Skip to content
1        10        20        30        40        50        601# My custom dockerfile23# Build stage4FROM rust:1.75-slim-bookworm AS builder56WORKDIR /app78# Install cargo-chef to cache dependencies9RUN cargo install cargo-chef1011# Plan stage - generate recipe.json for dependencies12FROM builder AS planner13COPY . .14RUN cargo chef prepare --recipe-path recipe.json1516# Build stage with caching17FROM builder AS build1819# Copy recipe.json first to cache dependency compilation20COPY --from=planner /app/recipe.json recipe.json2122# Build dependencies (cached if recipe.json hasn't changed)23RUN cargo chef cook --release --recipe-path recipe.json2425# Copy source code (this invalidates cache only when source changes)26COPY . .2728# Build the actual application (dependencies are already cached)29RUN cargo build --release3031# Runtime stage32FROM debian:bookworm-slim3334# Install runtime dependencies35RUN apt-get update && apt-get install -y \36    ca-certificates \37    libssl3 \38    && rm -rf /var/lib/apt/lists/*3940WORKDIR /app4142COPY --from=build /app/target/release/spruce /app/4344CMD ["./spruce"]