Complete Chapter 5
+ Add in More CI/CD + Update Tests and Configurations
This commit is contained in:
+32
@@ -0,0 +1,32 @@
|
||||
##### 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"]
|
||||
Reference in New Issue
Block a user