Bake a Compose stack
Save a running Docker Compose stack as a checkpoint that forks start from with their containers already up.
The call behind cua sb bake: a local VM (by default the docker tier, a Linux image with Docker), the project uploaded, docker compose up --wait, the stack checked, then a live memory checkpoint. Fork it with Sandboxes.fork. See Run Docker Compose stacks in a VM.
Bake#
Methods of Sandboxes.
Sandboxes.bake#
Bakes a Docker Compose project into a checkpoint that forks start
from with its containers already running: a local VM (by default
the docker tier, dockerd up at boot), the project uploaded, docker compose up --wait, the stack checked (every service running or
healthy, none restarted) and health commands passed, run
commands, then a live memory checkpoint. The bake Space is deleted
afterwards unless keep. Fork it with fork(checkpoint, name).
async def bake(self, options: BakeOptions) -> BakeSummary| Parameter | Type | Default |
|---|---|---|
options | BakeOptions | required |
Returns BakeSummary · Async · Raises CuaError
BakeOptions record#
Options for Sandboxes.bake.
| Field | Type | Default | Description |
|---|---|---|---|
project_dir / projectDir | String | The Docker Compose project directory on this machine (holds compose.yaml or docker-compose.yml, and whatever it builds or mounts). | |
checkpoint | String | The checkpoint to save (Sandboxes.fork(checkpoint, name) starts from it). | |
image | Option<String> | None | The image: a reference or a local disk path. None: the docker tier (Image.linux(tier="docker"), a Linux image with Docker). |
name | Option<String> | None | The bake Space's name. None: bake-<checkpoint>. |
cpus | Option<u32> | None | vCPUs of the bake Space (forks get the same). |
memory_mb / memoryMb | Option<u64> | None | Memory of the bake Space in MiB (forks get the same). |
compose_files / composeFiles | Vec<String> | [] | Compose files, relative to the project. Empty: compose's own lookup. |
project_name / projectName | Option<String> | None | The compose project name. None: the directory name. |
dest | Option<String> | None | Where the project lands in the guest. None: /opt/cua-bake/<project>. |
image_tarballs / imageTarballs | Vec<String> | [] | docker save tarballs on this machine to docker load before compose up, for images the guest cannot pull. |
health | Vec<String> | [] | Guest shell commands, run as root in the project directory, that must exit 0 before the checkpoint (each retried until health_timeout_s). compose up --wait already waits for the services' healthchecks. |
health_timeout_s / healthTimeoutS | u32 | 600 | Budget for compose up --wait and each health command, seconds. |
run | Vec<String> | [] | Guest shell commands, run as root in the project directory once the stack is healthy and before the checkpoint: state forks should start with. |
verify_fork / verifyFork | bool | false | Fork the checkpoint once, check the stack is live in the fork, then delete the fork. |
keep | bool | false | Keep the bake Space after the checkpoint (default: delete it). |
BakeSummary record#
What Sandboxes.bake did and how long each step took (seconds).
Returned by Sandboxes.bake.
| Field | Type | Default | Description |
|---|---|---|---|
checkpoint | String | The checkpoint saved. | |
runtime | String | The engine holding it (qemu, ...). | |
space | String | The bake Space (deleted unless keep). | |
image | String | The image it ran. | |
project | String | The compose project name. | |
dest | String | The project directory in the guest. | |
dockerd_ready_s / dockerdReadyS | Option<f64> | When dockerd became ready, seconds after the guest kernel booted. | |
create_s / createS | f64 | Creating the Space until its cua-spacesd answered. | |
upload_bytes / uploadBytes | u64 | The packed project's size. | |
upload_s / uploadS | f64 | Uploading the project and loading the tarballs. | |
compose_up_s / composeUpS | f64 | docker compose up --wait. | |
health_s / healthS | f64 | The stack check and health commands. | |
checkpoint_s / checkpointS | f64 | The checkpoint. | |
total_s / totalS | f64 | The whole bake. | |
containers | Vec<String> | One line per container: name, state or health, restarts. | |
verify_fork / verifyFork | Option<BakeForkCheck> | The fork check, with verify_fork. |
BakeForkCheck record#
The fork BakeOptions.verify_fork made and checked.
| Field | Type | Default | Description |
|---|---|---|---|
fork | String | The fork's name (deleted after the check). | |
fork_s / forkS | f64 | Seconds from the fork request until it was ready. | |
check_s / checkS | f64 | Seconds the stack check and health commands took in the fork. |