Skip to content

Commit 004e511

Browse files
Build multiarch images on native GitHub runners
This commit makes the following changes: 1. Builds multiarch images for non-release commits/PRs, in addition to released versions. 2. Runs the docker build for an arch on the respective GitHub runner (e.g. a linux/amd64 docker image will be built on a linux/amd64 runner). This native build reduces build times due to not requring emulation. Signed-off-by: Rajath Agasthya <[email protected]>
1 parent 48da989 commit 004e511

File tree

3 files changed

+63
-8
lines changed

3 files changed

+63
-8
lines changed

.github/workflows/ci.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ jobs:
3333
secrets: inherit
3434
with:
3535
version: ${{ needs.basic.outputs.version }}
36-
build_multi_arch_images: ${{ github.ref_name == 'main' || startsWith(github.ref_name, 'release-') }}
3736

3837
e2e-test:
3938
needs:

.github/workflows/image.yaml

Lines changed: 62 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,9 @@ on:
2020
version:
2121
required: true
2222
type: string
23-
build_multi_arch_images:
24-
required: true
25-
type: string
2623

2724
jobs:
28-
build:
25+
build-amd64:
2926
runs-on: linux-amd64-cpu4
3027
permissions:
3128
contents: read
@@ -52,10 +49,69 @@ jobs:
5249
- name: Build image
5350
env:
5451
IMAGE_NAME: ghcr.io/nvidia/k8s-device-plugin
55-
VERSION: ${{ inputs.version }}
52+
VERSION: ${{ inputs.version }}-amd64
5653
PUSH_ON_BUILD: true
57-
BUILD_MULTI_ARCH_IMAGES: ${{ inputs.build_multi_arch_images }}
5854
GOPROXY: ${{ steps.setup-go-proxy.outputs.goproxy-url }}
55+
DOCKER_BUILD_PLATFORM_OPTIONS: "--platform=linux/amd64"
5956
run: |
6057
echo "${VERSION}"
6158
make -f deployments/container/Makefile build
59+
60+
build-arm64:
61+
runs-on: linux-arm64-cpu4
62+
permissions:
63+
contents: read
64+
id-token: write
65+
packages: write
66+
steps:
67+
- uses: actions/checkout@v5
68+
name: Check out code
69+
- name: Set up QEMU
70+
uses: docker/setup-qemu-action@v3
71+
with:
72+
image: tonistiigi/binfmt:master
73+
- name: Set up Docker Buildx
74+
uses: docker/setup-buildx-action@v3
75+
- name: Login to GitHub Container Registry
76+
uses: docker/login-action@v3
77+
with:
78+
registry: ghcr.io
79+
username: ${{ github.actor }}
80+
password: ${{ secrets.GITHUB_TOKEN }}
81+
- name: Setup Go Proxy
82+
id: setup-go-proxy
83+
uses: nv-gha-runners/setup-artifactory-go-proxy@main
84+
- name: Build image
85+
env:
86+
IMAGE_NAME: ghcr.io/nvidia/k8s-device-plugin
87+
VERSION: ${{ inputs.version }}-arm64
88+
PUSH_ON_BUILD: true
89+
GOPROXY: ${{ steps.setup-go-proxy.outputs.goproxy-url }}
90+
DOCKER_BUILD_PLATFORM_OPTIONS: "--platform=linux/arm64"
91+
run: |
92+
echo "${VERSION}"
93+
make -f deployments/container/Makefile build
94+
95+
build-multi-arch-images:
96+
needs: [ build-arm64, build-amd64 ]
97+
runs-on: ubuntu-latest
98+
steps:
99+
- uses: actions/checkout@v5
100+
name: Check out code
101+
- name: Login to GitHub Container Registry
102+
uses: docker/login-action@v3
103+
with:
104+
registry: ghcr.io
105+
username: ${{ github.actor }}
106+
password: ${{ secrets.GITHUB_TOKEN }}
107+
- name: Build Manifest
108+
env:
109+
IMAGE_ARM: ghcr.io/nvidia/k8s-device-plugin:${{ inputs.version }}-arm64
110+
IMAGE_AMD: ghcr.io/nvidia/k8s-device-plugin:${{ inputs.version }}-amd64
111+
MULTIARCH_IMAGE: ghcr.io/nvidia/k8s-device-plugin:${{ inputs.version }}
112+
run: |
113+
docker manifest create \
114+
${MULTIARCH_IMAGE} \
115+
${IMAGE_AMD} \
116+
${IMAGE_ARM}
117+
docker manifest push ${MULTIARCH_IMAGE}

deployments/container/multi-arch.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@
1414

1515
PUSH_ON_BUILD ?= false
1616
DOCKER_BUILD_OPTIONS = --output=type=image,push=$(PUSH_ON_BUILD)
17-
DOCKER_BUILD_PLATFORM_OPTIONS = --platform=linux/amd64,linux/arm64
17+
DOCKER_BUILD_PLATFORM_OPTIONS ?= --platform=linux/amd64,linux/arm64
1818

1919
$(BUILD_TARGETS): build-%: image-%

0 commit comments

Comments
 (0)