2021-11-16 15:50:00 +10:00
|
|
|
FROM lukemathwalker/cargo-chef:latest-rust-1.53.0 AS chef
|
2021-11-16 14:34:05 +10:00
|
|
|
WORKDIR /app
|
2021-11-16 15:50:00 +10:00
|
|
|
|
|
|
|
# Create lock file for project to be used in builder
|
|
|
|
FROM chef AS planner
|
2021-11-16 14:34:05 +10:00
|
|
|
COPY . .
|
2021-11-16 15:50:00 +10:00
|
|
|
RUN cargo chef prepare --recipe-path recipe.json
|
2021-11-16 15:40:32 +10:00
|
|
|
|
2021-11-16 15:50:00 +10:00
|
|
|
# Build dependancies
|
|
|
|
FROM chef as builder
|
|
|
|
COPY --from=planner /app/recipe.json recipe.json
|
|
|
|
RUN cargo chef cook --release --recipe-path recipe.json
|
|
|
|
|
|
|
|
COPY . .
|
2021-11-16 14:34:05 +10:00
|
|
|
ENV SQLX_OFFLINE true
|
2021-11-16 15:10:20 +10:00
|
|
|
RUN cargo build --release
|
2021-11-16 14:34:05 +10:00
|
|
|
|
2021-11-16 15:40:32 +10:00
|
|
|
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
|
2021-11-16 14:34:05 +10:00
|
|
|
ENV APP_ENVIRONMENT production
|
|
|
|
|
2021-11-16 15:40:32 +10:00
|
|
|
ENTRYPOINT ["./mail_app"]
|