Skip to content

Commit 69f30b9

Browse files
authored
ci(docker): switch to GitHub Actions cache to prevent runner disk… (#304)
* fix(ci-docker): switch to GitHub Actions cache to prevent runner disk exhaustion - refactor to use a matrix strategy for both amd64 and arm64 - remove qemu (#300) Signed-off-by: Reza Rajan <28660160+rezarajan@users.noreply.github.com>
1 parent 1f97ad6 commit 69f30b9

File tree

1 file changed

+11
-58
lines changed

1 file changed

+11
-58
lines changed

.github/workflows/ci-docker.yml

Lines changed: 11 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -14,77 +14,30 @@ permissions:
1414
contents: read
1515

1616
jobs:
17-
build-amd64:
18-
# runs-on: ubuntu-latest
19-
runs-on: [self-hosted, Linux, X64, ansible]
17+
build:
18+
strategy:
19+
matrix:
20+
arch: [amd64, arm64]
21+
runs-on: ${{ matrix.arch == 'arm64' && 'ubuntu-24.04-arm' || 'ubuntu-latest' }}
2022
steps:
2123
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 https://github.com/actions/checkout/releases/tag/v5.0.0
22-
- name: qemu
23-
uses: docker/setup-qemu-action@c7c53464625b32c7a7e944ae62b3e17d2b600130 # v3.7.0 https://github.com/docker/setup-qemu-action/releases/tag/v3.7.0
24-
- uses: docker/setup-buildx-action@e468171a9de216ec08956ac3ada2f0791b6bd435 # v3.11.1 https://github.com/docker/setup-buildx-action/releases/tag/v3.11.1
25-
- uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0 https://github.com/actions/cache/releases/tag/v4.3.0
26-
with:
27-
path: /tmp/.buildx-cache
28-
key: ${{ runner.os }}-${{ runner.arch }}-buildx-${{ github.sha }}
29-
restore-keys: |
30-
${{ runner.os }}-${{ runner.arch }}-buildx-
31-
- id: meta
32-
uses: docker/metadata-action@318604b99e75e41977312d83839a89be02ca4893 # v5.9.0 https://github.com/docker/metadata-action/releases/tag/v5.9.0
33-
with:
34-
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
35-
flavor: |
36-
latest=false
37-
suffix=-amd64
38-
- name: build
39-
uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # v6.18.0 https://github.com/docker/build-push-action/releases/tag/v6.18.0
40-
with:
41-
context: .
42-
push: false
43-
tags: ${{ steps.meta.outputs.tags }}
44-
labels: ${{ steps.meta.outputs.labels }}
45-
cache-from: type=local,src=/tmp/.buildx-cache
46-
cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max
47-
# TEMP fix
48-
# https://github.com/docker/build-push-action/issues/252
49-
# https://github.com/moby/buildkit/issues/1896
50-
- name: cache
51-
run: |
52-
rm -rf /tmp/.buildx-cache
53-
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
5424

55-
build-arm64:
56-
runs-on: ubuntu-24.04-arm
57-
steps:
58-
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 https://github.com/actions/checkout/releases/tag/v5.0.0
59-
- name: qemu
60-
uses: docker/setup-qemu-action@c7c53464625b32c7a7e944ae62b3e17d2b600130 # v3.7.0 https://github.com/docker/setup-qemu-action/releases/tag/v3.7.0
6125
- uses: docker/setup-buildx-action@e468171a9de216ec08956ac3ada2f0791b6bd435 # v3.11.1 https://github.com/docker/setup-buildx-action/releases/tag/v3.11.1
62-
- uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0 https://github.com/actions/cache/releases/tag/v4.3.0
63-
with:
64-
path: /tmp/.buildx-cache
65-
key: ${{ runner.os }}-${{ runner.arch }}-buildx-${{ github.sha }}
66-
restore-keys: |
67-
${{ runner.os }}-${{ runner.arch }}-buildx-
26+
6827
- id: meta
6928
uses: docker/metadata-action@318604b99e75e41977312d83839a89be02ca4893 # v5.9.0 https://github.com/docker/metadata-action/releases/tag/v5.9.0
7029
with:
7130
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
7231
flavor: |
7332
latest=false
74-
suffix=-arm64v8
75-
- name: build
33+
suffix=-${{ matrix.arch == 'arm64' && 'arm64v8' || 'amd64' }}
34+
35+
- name: Build Docker image
7636
uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # v6.18.0 https://github.com/docker/build-push-action/releases/tag/v6.18.0
7737
with:
7838
context: .
7939
push: false
8040
tags: ${{ steps.meta.outputs.tags }}
8141
labels: ${{ steps.meta.outputs.labels }}
82-
cache-from: type=local,src=/tmp/.buildx-cache
83-
cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max
84-
# TEMP fix
85-
# https://github.com/docker/build-push-action/issues/252
86-
# https://github.com/moby/buildkit/issues/1896
87-
- name: cache
88-
run: |
89-
rm -rf /tmp/.buildx-cache
90-
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
42+
cache-from: type=gha,scope=buildkit-${{ matrix.arch }}
43+
cache-to: type=gha,mode=max,scope=buildkit-${{ matrix.arch }}

0 commit comments

Comments
 (0)