Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
# syntax=docker/dockerfile:1.24
# check=error=true

FROM rust:1.96-slim-trixie AS build
FROM lukemathwalker/cargo-chef:0.1.77-rust-1.96-slim-trixie AS chef
WORKDIR /app

FROM chef AS planner
COPY --exclude=target --exclude=.git . .
RUN cargo chef prepare --recipe-path recipe.json

FROM chef AS build
COPY --from=planner /app/recipe.json recipe.json
# Dependencies are compiled into their own layer, cached until recipe.json changes
RUN cargo chef cook --release --recipe-path recipe.json
COPY --exclude=target --exclude=.git . .
RUN --mount=type=cache,target=/usr/local/cargo/registry \
--mount=type=cache,target=/app/target \
cargo build --release && \
cp target/release/rust-template /rust-template
RUN cargo build --release

FROM gcr.io/distroless/cc-debian13:nonroot
COPY --link --from=build /rust-template /
COPY --link --from=build /app/target/release/rust-template /
ENTRYPOINT ["/rust-template"]