Skip to content

Commit d17a86a

Browse files
committed
ci: add Docker buildx GHA layer cache to build workflows
Caches Docker build layers in GitHub Actions cache (type=gha) scoped per platform. The second build-push-action call in the update workflow (push step) now reuses layers warmed by the test-image step, making the push build effectively free for this scratch-based image and future-proofing for any Dockerfile growth.
1 parent 2f438ad commit d17a86a

2 files changed

Lines changed: 5 additions & 0 deletions

File tree

.github/workflows/dockerimage.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,8 @@ jobs:
7777
platforms: linux/${{ matrix.platform }}
7878
load: true
7979
tags: ${{ env.IMAGE_NAME }}-${{ env.LATEST_VERSION }}
80+
cache-from: type=gha,scope=${{ matrix.platform }}
81+
cache-to: type=gha,mode=max,scope=${{ matrix.platform }}
8082

8183
- name: Test Image
8284
run: docker run --rm "${IMAGE_NAME}-${LATEST_VERSION}" -e "console.log('Hello from Node.js ' + process.version)"

.github/workflows/update-current-image.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,8 @@ jobs:
137137
platforms: linux/${{ matrix.platform }}
138138
load: true
139139
tags: ${{ env.IMAGE_NAME }}-${{ env.NODE_VERSION }}
140+
cache-from: type=gha,scope=${{ matrix.platform }}
141+
cache-to: type=gha,mode=max,scope=${{ matrix.platform }}
140142

141143
- name: Test Image
142144
run: docker run --rm "${IMAGE_NAME}-${NODE_VERSION}" -e "console.log('Hello from Node.js ' + process.version)"
@@ -152,6 +154,7 @@ jobs:
152154
tags: |
153155
${{ secrets.DOCKERHUB_USERNAME }}/${{ env.IMAGE_NAME }}:build-${{ github.run_id }}-${{ matrix.platform }}
154156
${{ env.GHCR_IMAGE }}:build-${{ github.run_id }}-${{ matrix.platform }}
157+
cache-from: type=gha,scope=${{ matrix.platform }}
155158

156159
merge:
157160
needs: [check_version, build]

0 commit comments

Comments
 (0)