Skip to content

Instantly share code, notes, and snippets.

@agaviria
Created March 30, 2024 17:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save agaviria/844fdc65707ef9931658bacf46849be0 to your computer and use it in GitHub Desktop.
Save agaviria/844fdc65707ef9931658bacf46849be0 to your computer and use it in GitHub Desktop.
ARG VCS_REVISION
FROM docker.io/lukemathwalker/cargo-chef:0.1.66-rust-1.76 AS chef
# set the work directory for the backend application
WORKDIR /app
FROM chef AS planner
COPY . .
RUN cargo chef prepare --recipe-path recipe.json
FROM chef AS builder
COPY --from=planner /app/recipe.json recipe.json
RUN cargo chef cook --release --recipe-path recipe.json
COPY . .
ARG VCS_REVISION
RUN VCS_REVISION=$VCS_REVISION cargo build --release
FROM gcr.io/distroless/cc-debian12
# Copy application binary from the image 'builder'
COPY --from=builder /app/target/release/pulse-api /
# Instead of exposing port we run the binary
CMD ["./pulse-api"]
@agaviria
Copy link
Author

Quick Rust Dockerfile template

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment