From e885e14cd4fc5b0237850dc99f9c871e0b11df10 Mon Sep 17 00:00:00 2001 From: 0xfourzerofour Date: Thu, 12 Oct 2023 11:21:43 -0400 Subject: [PATCH 1/3] chore(docker): do not overide cache with COPY --- Dockerfile | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 6d0492c0e..eaf57ed63 100644 --- a/Dockerfile +++ b/Dockerfile @@ -8,7 +8,7 @@ RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - && echo "d RUN mkdir -p /etc/apt/keyrings RUN curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg RUN echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_20.x nodistro main" | tee /etc/apt/sources.list.d/nodesource.list -RUN apt-get update && apt-get -y upgrade && apt-get install -y libclang-dev pkg-config protobuf-compiler nodejs yarn +RUN apt-get update && apt-get -y upgrade && apt-get install -y libclang-dev pkg-config protobuf-compiler nodejs yarn rsync SHELL ["/bin/bash", "-c"] RUN curl -L https://foundry.paradigm.xyz | bash @@ -36,6 +36,11 @@ RUN cargo chef cook --profile $BUILD_PROFILE --recipe-path recipe.json # Build application COPY . . + +COPY --from=planner /app recipe-original +RUN rsync --recursive --checksum --itemize-changes --verbose recipe-original/ . +RUN rm -r recipe-original + RUN cargo build --profile $BUILD_PROFILE --locked --bin rundler # Use Ubuntu as the release image From 7bd5d06d0170465903dbe8ab785d3f5f0f8c7822 Mon Sep 17 00:00:00 2001 From: 0xfourzerofour Date: Thu, 12 Oct 2023 15:31:03 -0400 Subject: [PATCH 2/3] chore(docker): remove copy and add comment --- Dockerfile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index eaf57ed63..1b35f3042 100644 --- a/Dockerfile +++ b/Dockerfile @@ -34,9 +34,9 @@ ENV BUILD_PROFILE $BUILD_PROFILE # Builds dependencies RUN cargo chef cook --profile $BUILD_PROFILE --recipe-path recipe.json -# Build application -COPY . . - +# Undo the source file changes made by cargo-chef. +# rsync invalidates the cargo cache for the changed files only, by updating their timestamps. +# This makes sure the fake empty binaries created by cargo-chef are rebuilt. COPY --from=planner /app recipe-original RUN rsync --recursive --checksum --itemize-changes --verbose recipe-original/ . RUN rm -r recipe-original From d642e90bda560d6dbeec0ec2d80ffe6e75312915 Mon Sep 17 00:00:00 2001 From: 0xfourzerofour Date: Thu, 12 Oct 2023 17:39:24 -0400 Subject: [PATCH 3/3] chore(docker): use locked version --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 1b35f3042..15b72a803 100644 --- a/Dockerfile +++ b/Dockerfile @@ -15,7 +15,7 @@ RUN curl -L https://foundry.paradigm.xyz | bash ENV PATH="/root/.foundry/bin:${PATH}" RUN foundryup -RUN cargo install cargo-chef +RUN cargo install cargo-chef --locked WORKDIR /app