Last active
June 5, 2024 20:24
-
-
Save terry90/cbb5337335d3252146ef92b62969f83d to your computer and use it in GitHub Desktop.
Rust Dockerfile to build really small containers with postgres and SSL (~20Mo with rocket and diesel). Dependencies are cached for faster builds.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM clux/muslrust as build | |
WORKDIR /app/ | |
# Deps caching begins | |
COPY Cargo.toml . | |
COPY Cargo.lock . | |
RUN mkdir src | |
RUN echo "fn main() {}" > src/main.rs | |
RUN apt-get update && apt-get install -y pkg-config libssl-dev libpq-dev && apt-get clean | |
RUN cargo build --release | |
# Deps caching ends | |
COPY . . | |
RUN touch src/main.rs | |
RUN cargo build --release | |
FROM alpine | |
WORKDIR /app/ | |
COPY --from=build app/target/x86_64-unknown-linux-musl/release/project ./ | |
ENV ROCKET_ENV prod | |
CMD ["./project"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment