Update Dockerfile.

This commit is contained in:
Luca Palmieri 2021-08-31 23:39:41 +02:00
parent 5239345c7d
commit 4c54c11adc

View file

@ -1,22 +1,18 @@
FROM lukemathwalker/cargo-chef:latest-rust-1.53.0 as planner FROM lukemathwalker/cargo-chef:latest-rust-1.53.0 as chef
WORKDIR /app WORKDIR /app
FROM chef as planner
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:latest-rust-1.53.0 as cacher FROM chef as builder
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.53.0 AS builder
WORKDIR /app
# Copy over the cached dependencies
COPY --from=cacher /app/target target
COPY --from=cacher /usr/local/cargo /usr/local/cargo
COPY . . COPY . .
ENV SQLX_OFFLINE true ENV SQLX_OFFLINE true
# Build our project
RUN cargo build --release --bin zero2prod RUN cargo build --release --bin zero2prod
FROM debian:buster-slim AS runtime FROM debian:buster-slim AS runtime