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
ParameterTypeDefault
optionsBakeOptionsrequired

Returns BakeSummary · Async · Raises CuaError

BakeOptions record#

Options for Sandboxes.bake.

FieldTypeDefaultDescription
project_dir / projectDirStringThe Docker Compose project directory on this machine (holds compose.yaml or docker-compose.yml, and whatever it builds or mounts).
checkpointStringThe checkpoint to save (Sandboxes.fork(checkpoint, name) starts from it).
imageOption<String>NoneThe image: a reference or a local disk path. None: the docker tier (Image.linux(tier="docker"), a Linux image with Docker).
nameOption<String>NoneThe bake Space's name. None: bake-<checkpoint>.
cpusOption<u32>NonevCPUs of the bake Space (forks get the same).
memory_mb / memoryMbOption<u64>NoneMemory of the bake Space in MiB (forks get the same).
compose_files / composeFilesVec<String>[]Compose files, relative to the project. Empty: compose's own lookup.
project_name / projectNameOption<String>NoneThe compose project name. None: the directory name.
destOption<String>NoneWhere the project lands in the guest. None: /opt/cua-bake/<project>.
image_tarballs / imageTarballsVec<String>[]docker save tarballs on this machine to docker load before compose up, for images the guest cannot pull.
healthVec<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 / healthTimeoutSu32600Budget for compose up --wait and each health command, seconds.
runVec<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 / verifyForkboolfalseFork the checkpoint once, check the stack is live in the fork, then delete the fork.
keepboolfalseKeep 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.

FieldTypeDefaultDescription
checkpointStringThe checkpoint saved.
runtimeStringThe engine holding it (qemu, ...).
spaceStringThe bake Space (deleted unless keep).
imageStringThe image it ran.
projectStringThe compose project name.
destStringThe project directory in the guest.
dockerd_ready_s / dockerdReadySOption<f64>When dockerd became ready, seconds after the guest kernel booted.
create_s / createSf64Creating the Space until its cua-spacesd answered.
upload_bytes / uploadBytesu64The packed project's size.
upload_s / uploadSf64Uploading the project and loading the tarballs.
compose_up_s / composeUpSf64docker compose up --wait.
health_s / healthSf64The stack check and health commands.
checkpoint_s / checkpointSf64The checkpoint.
total_s / totalSf64The whole bake.
containersVec<String>One line per container: name, state or health, restarts.
verify_fork / verifyForkOption<BakeForkCheck>The fork check, with verify_fork.

BakeForkCheck record#

The fork BakeOptions.verify_fork made and checked.

FieldTypeDefaultDescription
forkStringThe fork's name (deleted after the check).
fork_s / forkSf64Seconds from the fork request until it was ready.
check_s / checkSf64Seconds the stack check and health commands took in the fork.