Skip to content

Commit 9553fd9

Browse files
committed
Do docker push in one combined rake task to decrease size of the images
If images are built independent, they don't share common layers. Running the push with all caches combined fixes this.
1 parent 25410ae commit 9553fd9

File tree

3 files changed

+605
-64
lines changed

3 files changed

+605
-64
lines changed
Lines changed: 294 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,63 @@
1-
name: Publish docker images to GHCR
2-
concurrency:
3-
group: "${{github.workflow}}-${{github.ref}}"
4-
cancel-in-progress: true
1+
2+
name: Weekly publish docker images to GHCR
53
on:
64
workflow_dispatch:
75
schedule:
86
- cron: "0 3 * * 3" # At 03:00 on Wednesday # https://crontab.guru/#0_3_*_*_3
97

8+
9+
concurrency:
10+
group: "${{github.workflow}}-${{github.ref}}"
11+
cancel-in-progress: true
12+
13+
14+
15+
1016
jobs:
1117
build:
12-
name: build native
18+
name: "build ${{ matrix.platform }} ${{ matrix.os }}"
1319
strategy:
1420
fail-fast: false
1521
matrix:
1622
os:
1723
- ubuntu-latest
1824
- ubuntu-24.04-arm
1925
platform:
26+
2027
- aarch64-linux-gnu
28+
2129
- aarch64-linux-musl
30+
2231
- aarch64-mingw-ucrt
32+
2333
- arm-linux-gnu
34+
2435
- arm-linux-musl
36+
2537
- arm64-darwin
38+
2639
- jruby
40+
2741
- x64-mingw-ucrt
42+
2843
- x64-mingw32
44+
2945
- x86-linux-gnu
46+
3047
- x86-linux-musl
48+
3149
- x86-mingw32
50+
3251
- x86_64-darwin
52+
3353
- x86_64-linux-gnu
54+
3455
- x86_64-linux-musl
56+
3557
runs-on: ${{ matrix.os }}
3658
steps:
3759
- uses: actions/checkout@v4
60+
3861
- uses: ruby/setup-ruby@v1
3962
with:
4063
ruby-version: "3.3"
@@ -47,8 +70,9 @@ jobs:
4770
key: ${{ runner.os }}-on-${{ runner.arch }}-${{ matrix.platform }}-buildx-${{ github.sha }}
4871
restore-keys: ${{ runner.os }}-on-${{ runner.arch }}-${{ matrix.platform }}-buildx
4972
enableCrossOsArchive: true
50-
- name: Change docker to a cache-able driver
73+
- name: Build the image for platform ${{ matrix.platform }} on ${{ runner.arch }}
5174
run: |
75+
# Change docker to a cache-able driver
5276
docker buildx create --driver docker-container --use
5377
bundle exec rake build:${{ matrix.platform }} RCD_DOCKER_BUILD="docker buildx build --cache-from=type=local,src=tmp/build-cache-${{ runner.arch }} --cache-to=type=local,dest=tmp/build-cache-new"
5478
- name: Show docker images
@@ -63,41 +87,280 @@ jobs:
6387
needs: build
6488
strategy:
6589
fail-fast: false
66-
matrix:
67-
platform:
68-
- aarch64-linux-gnu
69-
- aarch64-linux-musl
70-
- aarch64-mingw-ucrt
71-
- arm-linux-gnu
72-
- arm-linux-musl
73-
- arm64-darwin
74-
- jruby
75-
- x64-mingw-ucrt
76-
- x64-mingw32
77-
- x86-linux-gnu
78-
- x86-linux-musl
79-
- x86-mingw32
80-
- x86_64-darwin
81-
- x86_64-linux-gnu
82-
- x86_64-linux-musl
8390
runs-on: ubuntu-latest
8491
steps:
8592
- uses: actions/checkout@v4
86-
- name: Use X64 cache from primary pipeline
93+
94+
- name: Use X64 cache from primary pipeline of aarch64-linux-gnu
95+
uses: actions/cache/restore@v4
96+
with:
97+
path: tmp/build-cache-X64
98+
key: ${{ runner.os }}-on-X64-aarch64-linux-gnu-buildx-${{ github.sha }}
99+
restore-keys: ${{ runner.os }}-on-X64-aarch64-linux-gnu-buildx
100+
enableCrossOsArchive: true
101+
- run: mv tmp/build-cache-X64 tmp/build-cache-X64-aarch64-linux-gnu
102+
- name: Use ARM64 cache from primary pipeline of aarch64-linux-gnu
103+
uses: actions/cache/restore@v4
104+
with:
105+
path: tmp/build-cache-ARM64
106+
key: ${{ runner.os }}-on-ARM64-aarch64-linux-gnu-buildx-${{ github.sha }}
107+
restore-keys: ${{ runner.os }}-on-ARM64-aarch64-linux-gnu-buildx
108+
enableCrossOsArchive: true
109+
fail-on-cache-miss: true
110+
- run: mv tmp/build-cache-ARM64 tmp/build-cache-ARM64-aarch64-linux-gnu
111+
112+
- name: Use X64 cache from primary pipeline of aarch64-linux-musl
113+
uses: actions/cache/restore@v4
114+
with:
115+
path: tmp/build-cache-X64
116+
key: ${{ runner.os }}-on-X64-aarch64-linux-musl-buildx-${{ github.sha }}
117+
restore-keys: ${{ runner.os }}-on-X64-aarch64-linux-musl-buildx
118+
enableCrossOsArchive: true
119+
- run: mv tmp/build-cache-X64 tmp/build-cache-X64-aarch64-linux-musl
120+
- name: Use ARM64 cache from primary pipeline of aarch64-linux-musl
121+
uses: actions/cache/restore@v4
122+
with:
123+
path: tmp/build-cache-ARM64
124+
key: ${{ runner.os }}-on-ARM64-aarch64-linux-musl-buildx-${{ github.sha }}
125+
restore-keys: ${{ runner.os }}-on-ARM64-aarch64-linux-musl-buildx
126+
enableCrossOsArchive: true
127+
fail-on-cache-miss: true
128+
- run: mv tmp/build-cache-ARM64 tmp/build-cache-ARM64-aarch64-linux-musl
129+
130+
- name: Use X64 cache from primary pipeline of aarch64-mingw-ucrt
131+
uses: actions/cache/restore@v4
132+
with:
133+
path: tmp/build-cache-X64
134+
key: ${{ runner.os }}-on-X64-aarch64-mingw-ucrt-buildx-${{ github.sha }}
135+
restore-keys: ${{ runner.os }}-on-X64-aarch64-mingw-ucrt-buildx
136+
enableCrossOsArchive: true
137+
- run: mv tmp/build-cache-X64 tmp/build-cache-X64-aarch64-mingw-ucrt
138+
- name: Use ARM64 cache from primary pipeline of aarch64-mingw-ucrt
139+
uses: actions/cache/restore@v4
140+
with:
141+
path: tmp/build-cache-ARM64
142+
key: ${{ runner.os }}-on-ARM64-aarch64-mingw-ucrt-buildx-${{ github.sha }}
143+
restore-keys: ${{ runner.os }}-on-ARM64-aarch64-mingw-ucrt-buildx
144+
enableCrossOsArchive: true
145+
fail-on-cache-miss: true
146+
- run: mv tmp/build-cache-ARM64 tmp/build-cache-ARM64-aarch64-mingw-ucrt
147+
148+
- name: Use X64 cache from primary pipeline of arm-linux-gnu
149+
uses: actions/cache/restore@v4
150+
with:
151+
path: tmp/build-cache-X64
152+
key: ${{ runner.os }}-on-X64-arm-linux-gnu-buildx-${{ github.sha }}
153+
restore-keys: ${{ runner.os }}-on-X64-arm-linux-gnu-buildx
154+
enableCrossOsArchive: true
155+
- run: mv tmp/build-cache-X64 tmp/build-cache-X64-arm-linux-gnu
156+
- name: Use ARM64 cache from primary pipeline of arm-linux-gnu
157+
uses: actions/cache/restore@v4
158+
with:
159+
path: tmp/build-cache-ARM64
160+
key: ${{ runner.os }}-on-ARM64-arm-linux-gnu-buildx-${{ github.sha }}
161+
restore-keys: ${{ runner.os }}-on-ARM64-arm-linux-gnu-buildx
162+
enableCrossOsArchive: true
163+
fail-on-cache-miss: true
164+
- run: mv tmp/build-cache-ARM64 tmp/build-cache-ARM64-arm-linux-gnu
165+
166+
- name: Use X64 cache from primary pipeline of arm-linux-musl
167+
uses: actions/cache/restore@v4
168+
with:
169+
path: tmp/build-cache-X64
170+
key: ${{ runner.os }}-on-X64-arm-linux-musl-buildx-${{ github.sha }}
171+
restore-keys: ${{ runner.os }}-on-X64-arm-linux-musl-buildx
172+
enableCrossOsArchive: true
173+
- run: mv tmp/build-cache-X64 tmp/build-cache-X64-arm-linux-musl
174+
- name: Use ARM64 cache from primary pipeline of arm-linux-musl
175+
uses: actions/cache/restore@v4
176+
with:
177+
path: tmp/build-cache-ARM64
178+
key: ${{ runner.os }}-on-ARM64-arm-linux-musl-buildx-${{ github.sha }}
179+
restore-keys: ${{ runner.os }}-on-ARM64-arm-linux-musl-buildx
180+
enableCrossOsArchive: true
181+
fail-on-cache-miss: true
182+
- run: mv tmp/build-cache-ARM64 tmp/build-cache-ARM64-arm-linux-musl
183+
184+
- name: Use X64 cache from primary pipeline of arm64-darwin
185+
uses: actions/cache/restore@v4
186+
with:
187+
path: tmp/build-cache-X64
188+
key: ${{ runner.os }}-on-X64-arm64-darwin-buildx-${{ github.sha }}
189+
restore-keys: ${{ runner.os }}-on-X64-arm64-darwin-buildx
190+
enableCrossOsArchive: true
191+
- run: mv tmp/build-cache-X64 tmp/build-cache-X64-arm64-darwin
192+
- name: Use ARM64 cache from primary pipeline of arm64-darwin
193+
uses: actions/cache/restore@v4
194+
with:
195+
path: tmp/build-cache-ARM64
196+
key: ${{ runner.os }}-on-ARM64-arm64-darwin-buildx-${{ github.sha }}
197+
restore-keys: ${{ runner.os }}-on-ARM64-arm64-darwin-buildx
198+
enableCrossOsArchive: true
199+
fail-on-cache-miss: true
200+
- run: mv tmp/build-cache-ARM64 tmp/build-cache-ARM64-arm64-darwin
201+
202+
- name: Use X64 cache from primary pipeline of jruby
203+
uses: actions/cache/restore@v4
204+
with:
205+
path: tmp/build-cache-X64
206+
key: ${{ runner.os }}-on-X64-jruby-buildx-${{ github.sha }}
207+
restore-keys: ${{ runner.os }}-on-X64-jruby-buildx
208+
enableCrossOsArchive: true
209+
- run: mv tmp/build-cache-X64 tmp/build-cache-X64-jruby
210+
- name: Use ARM64 cache from primary pipeline of jruby
211+
uses: actions/cache/restore@v4
212+
with:
213+
path: tmp/build-cache-ARM64
214+
key: ${{ runner.os }}-on-ARM64-jruby-buildx-${{ github.sha }}
215+
restore-keys: ${{ runner.os }}-on-ARM64-jruby-buildx
216+
enableCrossOsArchive: true
217+
fail-on-cache-miss: true
218+
- run: mv tmp/build-cache-ARM64 tmp/build-cache-ARM64-jruby
219+
220+
- name: Use X64 cache from primary pipeline of x64-mingw-ucrt
221+
uses: actions/cache/restore@v4
222+
with:
223+
path: tmp/build-cache-X64
224+
key: ${{ runner.os }}-on-X64-x64-mingw-ucrt-buildx-${{ github.sha }}
225+
restore-keys: ${{ runner.os }}-on-X64-x64-mingw-ucrt-buildx
226+
enableCrossOsArchive: true
227+
- run: mv tmp/build-cache-X64 tmp/build-cache-X64-x64-mingw-ucrt
228+
- name: Use ARM64 cache from primary pipeline of x64-mingw-ucrt
229+
uses: actions/cache/restore@v4
230+
with:
231+
path: tmp/build-cache-ARM64
232+
key: ${{ runner.os }}-on-ARM64-x64-mingw-ucrt-buildx-${{ github.sha }}
233+
restore-keys: ${{ runner.os }}-on-ARM64-x64-mingw-ucrt-buildx
234+
enableCrossOsArchive: true
235+
fail-on-cache-miss: true
236+
- run: mv tmp/build-cache-ARM64 tmp/build-cache-ARM64-x64-mingw-ucrt
237+
238+
- name: Use X64 cache from primary pipeline of x64-mingw32
239+
uses: actions/cache/restore@v4
240+
with:
241+
path: tmp/build-cache-X64
242+
key: ${{ runner.os }}-on-X64-x64-mingw32-buildx-${{ github.sha }}
243+
restore-keys: ${{ runner.os }}-on-X64-x64-mingw32-buildx
244+
enableCrossOsArchive: true
245+
- run: mv tmp/build-cache-X64 tmp/build-cache-X64-x64-mingw32
246+
- name: Use ARM64 cache from primary pipeline of x64-mingw32
247+
uses: actions/cache/restore@v4
248+
with:
249+
path: tmp/build-cache-ARM64
250+
key: ${{ runner.os }}-on-ARM64-x64-mingw32-buildx-${{ github.sha }}
251+
restore-keys: ${{ runner.os }}-on-ARM64-x64-mingw32-buildx
252+
enableCrossOsArchive: true
253+
fail-on-cache-miss: true
254+
- run: mv tmp/build-cache-ARM64 tmp/build-cache-ARM64-x64-mingw32
255+
256+
- name: Use X64 cache from primary pipeline of x86-linux-gnu
257+
uses: actions/cache/restore@v4
258+
with:
259+
path: tmp/build-cache-X64
260+
key: ${{ runner.os }}-on-X64-x86-linux-gnu-buildx-${{ github.sha }}
261+
restore-keys: ${{ runner.os }}-on-X64-x86-linux-gnu-buildx
262+
enableCrossOsArchive: true
263+
- run: mv tmp/build-cache-X64 tmp/build-cache-X64-x86-linux-gnu
264+
- name: Use ARM64 cache from primary pipeline of x86-linux-gnu
265+
uses: actions/cache/restore@v4
266+
with:
267+
path: tmp/build-cache-ARM64
268+
key: ${{ runner.os }}-on-ARM64-x86-linux-gnu-buildx-${{ github.sha }}
269+
restore-keys: ${{ runner.os }}-on-ARM64-x86-linux-gnu-buildx
270+
enableCrossOsArchive: true
271+
fail-on-cache-miss: true
272+
- run: mv tmp/build-cache-ARM64 tmp/build-cache-ARM64-x86-linux-gnu
273+
274+
- name: Use X64 cache from primary pipeline of x86-linux-musl
275+
uses: actions/cache/restore@v4
276+
with:
277+
path: tmp/build-cache-X64
278+
key: ${{ runner.os }}-on-X64-x86-linux-musl-buildx-${{ github.sha }}
279+
restore-keys: ${{ runner.os }}-on-X64-x86-linux-musl-buildx
280+
enableCrossOsArchive: true
281+
- run: mv tmp/build-cache-X64 tmp/build-cache-X64-x86-linux-musl
282+
- name: Use ARM64 cache from primary pipeline of x86-linux-musl
283+
uses: actions/cache/restore@v4
284+
with:
285+
path: tmp/build-cache-ARM64
286+
key: ${{ runner.os }}-on-ARM64-x86-linux-musl-buildx-${{ github.sha }}
287+
restore-keys: ${{ runner.os }}-on-ARM64-x86-linux-musl-buildx
288+
enableCrossOsArchive: true
289+
fail-on-cache-miss: true
290+
- run: mv tmp/build-cache-ARM64 tmp/build-cache-ARM64-x86-linux-musl
291+
292+
- name: Use X64 cache from primary pipeline of x86-mingw32
87293
uses: actions/cache/restore@v4
88294
with:
89295
path: tmp/build-cache-X64
90-
key: ${{ runner.os }}-on-X64-${{ matrix.platform }}-buildx-${{ github.sha }}
91-
restore-keys: ${{ runner.os }}-on-X64-${{ matrix.platform }}-buildx
296+
key: ${{ runner.os }}-on-X64-x86-mingw32-buildx-${{ github.sha }}
297+
restore-keys: ${{ runner.os }}-on-X64-x86-mingw32-buildx
92298
enableCrossOsArchive: true
93-
- name: Use ARM64 cache from primary pipeline
299+
- run: mv tmp/build-cache-X64 tmp/build-cache-X64-x86-mingw32
300+
- name: Use ARM64 cache from primary pipeline of x86-mingw32
94301
uses: actions/cache/restore@v4
95302
with:
96303
path: tmp/build-cache-ARM64
97-
key: ${{ runner.os }}-on-ARM64-${{ matrix.platform }}-buildx-${{ github.sha }}
98-
restore-keys: ${{ runner.os }}-on-ARM64-${{ matrix.platform }}-buildx
304+
key: ${{ runner.os }}-on-ARM64-x86-mingw32-buildx-${{ github.sha }}
305+
restore-keys: ${{ runner.os }}-on-ARM64-x86-mingw32-buildx
99306
enableCrossOsArchive: true
100307
fail-on-cache-miss: true
308+
- run: mv tmp/build-cache-ARM64 tmp/build-cache-ARM64-x86-mingw32
309+
310+
- name: Use X64 cache from primary pipeline of x86_64-darwin
311+
uses: actions/cache/restore@v4
312+
with:
313+
path: tmp/build-cache-X64
314+
key: ${{ runner.os }}-on-X64-x86_64-darwin-buildx-${{ github.sha }}
315+
restore-keys: ${{ runner.os }}-on-X64-x86_64-darwin-buildx
316+
enableCrossOsArchive: true
317+
- run: mv tmp/build-cache-X64 tmp/build-cache-X64-x86_64-darwin
318+
- name: Use ARM64 cache from primary pipeline of x86_64-darwin
319+
uses: actions/cache/restore@v4
320+
with:
321+
path: tmp/build-cache-ARM64
322+
key: ${{ runner.os }}-on-ARM64-x86_64-darwin-buildx-${{ github.sha }}
323+
restore-keys: ${{ runner.os }}-on-ARM64-x86_64-darwin-buildx
324+
enableCrossOsArchive: true
325+
fail-on-cache-miss: true
326+
- run: mv tmp/build-cache-ARM64 tmp/build-cache-ARM64-x86_64-darwin
327+
328+
- name: Use X64 cache from primary pipeline of x86_64-linux-gnu
329+
uses: actions/cache/restore@v4
330+
with:
331+
path: tmp/build-cache-X64
332+
key: ${{ runner.os }}-on-X64-x86_64-linux-gnu-buildx-${{ github.sha }}
333+
restore-keys: ${{ runner.os }}-on-X64-x86_64-linux-gnu-buildx
334+
enableCrossOsArchive: true
335+
- run: mv tmp/build-cache-X64 tmp/build-cache-X64-x86_64-linux-gnu
336+
- name: Use ARM64 cache from primary pipeline of x86_64-linux-gnu
337+
uses: actions/cache/restore@v4
338+
with:
339+
path: tmp/build-cache-ARM64
340+
key: ${{ runner.os }}-on-ARM64-x86_64-linux-gnu-buildx-${{ github.sha }}
341+
restore-keys: ${{ runner.os }}-on-ARM64-x86_64-linux-gnu-buildx
342+
enableCrossOsArchive: true
343+
fail-on-cache-miss: true
344+
- run: mv tmp/build-cache-ARM64 tmp/build-cache-ARM64-x86_64-linux-gnu
345+
346+
- name: Use X64 cache from primary pipeline of x86_64-linux-musl
347+
uses: actions/cache/restore@v4
348+
with:
349+
path: tmp/build-cache-X64
350+
key: ${{ runner.os }}-on-X64-x86_64-linux-musl-buildx-${{ github.sha }}
351+
restore-keys: ${{ runner.os }}-on-X64-x86_64-linux-musl-buildx
352+
enableCrossOsArchive: true
353+
- run: mv tmp/build-cache-X64 tmp/build-cache-X64-x86_64-linux-musl
354+
- name: Use ARM64 cache from primary pipeline of x86_64-linux-musl
355+
uses: actions/cache/restore@v4
356+
with:
357+
path: tmp/build-cache-ARM64
358+
key: ${{ runner.os }}-on-ARM64-x86_64-linux-musl-buildx-${{ github.sha }}
359+
restore-keys: ${{ runner.os }}-on-ARM64-x86_64-linux-musl-buildx
360+
enableCrossOsArchive: true
361+
fail-on-cache-miss: true
362+
- run: mv tmp/build-cache-ARM64 tmp/build-cache-ARM64-x86_64-linux-musl
363+
101364
- uses: ruby/setup-ruby@v1
102365
with:
103366
ruby-version: "3.3"
@@ -110,7 +373,7 @@ jobs:
110373
- name: Use cache and push docker image
111374
env:
112375
RCD_IMAGE_VERSION: snapshot
113-
RCD_DOCKER_BUILD: docker buildx build --cache-from=type=local,src=tmp/build-cache-X64 --cache-from=type=local,src=tmp/build-cache-ARM64 --cache-to=type=local,dest=tmp/build-cache-new
376+
RCD_DOCKER_BUILD: docker buildx build --cache-from=type=local,src=tmp/build-cache-X64-aarch64-linux-gnu --cache-from=type=local,src=tmp/build-cache-ARM64-aarch64-linux-gnu --cache-from=type=local,src=tmp/build-cache-X64-aarch64-linux-musl --cache-from=type=local,src=tmp/build-cache-ARM64-aarch64-linux-musl --cache-from=type=local,src=tmp/build-cache-X64-aarch64-mingw-ucrt --cache-from=type=local,src=tmp/build-cache-ARM64-aarch64-mingw-ucrt --cache-from=type=local,src=tmp/build-cache-X64-arm-linux-gnu --cache-from=type=local,src=tmp/build-cache-ARM64-arm-linux-gnu --cache-from=type=local,src=tmp/build-cache-X64-arm-linux-musl --cache-from=type=local,src=tmp/build-cache-ARM64-arm-linux-musl --cache-from=type=local,src=tmp/build-cache-X64-arm64-darwin --cache-from=type=local,src=tmp/build-cache-ARM64-arm64-darwin --cache-from=type=local,src=tmp/build-cache-X64-jruby --cache-from=type=local,src=tmp/build-cache-ARM64-jruby --cache-from=type=local,src=tmp/build-cache-X64-x64-mingw-ucrt --cache-from=type=local,src=tmp/build-cache-ARM64-x64-mingw-ucrt --cache-from=type=local,src=tmp/build-cache-X64-x64-mingw32 --cache-from=type=local,src=tmp/build-cache-ARM64-x64-mingw32 --cache-from=type=local,src=tmp/build-cache-X64-x86-linux-gnu --cache-from=type=local,src=tmp/build-cache-ARM64-x86-linux-gnu --cache-from=type=local,src=tmp/build-cache-X64-x86-linux-musl --cache-from=type=local,src=tmp/build-cache-ARM64-x86-linux-musl --cache-from=type=local,src=tmp/build-cache-X64-x86-mingw32 --cache-from=type=local,src=tmp/build-cache-ARM64-x86-mingw32 --cache-from=type=local,src=tmp/build-cache-X64-x86_64-darwin --cache-from=type=local,src=tmp/build-cache-ARM64-x86_64-darwin --cache-from=type=local,src=tmp/build-cache-X64-x86_64-linux-gnu --cache-from=type=local,src=tmp/build-cache-ARM64-x86_64-linux-gnu --cache-from=type=local,src=tmp/build-cache-X64-x86_64-linux-musl --cache-from=type=local,src=tmp/build-cache-ARM64-x86_64-linux-musl --cache-to=type=local,dest=tmp/build-cache-new
114377
run: |
115378
docker buildx create --driver docker-container --use
116-
bundle exec rake release:${{matrix.platform}}
379+
bundle exec rake release

0 commit comments

Comments
 (0)