Update Dockerfile.

This commit is contained in:
Luca Palmieri 2021-08-31 23:39:41 +02:00
parent 454a5e4afd
commit 2aa2c9a642

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
FROM chef as planner
COPY . .
# Compute a lock-like file for our project
RUN cargo chef prepare --recipe-path recipe.json
FROM lukemathwalker/cargo-chef:latest-rust-1.53.0 as cacher
WORKDIR /app
FROM chef as builder
COPY --from=planner /app/recipe.json recipe.json
# Build our project dependencies, not our application!
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 . .
ENV SQLX_OFFLINE true
# Build our project
RUN cargo build --release --bin zero2prod
FROM debian:buster-slim AS runtime