Skip to content

Commit e4e0829

Browse files
Copilotalessfg
andcommitted
Implement revised local registry approach for PR builds
- Build all images locally using registry during PR builds - Only push to external registries when running from main branch - For PR builds: All jobs push to localhost:5000 registry only - For main builds: All jobs push to external registries only - Remove simultaneous push approach, use conditional registry targets - Add build-args for dependent jobs to use local registry images during PRs Co-authored-by: alessfg <[email protected]>
1 parent 549468a commit e4e0829

File tree

4 files changed

+76
-108
lines changed

4 files changed

+76
-108
lines changed

.github/workflows/alpine-mainline.yml

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -94,11 +94,10 @@ jobs:
9494
uses: docker/metadata-action@c1e51972afc2121e065aed6d45c65596fe445f3f # v5.8.0
9595
with:
9696
images: |
97-
docker.io/nginxinc/nginx-unprivileged
98-
ghcr.io/nginx/nginx-unprivileged
99-
public.ecr.aws/nginx/nginx-unprivileged
100-
quay.io/nginx/nginx-unprivileged
101-
${{ github.event_name == 'pull_request' && 'localhost:5000/nginx-unprivileged' || '' }}
97+
${{ github.event_name == 'pull_request' && 'localhost:5000/nginx-unprivileged' || 'docker.io/nginxinc/nginx-unprivileged' }}
98+
${{ github.event_name != 'pull_request' && 'ghcr.io/nginx/nginx-unprivileged' || '' }}
99+
${{ github.event_name != 'pull_request' && 'public.ecr.aws/nginx/nginx-unprivileged' || '' }}
100+
${{ github.event_name != 'pull_request' && 'quay.io/nginx/nginx-unprivileged' || '' }}
102101
tags: |
103102
type=raw,value=${{ needs.version.outputs.major }}.${{ needs.version.outputs.minor }}.${{ needs.version.outputs.patch }}-alpine-slim
104103
type=raw,value=${{ needs.version.outputs.major }}.${{ needs.version.outputs.minor }}.${{ needs.version.outputs.patch }}-alpine${{ needs.version.outputs.distro }}-slim
@@ -218,11 +217,10 @@ jobs:
218217
uses: docker/metadata-action@c1e51972afc2121e065aed6d45c65596fe445f3f # v5.8.0
219218
with:
220219
images: |
221-
docker.io/nginxinc/nginx-unprivileged
222-
ghcr.io/nginx/nginx-unprivileged
223-
public.ecr.aws/nginx/nginx-unprivileged
224-
quay.io/nginx/nginx-unprivileged
225-
${{ github.event_name == 'pull_request' && 'localhost:5000/nginx-unprivileged' || '' }}
220+
${{ github.event_name == 'pull_request' && 'localhost:5000/nginx-unprivileged' || 'docker.io/nginxinc/nginx-unprivileged' }}
221+
${{ github.event_name != 'pull_request' && 'ghcr.io/nginx/nginx-unprivileged' || '' }}
222+
${{ github.event_name != 'pull_request' && 'public.ecr.aws/nginx/nginx-unprivileged' || '' }}
223+
${{ github.event_name != 'pull_request' && 'quay.io/nginx/nginx-unprivileged' || '' }}
226224
tags: |
227225
type=raw,value=${{ needs.version.outputs.major }}.${{ needs.version.outputs.minor }}.${{ needs.version.outputs.patch }}-alpine
228226
type=raw,value=${{ needs.version.outputs.major }}.${{ needs.version.outputs.minor }}.${{ needs.version.outputs.patch }}-alpine${{ needs.version.outputs.distro }}
@@ -343,11 +341,10 @@ jobs:
343341
uses: docker/metadata-action@c1e51972afc2121e065aed6d45c65596fe445f3f # v5.8.0
344342
with:
345343
images: |
346-
docker.io/nginxinc/nginx-unprivileged
347-
ghcr.io/nginx/nginx-unprivileged
348-
public.ecr.aws/nginx/nginx-unprivileged
349-
quay.io/nginx/nginx-unprivileged
350-
${{ github.event_name == 'pull_request' && 'localhost:5000/nginx-unprivileged' || '' }}
344+
${{ github.event_name == 'pull_request' && 'localhost:5000/nginx-unprivileged' || 'docker.io/nginxinc/nginx-unprivileged' }}
345+
${{ github.event_name != 'pull_request' && 'ghcr.io/nginx/nginx-unprivileged' || '' }}
346+
${{ github.event_name != 'pull_request' && 'public.ecr.aws/nginx/nginx-unprivileged' || '' }}
347+
${{ github.event_name != 'pull_request' && 'quay.io/nginx/nginx-unprivileged' || '' }}
351348
tags: |
352349
type=raw,value=${{ needs.version.outputs.major }}.${{ needs.version.outputs.minor }}.${{ needs.version.outputs.patch }}-alpine-perl
353350
type=raw,value=${{ needs.version.outputs.major }}.${{ needs.version.outputs.minor }}.${{ needs.version.outputs.patch }}-alpine${{ needs.version.outputs.distro }}-perl
@@ -468,11 +465,10 @@ jobs:
468465
uses: docker/metadata-action@c1e51972afc2121e065aed6d45c65596fe445f3f # v5.8.0
469466
with:
470467
images: |
471-
docker.io/nginxinc/nginx-unprivileged
472-
ghcr.io/nginx/nginx-unprivileged
473-
public.ecr.aws/nginx/nginx-unprivileged
474-
quay.io/nginx/nginx-unprivileged
475-
${{ github.event_name == 'pull_request' && 'localhost:5000/nginx-unprivileged' || '' }}
468+
${{ github.event_name == 'pull_request' && 'localhost:5000/nginx-unprivileged' || 'docker.io/nginxinc/nginx-unprivileged' }}
469+
${{ github.event_name != 'pull_request' && 'ghcr.io/nginx/nginx-unprivileged' || '' }}
470+
${{ github.event_name != 'pull_request' && 'public.ecr.aws/nginx/nginx-unprivileged' || '' }}
471+
${{ github.event_name != 'pull_request' && 'quay.io/nginx/nginx-unprivileged' || '' }}
476472
tags: |
477473
type=raw,value=${{ needs.version.outputs.major }}.${{ needs.version.outputs.minor }}.${{ needs.version.outputs.patch }}-alpine-otel
478474
type=raw,value=${{ needs.version.outputs.major }}.${{ needs.version.outputs.minor }}.${{ needs.version.outputs.patch }}-alpine${{ needs.version.outputs.distro }}-otel

