From e3ee24e42b284aa502df3257f85da107d134b283 Mon Sep 17 00:00:00 2001 From: aradwann Date: Tue, 12 Nov 2024 10:53:25 +0200 Subject: [PATCH] restore sccache mounting --- .github/workflows/docker.yml | 17 ++++++++++++++++- docker/Dockerfile | 6 +++++- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 31d07af1b..d2b00cf74 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -67,7 +67,22 @@ jobs: # https://docs.warpbuild.com/cache/docker-layer-caching#step-1-set-up-docker-buildx-action driver-opts: | network=host - + + - name: Cache sccache + uses: actions/cache@v4 + with: + path: sccache-cache + key: ${{ runner.os }}-sccache-${{ hashFiles('**/Cargo.lock') }} + + - name: Inject sccache-cache into Docker + uses: reproducible-containers/buildkit-cache-dance@v3 + with: + cache-map: | + { + "sccache-cache": "/var/cache/sccache" + } + skip-extraction: ${{ steps.cache.outputs.cache-hit }} + - name: Log into GitHub container registry uses: docker/login-action@v3 with: diff --git a/docker/Dockerfile b/docker/Dockerfile index 2a39ee384..dfa67a611 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -39,7 +39,11 @@ RUN just arch=$TARGETARCH libc=gnu features=$RESTATE_FEATURES chef-cook --releas COPY . . -RUN just arch=$TARGETARCH libc=gnu features=$RESTATE_FEATURES build --release --bin restate-server && \ +# Mount the sccache directory as a cache to leverage sccache during build +# Caching layer if nothing has changed +# Use sccache during the main build +RUN --mount=type=cache,target=/var/cache/sccache \ + just arch=$TARGETARCH libc=gnu features=$RESTATE_FEATURES build --release --bin restate-server && \ just notice-file && \ mv target/$(just arch=$TARGETARCH libc=gnu print-target)/release/restate-server target/restate-server