Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 31 additions & 14 deletions .github/workflows/image.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,26 +24,21 @@ on:

jobs:
build-image:
runs-on: linux-amd64-cpu4
strategy:
matrix:
arch:
- amd64
- arm64
dist: [ubi9]
runs-on: linux-${{ matrix.arch }}-cpu4
permissions:
contents: read
id-token: write
packages: write
strategy:
matrix:
dist: [ubi9]
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:
Expand All @@ -56,10 +51,32 @@ jobs:
- name: Build image
env:
IMAGE_NAME: ghcr.io/nvidia/k8s-driver-manager
VERSION: ${{ inputs.version }}
VERSION: ${{ inputs.version }}-${{ matrix.arch }}
PUSH_ON_BUILD: "true"
BUILD_MULTI_ARCH_IMAGES: "true"
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-${{ matrix.dist }}

create-manifest:
needs: [ build-image ]
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-driver-manager:${{ inputs.version }}
run: |
docker manifest create \
${MULTIARCH_IMAGE} \
ghcr.io/nvidia/k8s-driver-manager:${{ inputs.version }}-amd64 \
ghcr.io/nvidia/k8s-driver-manager:${{ inputs.version }}-arm64
docker manifest push ${MULTIARCH_IMAGE}
41 changes: 23 additions & 18 deletions deployments/container/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,6 @@

BUILD_MULTI_ARCH_IMAGES ?= no
DOCKER ?= docker
BUILDX =
ifeq ($(BUILD_MULTI_ARCH_IMAGES),true)
BUILDX = buildx
endif

##### Global variables #####
include $(CURDIR)/versions.mk
Expand All @@ -41,11 +37,12 @@ OUT_IMAGE = $(OUT_IMAGE_NAME):$(OUT_IMAGE_VERSION)
DISTRIBUTIONS := ubi9
DEFAULT_PUSH_TARGET := ubi9

IMAGE_TARGETS := $(patsubst %,image-%,$(DISTRIBUTIONS))
PUSH_TARGETS := $(patsubst %, push-%, $(DISTRIBUTIONS))
BUILD_TARGETS := $(patsubst %, build-%, $(DISTRIBUTIONS))
TEST_TARGETS := $(patsubst %, build-%, $(DISTRIBUTIONS))

.PHONY: $(DISTRIBUTIONS) $(PUSH_TARGETS) $(BUILD_TARGETS) $(TEST_TARGETS)
.PHONY: $(DISTRIBUTIONS) $(PUSH_TARGETS) $(BUILD_TARGETS) $(TEST_TARGETS) $(IMAGE_TARGETS)

ifneq ($(BUILD_MULTI_ARCH_IMAGES),true)
include $(CURDIR)/deployments/container/native-only.mk
Expand All @@ -56,21 +53,29 @@ endif
build-%: DOCKERFILE_SUFFIX = $(*)
build-%: DOCKERFILE = $(CURDIR)/deployments/container/Dockerfile.$(DOCKERFILE_SUFFIX)

image-%: DOCKERFILE_SUFFIX = $(*)
image-%: DOCKERFILE = $(CURDIR)/deployments/container/Dockerfile.$(DOCKERFILE_SUFFIX)

# Both ubi9 and build-ubi9 trigger a build of the relevant image
$(DISTRIBUTIONS): %: build-%
$(BUILD_TARGETS): build-%:
DOCKER_BUILDKIT=1 \
$(DOCKER) $(BUILDX) build --pull \
$(DOCKER_BUILD_OPTIONS) \
$(DOCKER_BUILD_PLATFORM_OPTIONS) \
--tag $(IMAGE) \
--build-arg GOLANG_VERSION="$(GOLANG_VERSION)" \
--build-arg VERSION="$(VERSION)" \
--build-arg GIT_COMMIT="$(GIT_COMMIT)" \
--build-arg CVE_UPDATES="$(CVE_UPDATES)" \
--build-arg GOPROXY="$(GOPROXY)" \
--file $(DOCKERFILE) \
$(CURDIR)

# Use a generic image target to build the relevant images
$(IMAGE_TARGETS): image-%:
$(DOCKER) build --pull \
$(DOCKER_BUILD_OPTIONS) \
$(DOCKER_BUILD_PLATFORM_OPTIONS) \
--tag $(IMAGE) \
--build-arg GOLANG_VERSION="$(GOLANG_VERSION)" \
--build-arg VERSION="$(VERSION)" \
--build-arg GIT_COMMIT="$(GIT_COMMIT)" \
--build-arg CVE_UPDATES="$(CVE_UPDATES)" \
--build-arg GOPROXY="$(GOPROXY)" \
--file $(DOCKERFILE) \
$(CURDIR)

# Handle the default build target.
.PHONY: build
build: $(DEFAULT_PUSH_TARGET)

.PHONY: bump-commit
BUMP_COMMIT := Bump to version $(VERSION)
Expand Down
2 changes: 1 addition & 1 deletion deployments/container/multi-arch.mk
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
PUSH_ON_BUILD ?= false
ATTACH_ATTESTATIONS ?= false
DOCKER_BUILD_OPTIONS = --output=type=image,push=$(PUSH_ON_BUILD) --provenance=$(ATTACH_ATTESTATIONS) --sbom=$(ATTACH_ATTESTATIONS)
DOCKER_BUILD_PLATFORM_OPTIONS = --platform=linux/amd64,linux/arm64
DOCKER_BUILD_PLATFORM_OPTIONS ?= --platform=linux/amd64,linux/arm64

REGCTL ?= regctl
$(PUSH_TARGETS): push-%:
Expand Down
10 changes: 9 additions & 1 deletion deployments/container/native-only.mk
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,15 @@
# See the License for the specific language governing permissions and
# limitations under the License.

DOCKER_BUILD_PLATFORM_OPTIONS = --platform=linux/amd64
PUSH_ON_BUILD ?= false
DOCKER_BUILD_PLATFORM_OPTIONS ?= --platform=linux/amd64

ifeq ($(PUSH_ON_BUILD),true)
$(BUILD_TARGETS): build-%: image-%
$(DOCKER) push "$(IMAGE)"
else
$(BUILD_TARGETS): build-%: image-%
endif

$(PUSH_TARGETS): push-%:
$(DOCKER) tag "$(IMAGE)" "$(OUT_IMAGE)"
Expand Down