diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 9a7f9950b..924fceb43 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -33,7 +33,6 @@ jobs: secrets: inherit with: version: ${{ needs.basic.outputs.version }} - build_multi_arch_images: ${{ github.ref_name == 'main' || startsWith(github.ref_name, 'release-') }} e2e-test: needs: diff --git a/.github/workflows/image.yaml b/.github/workflows/image.yaml index 24e1de2e5..1937ddffd 100644 --- a/.github/workflows/image.yaml +++ b/.github/workflows/image.yaml @@ -20,13 +20,15 @@ on: version: required: true type: string - build_multi_arch_images: - required: true - type: string jobs: build: - runs-on: linux-amd64-cpu4 + strategy: + matrix: + arch: + - amd64 + - arm64 + runs-on: linux-${{ matrix.arch }}-cpu4 permissions: contents: read id-token: write @@ -34,12 +36,6 @@ jobs: steps: - uses: actions/checkout@v5 name: Check out code - - name: Set up QEMU - uses: docker/setup-qemu-action@v3 - with: - image: tonistiigi/binfmt:master - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 - name: Login to GitHub Container Registry uses: docker/login-action@v3 with: @@ -52,10 +48,32 @@ jobs: - name: Build image env: IMAGE_NAME: ghcr.io/nvidia/k8s-device-plugin - VERSION: ${{ inputs.version }} + VERSION: ${{ inputs.version }}-${{ matrix.arch }} PUSH_ON_BUILD: true - BUILD_MULTI_ARCH_IMAGES: ${{ inputs.build_multi_arch_images }} GOPROXY: ${{ steps.setup-go-proxy.outputs.goproxy-url }} + DOCKER_BUILD_PLATFORM_OPTIONS: "--platform=linux/${{ matrix.arch }}" run: | echo "${VERSION}" make -f deployments/container/Makefile build + + create-manifest: + needs: [ build ] + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v5 + name: Check out code + - name: Login to GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Build Manifest + env: + MULTIARCH_IMAGE: ghcr.io/nvidia/k8s-device-plugin:${{ inputs.version }} + run: | + docker manifest create \ + ${MULTIARCH_IMAGE} \ + ghcr.io/nvidia/k8s-device-plugin:${{ inputs.version }}-amd64 \ + ghcr.io/nvidia/k8s-device-plugin:${{ inputs.version }}-arm64 + docker manifest push ${MULTIARCH_IMAGE} diff --git a/deployments/container/Makefile b/deployments/container/Makefile index 7f042e8ef..1a838fdc6 100644 --- a/deployments/container/Makefile +++ b/deployments/container/Makefile @@ -14,10 +14,6 @@ BUILD_MULTI_ARCH_IMAGES ?= no DOCKER ?= docker -BUILDX = -ifeq ($(BUILD_MULTI_ARCH_IMAGES),true) -BUILDX = buildx -endif MKDIR ?= mkdir ##### Global variables ##### @@ -72,8 +68,7 @@ DOCKERFILE = $(CURDIR)/deployments/container/Dockerfile # Use a generic build target to build the relevant images $(IMAGE_TARGETS): image-%: - DOCKER_BUILDKIT=1 \ - $(DOCKER) $(BUILDX) build --pull \ + $(DOCKER) build --pull \ --provenance=false --sbom=false \ $(DOCKER_BUILD_OPTIONS) \ $(DOCKER_BUILD_PLATFORM_OPTIONS) \ diff --git a/deployments/container/multi-arch.mk b/deployments/container/multi-arch.mk index 731d5455b..84174a4f1 100644 --- a/deployments/container/multi-arch.mk +++ b/deployments/container/multi-arch.mk @@ -14,6 +14,6 @@ PUSH_ON_BUILD ?= false DOCKER_BUILD_OPTIONS = --output=type=image,push=$(PUSH_ON_BUILD) -DOCKER_BUILD_PLATFORM_OPTIONS = --platform=linux/amd64,linux/arm64 +DOCKER_BUILD_PLATFORM_OPTIONS ?= --platform=linux/amd64,linux/arm64 $(BUILD_TARGETS): build-%: image-%