Skip to content

refactor(docker): convert thulp image to cargo-chef multi-stage - #20

Merged
bkataru merged 1 commit into
masterfrom
docker/cargo-chef
Oct 14, 2026
Merged

bkataru merged 1 commit into
masterfrom
docker/cargo-chef

Conversation

@bkataru

@bkataru bkataru commented Oct 9, 2026

Copy link
Copy Markdown
Member

Rationale

The estate-wide CI speedup (runner-side: baked toolchains, sccache per-repo volumes, pooled runners) is done; this is the image-build half. The previous Dockerfile was a plain two-stage build with no dependency caching: every source edit recompiled the entire workspace dependency graph from scratch.

This converts the Dockerfile to the same cargo-chef multi-stage pattern used by the eruka reference image: a chef stage installs cargo-chef, a planner stage captures a manifest-only recipe.json, a builder stage cooks dependencies from that recipe (cached independently of source), and only then copies the real sources for the final cargo build --release --bin thulp.

What changed

  • Added chef + planner stages; builder now cooks from recipe.json before compiling the workspace.
  • Registry/git/target dirs are cache-mounted (--mount=type=cache) so cooked deps persist between the two builder steps and across builds.
  • Added protobuf-compiler to the builder: the rs-utcp dependency compiles gRPC protos at build time and the plain rust:1.91-slim image has no protoc (this was the only thing missing for a clean build).
  • Preserved: workspace build context, --bin thulp, runtime user / ENTRYPOINT/CMD, LABELs, and the RUST_IMAGE/RUNTIME_IMAGE ARGs.

Verification

Built with a throwaway tag (docker build -t thulp-chef-check . — BuildKit, Docker 29.8.2) from a fresh clone; the image built successfully and docker run --rm thulp-chef-check --help prints the thulp CLI banner. The tag has been deleted.

…pattern

Mirrors /opt/eruka/Dockerfile: chef/planner/builder/runtime stages with
--mount=type=cache for the cargo registry/git/target dirs. Dependencies are
cooked from a manifest-only recipe, so source edits no longer invalidate the
dependency layer.

Repo-specific bits preserved: workspace build context (COPY . ...), the
--bin thulp build, the runtime user/ENTRYPOINT/LABELs, and the RUST_IMAGE/
RUNTIME_IMAGE ARGs. protobuf-compiler added to the builder because the
rs-utcp dependency compiles gRPC protos at build time and the plain
rust:1.91-slim image has no protoc.
@bkataru
bkataru merged commit ca25605 into master Oct 14, 2026
11 checks passed
@bkataru
bkataru deleted the docker/cargo-chef branch October 14, 2026 06:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant