mailApp/Dockerfile

30 lines
842 B
Docker
Raw Permalink Normal View History

FROM lukemathwalker/cargo-chef:latest-rust-1.57.0 AS chef
WORKDIR /app
# Create lock file for project to be used in builder
FROM chef AS planner
COPY . .
RUN cargo chef prepare --recipe-path recipe.json
# Build dependancies
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
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 ["./mail_app"]