Use debian as base image. (#16)

This commit is contained in:
Luca Palmieri 2020-11-04 10:09:04 +00:00 committed by GitHub
parent 918af7a6c4
commit 95e403575a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,4 +1,4 @@
FROM rust:1.47 as planner
FROM rust:1.47 AS planner
WORKDIR app
# We only pay the installation cost once,
# it will be cached from the second build onwards
@ -9,14 +9,14 @@ COPY . .
# Compute a lock-like file for our project
RUN cargo chef prepare --recipe-path recipe.json
FROM rust:1.47 as cacher
FROM rust:1.47 AS cacher
WORKDIR app
RUN cargo install cargo-chef
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.47 as builder
FROM rust:1.47 AS builder
WORKDIR app
# Copy over the cached dependencies
COPY --from=cacher /app/target target
@ -26,8 +26,12 @@ COPY . .
ENV SQLX_OFFLINE true
RUN cargo build --release --bin chapter05
FROM rust:1.47-slim as runtime
FROM debian:buster-slim AS runtime
WORKDIR app
RUN apt-get update -y \
&& apt-get install -y --no-install-recommends openssl \
# Clean up
&& apt-get autoremove -y && apt-get clean -y && rm -rf /var/lib/apt/lists/*
COPY --from=builder /app/target/release/chapter05 zero2prod
COPY configuration configuration
ENV APP_ENVIRONMENT production