mailApp/Dockerfile

33 lines
912 B
Docker
Raw Normal View History

##### Chef
FROM lukemathwalker/cargo-chef:latest-rust-1.76.0 as chef
WORKDIR /app
RUN apt update && apt install lld clang -y
##### Planner
FROM chef as planner
COPY . .
RUN cargo chef prepare --recipe-path recipe.json
##### Builder
# Builder prepares project dependancies, not the application.
FROM chef as builder
COPY --from=planner /app/recipe.json recipe.json
RUN cargo chef cook --release --recipe-path recipe.json
COPY . .
ENV SQLX_OFFLINE true
# Now build the application itself.
RUN cargo build --release --bin mail_app
##### Runtime
FROM debian:bookworm-slim as runtime
WORKDIR /app
RUN apt update && apt install -y --no-install-recommends openssl ca-certificates \
&& apt autoremove -y \
&& apt clean -y \
&& rm -rf /var/lib/apt/lists/*
COPY --from=builder /app/target/release/mail_app mail_app
COPY configuration configuration
ENV APP_ENVIRONMENT production
ENTRYPOINT ["./mail_app"]