Very large docker image size optimisations
without cross compiling to linux-musl, optimise image by compiling it on a slim rust image and then transferring only the binary over to a debian-slim image.
This commit is contained in:
+13
-3
@@ -1,11 +1,21 @@
|
||||
FROM rust:1.56
|
||||
FROM rust:1.56-slim AS builder
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
COPY . .
|
||||
|
||||
ENV SQLX_OFFLINE true
|
||||
RUN cargo build --release
|
||||
|
||||
FROM debian:bullseye-slim AS runtime
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Install dependancies required
|
||||
RUN apt update -y && apt install -y --no-install-recommends openssl && apt autoremove -y && apt clean -y && rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Copy the fully built binary and configuration to the image
|
||||
COPY --from=builder /app/target/release/mail_app mail_app
|
||||
COPY configuration configuration
|
||||
ENV APP_ENVIRONMENT production
|
||||
|
||||
ENTRYPOINT ["./target/release/mail_app"]
|
||||
ENTRYPOINT ["./mail_app"]
|
||||
Reference in New Issue
Block a user