Skip to content

Commit ff72dc3

Browse files
committed
Use docker buildx to ensure images for multi platforms are saved
1 parent 90f1618 commit ff72dc3

File tree

3 files changed

+24
-13
lines changed

3 files changed

+24
-13
lines changed

.github/workflows/build.yml

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,6 @@ jobs:
155155
labels: ${{ steps.meta.outputs.labels }}
156156
annotations: ${{ steps.meta.outputs.annotations }}
157157
push: ${{ !inputs.dry_run }}
158-
load: true
159158
platforms: ${{ inputs.platforms }}
160159
cache-from: type=gha,scope=${{ inputs.image }}${{ inputs.build-os != '' && format('-{0}', inputs.build-os) || '' }}
161160
cache-to: type=gha,scope=${{ inputs.image }}${{ inputs.build-os != '' && format('-{0}', inputs.build-os) || '' }},mode=max
@@ -195,15 +194,22 @@ jobs:
195194
sarif_file: ${{ steps.scan.outputs.sarif }}
196195
category: build-${{ inputs.image }}
197196

198-
- name: Show all image tags for debugging
199-
run: echo "${{ steps.meta.outputs.tags }}"
200-
201-
- name: Save the image as tarball
197+
- name: Export and upload images for all platforms
202198
run: |
203-
docker save -o ${{ inputs.image }}.tar localhost:5000/nginx-gateway-fabric/${{ inputs.image }}:${{ steps.meta.outputs.version }}
204-
205-
- name: Upload the image artifact
199+
# Remove spaces and split platforms by comma
200+
platforms=$(echo "${{ inputs.platforms }}" | tr -d ' ' | tr ',' ' ')
201+
for platform in $platforms; do
202+
# Replace / with - for tarball name (e.g., linux/amd64 -> linux-amd64)
203+
plat_tag=$(echo "$platform" | tr '/' '-')
204+
# Create a local reference for the platform
205+
docker buildx imagetools create --tag tempimg-$plat_tag ghcr.io/${{ github.repository_owner }}/nginx-gateway-fabric/${{ inputs.image }}:${{ steps.meta.outputs.version }} --platform $platform
206+
# Export the image as a tarball
207+
docker buildx imagetools export tempimg-$plat_tag > ${{ inputs.image }}-$plat_tag.tar
208+
done
209+
210+
- name: Upload all image artifacts
206211
uses: actions/upload-artifact@v4
207212
with:
208-
name: ${{ inputs.image }}
209-
path: ${{ inputs.image }}.tar
213+
name: ${{ inputs.image }}-images
214+
path: ${{ inputs.image }}-*.tar
215+

.github/workflows/ci.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -416,11 +416,13 @@ jobs:
416416
fail-fast: false
417417
matrix:
418418
image: [ngf, nginx, operator]
419+
platform: ["linux/amd64", "linux/arm64"]
419420
# if: ${{ github.event_name == 'pull_request' && github.event_pull_request.base.ref == 'main' || (github.event_name == 'push' && github.ref == 'refs/heads/main') || (inputs.is_production_release == true) }}
420421
uses: ./.github/workflows/openshift-certification.yml
421422
with:
422423
runner: ubuntu-24.04
423424
image: ${{ matrix.image }}
425+
platform: ${{ matrix.platform }}
424426
permissions:
425427
contents: read
426428
packages: read

.github/workflows/openshift-certification.yml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ on:
1010
image:
1111
required: true
1212
type: string
13+
platform:
14+
required: true
15+
type: string
1316

1417
defaults:
1518
run:
@@ -34,14 +37,14 @@ jobs:
3437
- name: Download image artifact
3538
uses: actions/download-artifact@v4
3639
with:
37-
name: ${{ inputs.image }}
40+
name: ${{ inputs.image }}-images # or ${{ inputs.image }}-linux-${{ inputs.platform | tr '/' '-' }}
3841

3942
- name: Load image into Docker
40-
run: docker load -i ${{ inputs.image }}.tar
43+
run: docker load -i ${{ inputs.image }}-${{ inputs.platform | tr '/' '-' }}.tar
4144

4245
- name: Retag image for preflight
4346
run: |
44-
loaded_tag="localhost:5000/nginx-gateway-fabric/${{ inputs.image }}"
47+
loaded_tag="ghcr.io/${{ github.repository_owner }}/nginx-gateway-fabric/${{ inputs.image }}:${{ inputs.image_version }}"
4548
preflight_tag="${{ inputs.image }}:ubi"
4649
docker tag "$loaded_tag" "$preflight_tag"
4750

0 commit comments

Comments
 (0)