From 96c3ecbe65fa509220844d355ca5e732d7ba8060 Mon Sep 17 00:00:00 2001 From: Miraculous Owonubi Date: Sat, 15 Apr 2023 00:50:59 +0100 Subject: [PATCH] docker: play nicely with cargo's incremental compilation --- .dockerignore | 1 + Dockerfile | 18 ++++++++++++------ 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/.dockerignore b/.dockerignore index 18f93b5bb..afef96a88 100644 --- a/.dockerignore +++ b/.dockerignore @@ -4,5 +4,6 @@ .gitattributes target/ +!target/cache Dockerfile .dockerignore diff --git a/Dockerfile b/Dockerfile index 3cc43c446..9ea80c6f4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,13 +4,19 @@ RUN apt-get update \ && DEBIAN_FRONTEND=noninteractive \ apt-get install --no-install-recommends --assume-yes \ protobuf-compiler libprotobuf-dev -RUN echo "fn main() {}" > dummy.rs -COPY mpc-recovery/Cargo.toml Cargo.toml -RUN sed -i 's#src/main.rs#dummy.rs#' Cargo.toml -RUN sed -i 's#mpc-recovery-gcp = { path = "../mpc-recovery-gcp" }##' Cargo.toml -RUN cargo build --release COPY . . -RUN cargo build --release --package mpc-recovery +COPY ./targe[t]/cach[e]/us[r]/ /usr/ +RUN rm -rf ./target/cache +RUN CARGO_INCREMENTAL=0 cargo build --release --package mpc-recovery + +FROM scratch as export-artifacts +COPY --from=builder /usr/src/app/target /usr/src/app/target +COPY --from=builder /usr/local/cargo/bin /usr/local/cargo/bin +COPY --from=builder /usr/local/cargo/git* /usr/local/cargo/git +COPY --from=builder /usr/local/cargo/.crate.toml* /usr/local/cargo/.crate.toml +COPY --from=builder /usr/local/cargo/.crate2.toml* /usr/local/cargo/.crate2.toml +COPY --from=builder /usr/local/cargo/registry/cache /usr/local/cargo/registry/cache +COPY --from=builder /usr/local/cargo/registry/index /usr/local/cargo/registry/index FROM debian:buster-slim as runtime RUN apt-get update && apt-get install --assume-yes libssl-dev