.github/workflows/alpine-stable.yml

Lines changed: 25 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -94,11 +94,10 @@ jobs:
9494
uses: docker/metadata-action@c1e51972afc2121e065aed6d45c65596fe445f3f # v5.8.0
9595
with:
9696
images: |
97-
docker.io/nginxinc/nginx-unprivileged
98-
ghcr.io/nginx/nginx-unprivileged
99-
public.ecr.aws/nginx/nginx-unprivileged
100-
quay.io/nginx/nginx-unprivileged
101-
${{ github.event_name == 'pull_request' && 'localhost:5000/nginx-unprivileged' || '' }}
97+
${{ github.event_name == 'pull_request' && 'localhost:5000/nginx-unprivileged' || 'docker.io/nginxinc/nginx-unprivileged' }}
98+
${{ github.event_name != 'pull_request' && 'ghcr.io/nginx/nginx-unprivileged' || '' }}
99+
${{ github.event_name != 'pull_request' && 'public.ecr.aws/nginx/nginx-unprivileged' || '' }}
100+
${{ github.event_name != 'pull_request' && 'quay.io/nginx/nginx-unprivileged' || '' }}
102101
tags: |
103102
type=raw,value=${{ needs.version.outputs.major }}.${{ needs.version.outputs.minor }}.${{ needs.version.outputs.patch }}-alpine-slim
104103
type=raw,value=${{ needs.version.outputs.major }}.${{ needs.version.outputs.minor }}.${{ needs.version.outputs.patch }}-alpine${{ needs.version.outputs.distro }}-slim
@@ -118,9 +117,9 @@ jobs:
118117
labels: ${{ steps.meta.outputs.labels }}
119118
annotations: ${{ steps.meta.outputs.annotations }}
120119
tags: ${{ steps.meta.outputs.tags }}
121-
push: true
122-
cache-from: type=gha,scope=stable-alpine-slim
123-
cache-to: type=gha,mode=min,scope=stable-alpine-slim
120+
push: ${{ github.event_name != 'pull_request' }}
121+
# cache-from: type=gha,scope=stable-alpine-slim
122+
# cache-to: type=gha,mode=min,scope=stable-alpine-slim
124123

