Skip to content

Commit 9d90048

Browse files
authored
perf: add Docker layer caching to CI image builds (#163)
1 parent ff5746b commit 9d90048

1 file changed

Lines changed: 16 additions & 7 deletions

File tree

.github/workflows/test.yml

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -124,33 +124,42 @@ jobs:
124124
125125
docker:
126126
runs-on: ubuntu-latest
127+
services:
128+
registry:
129+
image: registry:3
130+
ports:
131+
- 5000:5000
127132
steps:
128133
- uses: actions/checkout@v4
129134

130135
- name: Set up Docker Buildx
131136
uses: docker/setup-buildx-action@v3
132137
with:
133-
driver: docker
138+
driver-opts: network=host
134139

135140
- name: Build base image
136141
uses: docker/build-push-action@v6
137142
with:
138143
context: ./perry
139144
file: ./perry/Dockerfile.base
140-
load: true
141-
tags: perry-base:latest
145+
push: true
146+
tags: localhost:5000/perry-base:latest
147+
cache-from: type=gha,scope=perry-base
148+
cache-to: type=gha,scope=perry-base,mode=max
142149

143150
- name: Build full image
144151
uses: docker/build-push-action@v6
145152
with:
146153
context: ./perry
147-
load: true
148154
tags: perry:latest
149155
build-args: |
150-
BASE_IMAGE=perry-base:latest
156+
BASE_IMAGE=localhost:5000/perry-base:latest
157+
cache-from: type=gha,scope=perry-full
158+
cache-to: type=gha,scope=perry-full,mode=max
159+
outputs: type=docker,dest=perry-image.tar
151160

152-
- name: Save Docker image
153-
run: docker save perry:latest | gzip > perry-image.tar.gz
161+
- name: Compress Docker image
162+
run: gzip perry-image.tar
154163

155164
- name: Upload Docker image
156165
uses: actions/upload-artifact@v4

0 commit comments

Comments
 (0)