Skip to content

Instantly share code, notes, and snippets.

@oldsj
Created December 3, 2020 18:17
Show Gist options
  • Save oldsj/416087bad5fd34498623ee285db6cc94 to your computer and use it in GitHub Desktop.
Save oldsj/416087bad5fd34498623ee285db6cc94 to your computer and use it in GitHub Desktop.
An Ideal Dockerfile for Rust
FROM rust:slim as builder
WORKDIR /app
RUN rustup default nightly
RUN rustup target add x86_64-unknown-linux-musl --toolchain=nightly
WORKDIR /app/gcpizza
COPY Cargo.toml Cargo.lock ./
COPY src ./src
RUN cargo build --target x86_64-unknown-linux-musl --release
FROM scratch as runtime
COPY --from=builder /app/gcpizza/target/x86_64-unknown-linux-musl/release/gcpizza .
COPY Rocket.toml .
USER 1000
EXPOSE 8080
CMD ["./gcpizza"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment