Skip to content

Use cargo-chef so the Docker layer cache works - #1

Merged
valar999 merged 1 commit into
mainfrom
cargo-chef
Aug 26, 2026
Merged

Use cargo-chef so the Docker layer cache works#1
valar999 merged 1 commit into
mainfrom
cargo-chef

Conversation

@valar999

Copy link
Copy Markdown
Member

cache-to: type=gha exports image layers only: the contents of RUN cache mounts (cargo registry, target/) live inside the buildx builder, which CI recreates on every run. The COPY . . layer changes with every commit, so the cargo build layer never hits and each push compiles all dependencies from scratch (~10 min).

cargo-chef moves dependency compilation into a layer keyed only by recipe.json, derived from Cargo.toml/Cargo.lock. That layer survives source-only commits, so a typical build recompiles just this crate.

cache-to: type=gha exports image layers only: the contents of RUN cache
mounts (cargo registry, target/) live inside the buildx builder, which
CI recreates on every run. The COPY . . layer changes with every
commit, so the cargo build layer never hits and each push compiles all
dependencies from scratch (~10 min).

cargo-chef moves dependency compilation into a layer keyed only by
recipe.json, derived from Cargo.toml/Cargo.lock. That layer survives
source-only commits, so a typical build recompiles just this crate.
@valar999
valar999 merged commit dd037a3 into main Aug 26, 2026
1 check passed
@valar999
valar999 deleted the cargo-chef branch August 26, 2026 15:53
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