11# syntax=docker/dockerfile:1
2- FROM rust:1.84.0-bookworm AS chef
3- # Install cargo-chef for dependency caching
4- RUN cargo install cargo-chef
2+ FROM lukemathwalker/cargo-chef:latest-rust-1.84-slim-bookworm AS chef
3+ RUN cargo install --locked sccache
4+ ENV RUSTC_WRAPPER=sccache
5+ ENV SCCACHE_CACHE_SIZE=2G
6+ ENV SCCACHE_DIR=/sccache
57WORKDIR /app
68
79FROM chef AS planner
@@ -25,19 +27,24 @@ WORKDIR /app/eth2near
2527RUN --mount=type=cache,target=/app/eth2near/target \
2628 --mount=type=cache,target=/usr/local/cargo/registry \
2729 --mount=type=cache,target=/usr/local/cargo/git \
30+ --mount=type=cache,target=/sccache,sharing=locked \
2831 cargo chef cook --release --recipe-path recipe.json
2932
3033# Copy source code and build the actual project
3134COPY eth2near/ ./
3235
33- # Build the final binaries - only rebuilds when source changes
36+ # Build with sccache - only rebuilds when source changes
3437RUN --mount=type=cache,target=/app/eth2near/target \
3538 --mount=type=cache,target=/usr/local/cargo/registry \
3639 --mount=type=cache,target=/usr/local/cargo/git \
40+ --mount=type=cache,target=/sccache,sharing=locked \
3741 cargo build --release && \
3842 cp target/release/eth2-contract-init /tmp/ && \
3943 cp target/release/eth2_to_near_relay /tmp/
4044
45+ # Show sccache stats (optional, for debugging)
46+ RUN sccache --show-stats
47+
4148# === RUNTIME STAGE ===
4249FROM debian:bookworm-slim AS runtime
4350
0 commit comments