From 3f555f977a7f5c3f23a945281a6564170d5d9bf0 Mon Sep 17 00:00:00 2001 From: Max Audron Date: Tue, 7 Sep 2021 13:38:43 +0200 Subject: add cargo chef to container build to utilize caching --- Containerfile | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) (limited to 'Containerfile') diff --git a/Containerfile b/Containerfile index 7bf429e..b3b7ba3 100644 --- a/Containerfile +++ b/Containerfile @@ -2,26 +2,30 @@ # Cargo Build Stage # ------------------------------------------------------------------------------ -FROM docker.io/rust:1.52-alpine as cargo-build - -RUN rustup default nightly && rustup update - +FROM docker.io/lukemathwalker/cargo-chef:latest-rust-1.54.0-alpine AS chef WORKDIR /work +FROM chef AS planner COPY . . +RUN cargo chef prepare --recipe-path recipe.json + +FROM chef AS builder +COPY --from=planner /work/recipe.json recipe.json -RUN apk add --no-cache musl-dev +RUN cargo chef cook --release --recipe-path recipe.json + +COPY . . RUN cargo build --release # ------------------------------------------------------------------------------ # Final Stage # ------------------------------------------------------------------------------ -FROM alpine:3.13 +FROM scratch -COPY --from=cargo-build /work/target/release/catinator /usr/local/bin +COPY --from=builder /work/target/release/catinator /usr/local/bin ENV CATINATOR_CONFIG="/config.toml" ENV CATINATOR_PASSWORD="" -CMD ["/usr/local/bin/catinator"] +ENTRYPOINT ["/usr/local/bin/catinator"] -- cgit v1.2.3