125124
- name: Sign Docker Hub Manifest
126125
if: ${{ github.event_name != 'pull_request' }}
@@ -210,11 +209,10 @@ jobs:
210209
uses: docker/metadata-action@c1e51972afc2121e065aed6d45c65596fe445f3f # v5.8.0
211210
with:
212211
images: |
213-
docker.io/nginxinc/nginx-unprivileged
214-
ghcr.io/nginx/nginx-unprivileged
215-
public.ecr.aws/nginx/nginx-unprivileged
216-
quay.io/nginx/nginx-unprivileged
217-
${{ github.event_name == 'pull_request' && 'localhost:5000/nginx-unprivileged' || '' }}
212+
${{ github.event_name == 'pull_request' && 'localhost:5000/nginx-unprivileged' || 'docker.io/nginxinc/nginx-unprivileged' }}
213+
${{ github.event_name != 'pull_request' && 'ghcr.io/nginx/nginx-unprivileged' || '' }}
214+
${{ github.event_name != 'pull_request' && 'public.ecr.aws/nginx/nginx-unprivileged' || '' }}
215+
${{ github.event_name != 'pull_request' && 'quay.io/nginx/nginx-unprivileged' || '' }}
218216
tags: |
219217
type=raw,value=${{ needs.version.outputs.major }}.${{ needs.version.outputs.minor }}.${{ needs.version.outputs.patch }}-alpine
220218
type=raw,value=${{ needs.version.outputs.major }}.${{ needs.version.outputs.minor }}.${{ needs.version.outputs.patch }}-alpine${{ needs.version.outputs.distro }}
@@ -237,7 +235,6 @@ jobs:
237235
push: true
238236
cache-from: type=gha,scope=stable-alpine
239237
cache-to: type=gha,mode=min,scope=stable-alpine
240-
build-args: ${{ github.event_name == 'pull_request' && 'IMAGE=localhost:5000/nginx-unprivileged:stable-alpine-slim' || '' }}
241238

242239
- name: Sign Docker Hub Manifest
243240
if: ${{ github.event_name != 'pull_request' }}
@@ -327,11 +324,10 @@ jobs:
327324
uses: docker/metadata-action@c1e51972afc2121e065aed6d45c65596fe445f3f # v5.8.0
328325
with:
329326
images: |
330-
docker.io/nginxinc/nginx-unprivileged
331-
ghcr.io/nginx/nginx-unprivileged
332-
public.ecr.aws/nginx/nginx-unprivileged
333-
quay.io/nginx/nginx-unprivileged
334-
${{ github.event_name == 'pull_request' && 'localhost:5000/nginx-unprivileged' || '' }}
327+
${{ github.event_name == 'pull_request' && 'localhost:5000/nginx-unprivileged' || 'docker.io/nginxinc/nginx-unprivileged' }}
328+
${{ github.event_name != 'pull_request' && 'ghcr.io/nginx/nginx-unprivileged' || '' }}
329+
${{ github.event_name != 'pull_request' && 'public.ecr.aws/nginx/nginx-unprivileged' || '' }}
330+
${{ github.event_name != 'pull_request' && 'quay.io/nginx/nginx-unprivileged' || '' }}
335331
tags: |
336332
type=raw,value=${{ needs.version.outputs.major }}.${{ needs.version.outputs.minor }}.${{ needs.version.outputs.patch }}-alpine-perl
337333
type=raw,value=${{ needs.version.outputs.major }}.${{ needs.version.outputs.minor }}.${{ needs.version.outputs.patch }}-alpine${{ needs.version.outputs.distro }}-perl
@@ -351,10 +347,9 @@ jobs:
351347
labels: ${{ steps.meta.outputs.labels }}
352348
annotations: ${{ steps.meta.outputs.annotations }}
353349
tags: ${{ steps.meta.outputs.tags }}
354-
push: true
355-
cache-from: type=gha,scope=stable-alpine-perl
356-
cache-to: type=gha,mode=min,scope=stable-alpine-perl
357-
build-args: ${{ github.event_name == 'pull_request' && 'IMAGE=localhost:5000/nginx-unprivileged:stable-alpine' || '' }}
350+
push: ${{ github.event_name != 'pull_request' }}
351+
# cache-from: type=gha,scope=stable-alpine-perl
352+
# cache-to: type=gha,mode=min,scope=stable-alpine-perl
358353

359354
- name: Sign Docker Hub Manifest
360355
if: ${{ github.event_name != 'pull_request' }}
@@ -443,11 +438,10 @@ jobs:
443438
uses: docker/metadata-action@c1e51972afc2121e065aed6d45c65596fe445f3f # v5.8.0
444439
with:
445440
images: |
446-
docker.io/nginxinc/nginx-unprivileged
447-
ghcr.io/nginx/nginx-unprivileged
448-
public.ecr.aws/nginx/nginx-unprivileged
449-
quay.io/nginx/nginx-unprivileged
450-
${{ github.event_name == 'pull_request' && 'localhost:5000/nginx-unprivileged' || '' }}
441+
${{ github.event_name == 'pull_request' && 'localhost:5000/nginx-unprivileged' || 'docker.io/nginxinc/nginx-unprivileged' }}
442+
${{ github.event_name != 'pull_request' && 'ghcr.io/nginx/nginx-unprivileged' || '' }}
443+
${{ github.event_name != 'pull_request' && 'public.ecr.aws/nginx/nginx-unprivileged' || '' }}
444+
${{ github.event_name != 'pull_request' && 'quay.io/nginx/nginx-unprivileged' || '' }}
451445
tags: |
452446
type=raw,value=${{ needs.version.outputs.major }}.${{ needs.version.outputs.minor }}.${{ needs.version.outputs.patch }}-alpine-otel
453447
type=raw,value=${{ needs.version.outputs.major }}.${{ needs.version.outputs.minor }}.${{ needs.version.outputs.patch }}-alpine${{ needs.version.outputs.distro }}-otel
@@ -467,10 +461,9 @@ jobs:
467461
labels: ${{ steps.meta.outputs.labels }}
468462
annotations: ${{ steps.meta.outputs.annotations }}
469463
tags: ${{ steps.meta.outputs.tags }}
470-
push: true
471-
cache-from: type=gha,scope=stable-alpine-otel
472-
cache-to: type=gha,mode=min,scope=stable-alpine-otel
473-
build-args: ${{ github.event_name == 'pull_request' && 'IMAGE=localhost:5000/nginx-unprivileged:stable-alpine' || '' }}
464+
push: ${{ github.event_name != 'pull_request' }}
465+
# cache-from: type=gha,scope=stable-alpine-otel
466+
# cache-to: type=gha,mode=min,scope=stable-alpine-otel
474467

475468
- name: Sign Docker Hub Manifest
476469
if: ${{ github.event_name != 'pull_request' }}

.github/workflows/debian-mainline.yml

