Skip to content

Instantly share code, notes, and snippets.

@nayato
Last active May 8, 2023 13:36
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save nayato/18f03329c8df3eb5461e2b2b8ec23b9f to your computer and use it in GitHub Desktop.
Save nayato/18f03329c8df3eb5461e2b2b8ec23b9f to your computer and use it in GitHub Desktop.
Dockerfile for rust multistage build sample
FROM rustlang/rust:nightly as builder
WORKDIR /app/src
RUN USER=root cargo new --bin ht
COPY Cargo.toml Cargo.lock ./ht/
WORKDIR /app/src/ht
RUN cargo build --release
COPY ./ ./
RUN cargo build --release
FROM debian:stable-slim
WORKDIR /app
RUN apt update \
&& apt install -y openssl ca-certificates \
&& apt clean \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
EXPOSE 80 443
COPY --from=builder /app/src/ht/target/release/ht /app/src/ht/gateway.tests.com.pfx ./
CMD ["/app/ht"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment