build: reduce podman/docker image size

This commit is contained in:
Sandro Eiler 2024-02-07 12:14:51 +01:00
parent 9dde52c1cd
commit a25cb5a7ef
2 changed files with 20 additions and 2 deletions

6
.dockerignore Normal file
View file

@ -0,0 +1,6 @@
.env
target/
tests/
Dockerfile
scripts/
migrations/

View file

@ -1,8 +1,20 @@
FROM docker.io/rust:1.75.0
# Builder stage
FROM rust:1.75.0 AS builder
WORKDIR /app
RUN apt update && apt install lld clang -y
COPY . .
ENV SQLX_OFFLINE true
RUN cargo build --release
# Runtime stage
FROM rust:1.75.0-slim AS runtime
WORKDIR /app
# Copy the compiled binary from the builder environment
# to our runtime environment
COPY --from=builder /app/target/release/learn_axum zero2prod
# We need the configuration file at runtime!
COPY configuration configuration
ENV APP_ENVIRONMENT production
ENTRYPOINT ["./target/release/learn_axum"]
ENTRYPOINT ["./zero2prod"]