diff --git a/HACKING.md b/HACKING.md index c0605dff..dec6ebc3 100644 --- a/HACKING.md +++ b/HACKING.md @@ -47,16 +47,6 @@ Windows: GOOS=linux GOARCH=amd64 go build -o uncloudd ./cmd/uncloudd ``` -## Docker in Docker (ucind) - -When running ucind and running in trouble, you must manually remove the cluster, by running: - -```shell -docker stop CONTAINERID -docker rm CONTAINERID -docker network rm CLUSTERNAME -``` - ## Testing Run all tests (unit and e2e): @@ -67,10 +57,10 @@ make test ### End-to-end tests -E2e tests run inside Docker using the [`ucind`](Dockerfile) (Uncloud-in-Docker) image. Build it first: +E2e tests run inside Docker using the [Uncloud-in-Docker](#uncloud-in-docker-ucind) image. Build it first: ```shell -make ucind-image +mise ucind:image ``` ⚠️ NOTE: You need to rebuild the `ucind` image every time you make changes to the daemon code if you want to test them @@ -127,3 +117,38 @@ Regenerate mocks: ```shell make mocks ``` + +## Uncloud in Docker (UCinD) + +The [`ucind`](./cmd/ucind) CLI lets you run Uncloud clusters locally using Docker containers instead of real machines. +Each cluster machine runs as a Docker container connected to a shared Docker network. + +Cluster machines use the `ghcr.io/psviderski/ucind:latest` Docker image by default. It may not always have the +latest changes to the `uncloudd` daemon code as it's not automatically rebuilt on CI yet. + +You can rebuild it locally to pick up the latest changes, including your work in progress, and test them in a UCinD +cluster: + +```shell +mise ucind:image +``` + +Create a cluster with 3 machines: + +```shell +mise ucind cluster create -m 3 +``` + +This also sets the new cluster as the active context, so you can interact with it using the `uc` CLI right away. + +Remove the cluster when you're done: + +```shell +mise ucind cluster rm +``` + +Sometimes crashed tests or interrupted runs can leave orphaned containers and networks behind. Clean them all up with: + +```shell +mise ucind:cleanup +``` diff --git a/mise.toml b/mise.toml index 5f3e850c..a38f20b3 100644 --- a/mise.toml +++ b/mise.toml @@ -10,6 +10,9 @@ protoc = "27.3" protoc-gen-go = "1.34.2" protoc-gen-go-grpc = "1.5.1" +[vars] +ucind_image = "ghcr.io/psviderski/ucind:latest" + [env] _.file = ".env" @@ -42,6 +45,18 @@ protoc --go_out=. --go_opt=paths=source_relative --go-grpc_out=. --go-grpc_opt=p --proto_path=. --proto_path=internal/machine/api/vendor internal/machine/api/pb/*.proto """ +[tasks.uc] +description = "Run the Uncloud CLI" +run = "go run ./cmd/uncloud" + +[tasks.ucind] +description = "Run ucind CLI for managing local Docker-based clusters" +run = "go run ./cmd/ucind" + +[tasks."ucind:image"] +description = "Build the ucind Docker image" +run = "docker build -t {{vars.ucind_image}} --target ucind ." + [tasks."ucind:cleanup"] description = "Remove ucind managed containers and networks" run = """