Skip to content

Commit

Permalink
Fix docker cache for container build
Browse files Browse the repository at this point in the history
Signed-off-by: Nicolas Belouin <[email protected]>
  • Loading branch information
diconico07 committed Oct 26, 2023
1 parent 0ee6a20 commit 019748e
Showing 1 changed file with 22 additions and 3 deletions.
25 changes: 22 additions & 3 deletions .github/workflows/build-rust-containers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@ jobs:
run: |
echo "version=$(cat version.txt)" >> $GITHUB_OUTPUT
- name: Cache Docker layers
uses: actions/cache@v3
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.ref_name }}-${{ matrix.component.label }}

- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
Expand Down Expand Up @@ -81,13 +87,19 @@ jobs:
build-args: |
AKRI_COMPONENT=agent
EXTRA_CARGO_ARGS=${{matrix.component.cargo-build-args}}
cache-from: type=gha,scope=${{github.ref_name}}-${{matrix.component.label}}
cache-to: type=gha,mode=max,scope=${{github.ref_name}}-${{matrix.component.label}}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
file: build/containers/Dockerfile.rust
platforms: linux/amd64,linux/arm64,linux/arm/v7

# This ensures we don't end-up with an ever-growing cache
- name: Move cache
run: |
rm -rf /tmp/.buildx-cache
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
build-others:
runs-on: ubuntu-latest
needs: build-agents
Expand All @@ -114,6 +126,13 @@ jobs:
run: |
echo "version=$(cat version.txt)" >> $GITHUB_OUTPUT
- name: Cache Docker layers
uses: actions/cache/restore@v3
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.ref_name }}-agent
fail-on-cache-miss: true

- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
Expand All @@ -140,7 +159,7 @@ jobs:
build-args: |
AKRI_COMPONENT=${{matrix.component.label}}
EXTRA_CARGO_ARGS=--release
cache-from: type=gha,scope=${{github.ref_name}}-agent
cache-from: type=local,src=/tmp/.buildx-cache
# No cache-to here as we want to use the one from agent
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
Expand Down

0 comments on commit 019748e

Please sign in to comment.