Skip to content

Commit 14800e4

Browse files
committed
test: split cargo fetch from cargo chef cook into separate layers
Experiment: use cargo chef cook --no-build to materialize the skeleton (real Cargo.toml/Cargo.lock, dummy source) without compiling, then run a separate cargo fetch --locked as its own layer, then cook again to actually compile. Goal is to make dependency downloading independently cacheable from compilation, so a change to build flags alone doesn't force re-downloading everything. Running in parallel against optimize/validity-docker-build-cache (single combined cook layer) to compare — this only matters if it still compiles successfully.
1 parent 4cf1ab0 commit 14800e4

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

validity/Dockerfile

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,19 @@ RUN curl -L https://sp1.succinct.xyz | bash && \
4646
# dependency with a higher MSRV — unrelated to which --bin is requested.
4747
COPY --from=planner /build/rust-toolchain.toml rust-toolchain.toml
4848
COPY --from=planner /build/recipe.json recipe.json
49+
50+
# Materialize the skeleton (real Cargo.toml/Cargo.lock, dummy source) without
51+
# building, so downloading and compiling become two separately cacheable
52+
# layers instead of one. If only build flags change later, the fetch layer
53+
# above can still hit even when the compile layer doesn't.
54+
RUN cargo chef cook --recipe-path recipe.json --no-build
55+
56+
# Download dependency sources as their own layer, keyed only on Cargo.lock.
57+
RUN --mount=type=ssh \
58+
cargo fetch --locked
59+
60+
# Actually compile. Re-running cook regenerates the same deterministic
61+
# skeleton from recipe.json; cargo finds everything already fetched above.
4962
RUN --mount=type=ssh \
5063
cargo chef cook --release --bin clear-stuck-txs --recipe-path recipe.json
5164

0 commit comments

Comments
 (0)