Skip to content

Commit 313f9f0

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 requiring emulation. 3. Removes explicit use if buildx for docker build. Buildx is now the default builder in Docker. Also removes the related QEMU setup. Signed-off-by: Rajath Agasthya <[email protected]>
1 parent 48da989 commit 313f9f0

File tree

4 files changed

+32
-20
lines changed

4 files changed

+32
-20
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: 30 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,26 +20,22 @@ on:
2020
version:
2121
required: true
2222
type: string
23-
build_multi_arch_images:
24-
required: true
25-
type: string
2623

2724
jobs:
2825
build:
29-
runs-on: linux-amd64-cpu4
26+
strategy:
27+
matrix:
28+
arch:
29+
- amd64
30+
- arm64
31+
runs-on: linux-${{ matrix.arch }}-cpu4
3032
permissions:
3133
contents: read
3234
id-token: write
3335
packages: write
3436
steps:
3537
- uses: actions/checkout@v5
3638
name: Check out code
37-
- name: Set up QEMU
38-
uses: docker/setup-qemu-action@v3
39-
with:
40-
image: tonistiigi/binfmt:master
41-
- name: Set up Docker Buildx
42-
uses: docker/setup-buildx-action@v3
4339
- name: Login to GitHub Container Registry
4440
uses: docker/login-action@v3
4541
with:
@@ -52,10 +48,32 @@ jobs:
5248
- name: Build image
5349
env:
5450
IMAGE_NAME: ghcr.io/nvidia/k8s-device-plugin
55-
VERSION: ${{ inputs.version }}
51+
VERSION: ${{ inputs.version }}-${{ matrix.arch }}
5652
PUSH_ON_BUILD: true
57-
BUILD_MULTI_ARCH_IMAGES: ${{ inputs.build_multi_arch_images }}
5853
GOPROXY: ${{ steps.setup-go-proxy.outputs.goproxy-url }}
54+
DOCKER_BUILD_PLATFORM_OPTIONS: "--platform=linux/${{ matrix.arch }}"
5955
run: |
6056
echo "${VERSION}"
6157
make -f deployments/container/Makefile build
58+
59+
create-manifest:
60+
needs: [ build ]
61+
runs-on: ubuntu-latest
62+
steps:
63+
- uses: actions/checkout@v5
64+
name: Check out code
65+
- name: Login to GitHub Container Registry
66+
uses: docker/login-action@v3
67+
with:
68+
registry: ghcr.io
69+
username: ${{ github.actor }}
70+
password: ${{ secrets.GITHUB_TOKEN }}
71+
- name: Build Manifest
72+
env:
73+
MULTIARCH_IMAGE: ghcr.io/nvidia/k8s-device-plugin:${{ inputs.version }}
74+
run: |
75+
docker manifest create \
76+
${MULTIARCH_IMAGE} \
77+
ghcr.io/nvidia/k8s-device-plugin:${{ inputs.version }}-amd64 \
78+
ghcr.io/nvidia/k8s-device-plugin:${{ inputs.version }}-arm64
79+
docker manifest push ${MULTIARCH_IMAGE}

deployments/container/Makefile

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

1515
BUILD_MULTI_ARCH_IMAGES ?= no
1616
DOCKER ?= docker
17-
BUILDX =
18-
ifeq ($(BUILD_MULTI_ARCH_IMAGES),true)
19-
BUILDX = buildx
20-
endif
2117
MKDIR ?= mkdir
2218

2319
##### Global variables #####
@@ -72,8 +68,7 @@ DOCKERFILE = $(CURDIR)/deployments/container/Dockerfile
7268

7369
# Use a generic build target to build the relevant images
7470
$(IMAGE_TARGETS): image-%:
75-
DOCKER_BUILDKIT=1 \
76-
$(DOCKER) $(BUILDX) build --pull \
71+
$(DOCKER) build --pull \
7772
--provenance=false --sbom=false \
7873
$(DOCKER_BUILD_OPTIONS) \
7974
$(DOCKER_BUILD_PLATFORM_OPTIONS) \

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)