1- # Chef stage: shared base with cargo-chef installed
2- FROM rust:1.85 AS chef
3- RUN cargo install cargo-chef --locked
4- WORKDIR /build
5-
6- # Planner stage: compute a dependency-only recipe from the workspace
7- # Cargo.toml/Cargo.lock, independent of the rest of the source tree
8- FROM chef AS planner
9- COPY . .
10- RUN cargo chef prepare --recipe-path recipe.json
11-
121# Build stage
13- FROM chef AS builder
2+ FROM rust:1.85 AS builder
143
154# Install build dependencies
165RUN apt-get update && apt-get install -y \
@@ -28,25 +17,21 @@ RUN curl -LO https://go.dev/dl/go1.24.0.linux-amd64.tar.gz && \
2817 rm go1.24.0.linux-amd64.tar.gz
2918ENV PATH="/usr/local/go/bin:${PATH}"
3019
20+
21+ WORKDIR /build
22+
3123# Install SP1
3224RUN curl -L https://sp1.succinct.xyz | bash && \
3325 ~/.sp1/bin/sp1up -v 6.4.0 && \
3426 ~/.sp1/bin/cargo-prove prove --version
3527
36- # Build only the dependency graph first, keyed on the recipe (Cargo.toml/Cargo.lock)
37- # rather than the full source tree. As long as dependency versions don't change,
38- # this layer is reused from the registry build cache and the sp1-*/gnark crates
39- # don't get recompiled on every source change.
40- COPY --from=planner /build/recipe.json recipe.json
41- RUN --mount=type=ssh \
42- cargo chef cook --release --bin validity --bin clear-stuck-txs --recipe-path recipe.json
43-
4428# Copy only what's needed for the build
4529COPY . .
4630
47- # Build the server. Dependencies are already compiled by the cook step above,
48- # so this only (re)compiles the workspace's own crates that actually changed.
31+ # Build the server
4932RUN --mount=type=ssh \
33+ --mount=type=cache,target=/root/.cargo/registry \
34+ --mount=type=cache,target=/build/target \
5035 cargo build --bin validity --bin clear-stuck-txs --release && \
5136 cp target/release/validity /build/validity-proposer && \
5237 cp target/release/clear-stuck-txs /build/clear-stuck-txs
0 commit comments