From 0eedb44591684da9fda088f9a33ae9f79e73e9f2 Mon Sep 17 00:00:00 2001 From: aradwann Date: Mon, 11 Nov 2024 23:27:57 +0200 Subject: [PATCH] clean up after gha worked and try warp build cache --- .github/workflows/docker.yml | 35 +++++++---------------------------- docker/Dockerfile | 12 ++++++------ 2 files changed, 13 insertions(+), 34 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 367d6fb82e..f32b8ed1ee 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -67,24 +67,11 @@ jobs: # https://docs.warpbuild.com/cache/docker-layer-caching#step-1-set-up-docker-buildx-action driver-opts: | network=host - # this will be used to generate cache key, - # so if dev-tools dockerfile or docker/Dockerfile in restate repo or cargo.lock change - # old cache will be invalidated and new cache will be created - - name: Download dev-tools Dockerfile - run: curl -L -o external.Dockerfile https://github.com/restatedev/dev-tools/raw/main/docker/Dockerfile - - - name: Cache Docker layers - uses: actions/cache@v4 - with: - path: /tmp/.buildx-cache - key: ${{ runner.os }}-buildx-${{ hashFiles('**/Dockerfile', '**/Cargo.lock', 'external.Dockerfile') }} - restore-keys: | - ${{ runner.os }}-buildx- - name: Cache sccache uses: actions/cache@v4 with: - path: ~/.cache/sccache + path: sccache-cache key: ${{ runner.os }}-sccache-${{ hashFiles('**/Cargo.lock') }} - name: Inject sccache-cache into Docker @@ -92,7 +79,7 @@ jobs: with: cache-map: | { - "~/.cache/sccache": "~/.cache/sccache" + "sccache-cache": "/var/cache/sccache" } skip-extraction: ${{ steps.cache.outputs.cache-hit }} @@ -147,8 +134,8 @@ jobs: CARGO_PROFILE_RELEASE_DEBUG=${{ inputs.debug }} RESTATE_FEATURES=${{ inputs.features || '' }} SCCACHE_DIR=~/.cache/sccache - cache-from: type=gha - cache-to: type=gha,mode=max + cache-from: type=gha,url=http://127.0.0.1:49160/ + cache-to: type=gha,url=http://127.0.0.1:49160/,mode=max - name: Save docker image as tar if: ${{ inputs.uploadImageAsTarball }} @@ -183,14 +170,6 @@ jobs: CARGO_PROFILE_RELEASE_DEBUG=${{ inputs.debug }} RESTATE_FEATURES=${{ inputs.features || '' }} SCCACHE_DIR=/sccache-cache - cache-from: type=local,src=/tmp/.buildx-cache - cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max - - - # Temp fix for growing cache size - # https://github.com/docker/build-push-action/issues/252 - # https://github.com/moby/buildkit/issues/1896 - name: Move cache - run: | - rm -rf /tmp/.buildx-cache - mv /tmp/.buildx-cache-new /tmp/.buildx-cache - \ No newline at end of file + cache-from: type=gha,url=http://127.0.0.1:49160/ + cache-to: type=gha,url=http://127.0.0.1:49160/,mode=max + \ No newline at end of file diff --git a/docker/Dockerfile b/docker/Dockerfile index e1257d276f..eacb0f5106 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -28,20 +28,20 @@ ARG SCCACHE_SERVER_PORT ARG TARGETARCH ENV RUSTC_WRAPPER=/usr/bin/sccache -ENV SCCACHE_DIR=~/.cache/sccache +ENV SCCACHE_DIR=/var/cache/sccache # Overrides the behaviour of the release profile re including debug symbols, which in our repo is not to include them. # Should be set to 'false' or 'true'. See https://doc.rust-lang.org/cargo/reference/environment-variables.html ARG CARGO_PROFILE_RELEASE_DEBUG=false ARG RESTATE_FEATURES='' -# Mount the sccache directory as a cache to leverage sccache during build -# Caching layer if nothing has changed -RUN --mount=type=cache,target=~/.cache/sccache \ - just arch=$TARGETARCH libc=gnu features=$RESTATE_FEATURES chef-cook --release --bin restate-server + +RUN just arch=$TARGETARCH libc=gnu features=$RESTATE_FEATURES chef-cook --release --bin restate-server COPY . . +# 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=~/.cache/sccache \ +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