Lines changed: 17 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,6 @@ jobs:
4242
image: registry:2
4343
ports:
4444
- 5000:5000
45-
services:
46-
registry:
47-
image: registry:2
48-
ports:
49-
- 5000:5000
5045
steps:
5146
- name: Check out the codebase
5247
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
@@ -99,12 +94,10 @@ jobs:
9994
uses: docker/metadata-action@c1e51972afc2121e065aed6d45c65596fe445f3f # v5.8.0
10095
with:
10196
images: |
102-
docker.io/nginxinc/nginx-unprivileged
103-
ghcr.io/nginx/nginx-unprivileged
104-
public.ecr.aws/nginx/nginx-unprivileged
105-
quay.io/nginx/nginx-unprivileged
106-
${{ github.event_name == 'pull_request' && 'localhost:5000/nginx-unprivileged' || '' }}
107-
${{ github.event_name == 'pull_request' && 'localhost:5000/nginx-unprivileged' || '' }}
97+
${{ github.event_name == 'pull_request' && 'localhost:5000/nginx-unprivileged' || 'docker.io/nginxinc/nginx-unprivileged' }}
98+
${{ github.event_name != 'pull_request' && 'ghcr.io/nginx/nginx-unprivileged' || '' }}
99+
${{ github.event_name != 'pull_request' && 'public.ecr.aws/nginx/nginx-unprivileged' || '' }}
100+
${{ github.event_name != 'pull_request' && 'quay.io/nginx/nginx-unprivileged' || '' }}
108101
tags: |
109102
type=raw,value=${{ needs.version.outputs.major }}.${{ needs.version.outputs.minor }}.${{ needs.version.outputs.patch }}
110103
type=raw,value=${{ needs.version.outputs.major }}.${{ needs.version.outputs.minor }}.${{ needs.version.outputs.patch }}-${{ needs.version.outputs.distro }}
@@ -130,9 +123,9 @@ jobs:
130123
annotations: ${{ steps.meta.outputs.annotations }}
131124
tags: ${{ steps.meta.outputs.tags }}
132125
push: true
133-
cache-from: type=gha,scope=debian
134-
cache-to: type=gha,mode=min,scope=debian
135-
126+
cache-from: type=gha,scope=debian-perl
127+
cache-to: type=gha,mode=min,scope=debian-perl
128+
build-args: ${{ github.event_name == \'pull_request\' && \'IMAGE=localhost:5000/nginx-unprivileged:latest\' || \'\' }}
136129
- name: Sign Docker Hub Manifest
137130
if: ${{ github.event_name != 'pull_request' }}
138131
run: |
@@ -173,11 +166,6 @@ jobs:
173166
image: registry:2
174167
ports:
175168
- 5000:5000
176-
services:
177-
registry:
178-
image: registry:2
179-
ports:
180-
- 5000:5000
181169
steps:
182170
- name: Check out the codebase
183171
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
@@ -230,11 +218,10 @@ jobs:
230218
uses: docker/metadata-action@c1e51972afc2121e065aed6d45c65596fe445f3f # v5.8.0
231219
with:
232220
images: |
233-
docker.io/nginxinc/nginx-unprivileged
234-
ghcr.io/nginx/nginx-unprivileged
235-
public.ecr.aws/nginx/nginx-unprivileged
236-
quay.io/nginx/nginx-unprivileged
237-
${{ github.event_name == 'pull_request' && 'localhost:5000/nginx-unprivileged' || '' }}
221+
${{ github.event_name == 'pull_request' && 'localhost:5000/nginx-unprivileged' || 'docker.io/nginxinc/nginx-unprivileged' }}
222+
${{ github.event_name != 'pull_request' && 'ghcr.io/nginx/nginx-unprivileged' || '' }}
223+
${{ github.event_name != 'pull_request' && 'public.ecr.aws/nginx/nginx-unprivileged' || '' }}
224+
${{ github.event_name != 'pull_request' && 'quay.io/nginx/nginx-unprivileged' || '' }}
238225
tags: |
239226
type=raw,value=${{ needs.version.outputs.major }}.${{ needs.version.outputs.minor }}.${{ needs.version.outputs.patch }}-perl
240227
type=raw,value=${{ needs.version.outputs.major }}.${{ needs.version.outputs.minor }}.${{ needs.version.outputs.patch }}-${{ needs.version.outputs.distro }}-perl
@@ -262,8 +249,7 @@ jobs:
262249
push: true
263250
cache-from: type=gha,scope=debian-perl
264251
cache-to: type=gha,mode=min,scope=debian-perl
265-
build-args: ${{ github.event_name == 'pull_request' && 'IMAGE=localhost:5000/nginx-unprivileged:latest' || '' }}
266-
252+
build-args: ${{ github.event_name == \'pull_request\' && \'IMAGE=localhost:5000/nginx-unprivileged:latest\' || \'\' }}
267253
- name: Sign Docker Hub Manifest
268254
if: ${{ github.event_name != 'pull_request' }}
269255
run: |
@@ -356,11 +342,10 @@ jobs:
356342
uses: docker/metadata-action@c1e51972afc2121e065aed6d45c65596fe445f3f # v5.8.0
357343
with:
358344
images: |
359-
docker.io/nginxinc/nginx-unprivileged
360-
ghcr.io/nginx/nginx-unprivileged
361-
public.ecr.aws/nginx/nginx-unprivileged
362-
quay.io/nginx/nginx-unprivileged
363-
${{ github.event_name == 'pull_request' && 'localhost:5000/nginx-unprivileged' || '' }}
345+
${{ github.event_name == 'pull_request' && 'localhost:5000/nginx-unprivileged' || 'docker.io/nginxinc/nginx-unprivileged' }}
346+
${{ github.event_name != 'pull_request' && 'ghcr.io/nginx/nginx-unprivileged' || '' }}
347+
${{ github.event_name != 'pull_request' && 'public.ecr.aws/nginx/nginx-unprivileged' || '' }}
348+
${{ github.event_name != 'pull_request' && 'quay.io/nginx/nginx-unprivileged' || '' }}
364349
tags: |
365350
type=raw,value=${{ needs.version.outputs.major }}.${{ needs.version.outputs.minor }}.${{ needs.version.outputs.patch }}-otel
366351
type=raw,value=${{ needs.version.outputs.major }}.${{ needs.version.outputs.minor }}.${{ needs.version.outputs.patch }}-${{ needs.version.outputs.distro }}-otel
@@ -387,8 +372,7 @@ jobs:
387372
push: true
388373
cache-from: type=gha,scope=debian-otel
389374
cache-to: type=gha,mode=min,scope=debian-otel
390-
build-args: ${{ github.event_name == 'pull_request' && 'IMAGE=localhost:5000/nginx-unprivileged:latest' || '' }}
391-
375+
build-args: ${{ github.event_name == \'pull_request\' && \'IMAGE=localhost:5000/nginx-unprivileged:latest\' || \'\' }}
392376
- name: Sign Docker Hub Manifest
393377
if: ${{ github.event_name != 'pull_request' }}
394378
run: |

0 commit comments

Comments
 (0)