Skip to content

Commit a2a11c9

Browse files
Added cache for GitHub Actions Docker builds (#2214)
1 parent a5016bf commit a2a11c9

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

.github/workflows/docker-publish.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ jobs:
1919
- name: Checkout repository
2020
uses: actions/checkout@v4
2121

22+
- name: Set up Docker Buildx
23+
uses: docker/setup-buildx-action@v3
24+
2225
- name: Log in to the Container registry
2326
uses: docker/login-action@v3
2427
with:
@@ -44,3 +47,5 @@ jobs:
4447
push: true
4548
tags: ${{ steps.meta.outputs.tags }}
4649
labels: ${{ steps.meta.outputs.labels }}
50+
cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}-buildcache:bc-publish-${{ github.ref_name }}
51+
cache-to: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}-buildcache:bc-publish-${{ github.ref_name }},mode=max

.github/workflows/docker-test-build.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,17 @@ name: Docker test build
33
on:
44
pull_request:
55

6+
env:
7+
REGISTRY: ghcr.io
8+
IMAGE_NAME: ${{ github.repository }}
9+
610
concurrency:
711
group: ${{ github.workflow }}-${{ github.ref }}
812
cancel-in-progress: true
913

1014
permissions:
1115
contents: read
16+
packages: write
1217

1318
jobs:
1419
build-image:
@@ -25,10 +30,22 @@ jobs:
2530
- name: Checkout repository
2631
uses: actions/checkout@v4
2732

33+
- name: Set up Docker Buildx
34+
uses: docker/setup-buildx-action@v3
35+
36+
- name: Log in to the Container registry
37+
uses: docker/login-action@v3
38+
with:
39+
registry: ${{ env.REGISTRY }}
40+
username: ${{ github.actor }}
41+
password: ${{ secrets.GITHUB_TOKEN }}
42+
2843
- name: Test docker image build (local development)
2944
uses: docker/build-push-action@v6
3045
with:
3146
context: .
3247
push: false
3348
build-args: |
3449
REQ_FILE=requirements/${{ matrix.req_file }}
50+
cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}-buildcache:bc-test-build-${{ matrix.req_file }}
51+
cache-to: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}-buildcache:bc-test-build-${{ matrix.req_file }},mode=max

0 commit comments

Comments
 (0)