mirror of
https://github.com/LukeMathWalker/zero-to-production.git
synced 2024-11-25 10:11:00 +00:00
Use pinned images in Dockerfile
This commit is contained in:
parent
bc22cdca68
commit
6ffdae5742
1 changed files with 10 additions and 9 deletions
19
Dockerfile
19
Dockerfile
|
@ -1,31 +1,32 @@
|
||||||
FROM lukemathwalker/cargo-chef as planner
|
FROM lukemathwalker/cargo-chef:latest-rust-1.53.0 as planner
|
||||||
WORKDIR app
|
WORKDIR /app
|
||||||
COPY . .
|
COPY . .
|
||||||
# Compute a lock-like file for our project
|
# Compute a lock-like file for our project
|
||||||
RUN cargo chef prepare --recipe-path recipe.json
|
RUN cargo chef prepare --recipe-path recipe.json
|
||||||
|
|
||||||
FROM lukemathwalker/cargo-chef as cacher
|
FROM lukemathwalker/cargo-chef:latest-rust-1.53.0 as cacher
|
||||||
WORKDIR app
|
WORKDIR /app
|
||||||
COPY --from=planner /app/recipe.json recipe.json
|
COPY --from=planner /app/recipe.json recipe.json
|
||||||
# Build our project dependencies, not our application!
|
# Build our project dependencies, not our application!
|
||||||
RUN cargo chef cook --release --recipe-path recipe.json
|
RUN cargo chef cook --release --recipe-path recipe.json
|
||||||
|
|
||||||
FROM rust:1.50 AS builder
|
FROM rust:1.53.0 AS builder
|
||||||
WORKDIR app
|
WORKDIR /app
|
||||||
# Copy over the cached dependencies
|
# Copy over the cached dependencies
|
||||||
COPY --from=cacher /app/target target
|
COPY --from=cacher /app/target target
|
||||||
COPY --from=cacher /usr/local/cargo /usr/local/cargo
|
COPY --from=cacher /usr/local/cargo /usr/local/cargo
|
||||||
COPY . .
|
COPY . .
|
||||||
# Build our application, leveraging the cached deps!
|
|
||||||
ENV SQLX_OFFLINE true
|
ENV SQLX_OFFLINE true
|
||||||
RUN cargo build --release --bin zero2prod
|
RUN cargo build --release --bin zero2prod
|
||||||
|
|
||||||
FROM debian:buster-slim AS runtime
|
FROM debian:buster-slim AS runtime
|
||||||
WORKDIR app
|
WORKDIR /app
|
||||||
RUN apt-get update -y \
|
RUN apt-get update -y \
|
||||||
&& apt-get install -y --no-install-recommends openssl \
|
&& apt-get install -y --no-install-recommends openssl \
|
||||||
# Clean up
|
# Clean up
|
||||||
&& apt-get autoremove -y && apt-get clean -y && rm -rf /var/lib/apt/lists/*
|
&& apt-get autoremove -y \
|
||||||
|
&& apt-get clean -y \
|
||||||
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
COPY --from=builder /app/target/release/zero2prod zero2prod
|
COPY --from=builder /app/target/release/zero2prod zero2prod
|
||||||
COPY configuration configuration
|
COPY configuration configuration
|
||||||
ENV APP_ENVIRONMENT production
|
ENV APP_ENVIRONMENT production
|
||||||
|
|
Loading…
Reference in a new issue