From e6b57b91edc08911bd1cef4d37b81b514afb9863 Mon Sep 17 00:00:00 2001 From: Amulyam24 Date: Wed, 3 Jun 2026 11:38:19 +0530 Subject: [PATCH] Build AMD GPU operator images for ppc64le Signed-off-by: Amulyam24 --- Dockerfile | 8 +++++--- Makefile | 15 +++++++++++++-- internal/utils_container/Dockerfile | 7 ++++--- 3 files changed, 22 insertions(+), 8 deletions(-) diff --git a/Dockerfile b/Dockerfile index 6362149f..3ba9b56b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,7 +2,7 @@ ARG GOLANG_BASE_IMG=golang:1.25.8 ARG OPERATOR_CONTROLLER_BASE_IMAGE=registry.access.redhat.com/ubi9/ubi-minimal:9.7 # Build the manager binary -FROM ${GOLANG_BASE_IMG} AS builder +FROM --platform=$BUILDPLATFORM ${GOLANG_BASE_IMG} AS builder USER root @@ -36,11 +36,13 @@ RUN cd helm-charts-k8s/charts && \ tar -xvzf node-feature-discovery-chart-0.18.3.tgz ARG TARGET +ARG TARGETARCH +ARG TARGETOS # Build -RUN git config --global --add safe.directory ${PWD} && make ${TARGET} +RUN git config --global --add safe.directory ${PWD} && GOOS=${TARGETOS} GOARCH=${TARGETARCH} make ${TARGET} -RUN curl -LO https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl && \ +RUN curl -LO https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/${TARGETARCH}/kubectl && \ chmod +x ./kubectl FROM ${OPERATOR_CONTROLLER_BASE_IMAGE} diff --git a/Makefile b/Makefile index 9b3685c0..295af66e 100644 --- a/Makefile +++ b/Makefile @@ -341,8 +341,15 @@ docs-lint: ## Run docs Markdown lint + spelling (full ROCm-style docs lint). manager: $(shell find -name "*.go") go.mod go.sum ## Build manager binary. go build -ldflags="-X main.Version=$(PROJECT_VERSION) -X main.GitCommit=$(GIT_COMMIT) -X main.BuildTag=$(HOURLY_TAG_LABEL)" -o $@ ./cmd +# Platforms for multi-arch builds +PLATFORMS ?= linux/amd64,linux/ppc64le + .PHONY: docker-build -docker-build: ## Build docker image with the manager. +docker-build: ## Build and push multi-arch docker image with the manager. + docker buildx build --platform $(PLATFORMS) -t $(IMG) --label HOURLY_TAG=$(HOURLY_TAG_LABEL) --build-arg TARGET=manager --build-arg GOLANG_BASE_IMG=$(GOLANG_BASE_IMG) --build-arg OPERATOR_CONTROLLER_BASE_IMAGE=$(OPERATOR_CONTROLLER_BASE_IMAGE) --push . + +.PHONY: docker-build-local +docker-build-local: ## Build docker image locally for current architecture only (no push). DOCKER_BUILDKIT=1 docker build -t $(IMG) --label HOURLY_TAG=$(HOURLY_TAG_LABEL) --build-arg TARGET=manager --build-arg GOLANG_BASE_IMG=$(GOLANG_BASE_IMG) --build-arg OPERATOR_CONTROLLER_BASE_IMAGE=$(OPERATOR_CONTROLLER_BASE_IMAGE) . .PHONY: docker-push @@ -354,7 +361,11 @@ docker-save: ## Save the container image with the manager. docker save $(IMG) | gzip > $(IMAGE_NAME).tar.gz .PHONY: docker-build-utils -docker-build-utils: ## Build docker image for utils container. +docker-build-utils: ## Build and push multi-arch docker image for utils container. + docker buildx build --platform $(PLATFORMS) -t $(UTILS_IMG) --label HOURLY_TAG=$(HOURLY_TAG_LABEL) -f internal/utils_container/Dockerfile --push . + +.PHONY: docker-build-utils-local +docker-build-utils-local: ## Build utils docker image locally for current architecture only (no push). DOCKER_BUILDKIT=1 docker build -t $(UTILS_IMG) --label HOURLY_TAG=$(HOURLY_TAG_LABEL) -f internal/utils_container/Dockerfile . .PHONY: docker-push-utils diff --git a/internal/utils_container/Dockerfile b/internal/utils_container/Dockerfile index 1849f6b2..1a361325 100644 --- a/internal/utils_container/Dockerfile +++ b/internal/utils_container/Dockerfile @@ -15,10 +15,11 @@ RUN microdnf install -y util-linux pciutils kmod tar jq systemd && \ ADD LICENSE /licenses/LICENSE -# Install kubectl and oc +# Install kubectl and oc with architecture detection +ARG TARGETARCH RUN mkdir -p /oc && cd /oc && \ - curl -SsLO 'https://mirror.openshift.com/pub/openshift-v4/clients/ocp/latest/openshift-client-linux-amd64-rhel9.tar.gz' && \ - tar -xzf openshift-client-linux-amd64-rhel9.tar.gz -C /oc && \ + curl -SsLO "https://mirror.openshift.com/pub/openshift-v4/clients/ocp/latest/openshift-client-linux-${TARGETARCH}-rhel9.tar.gz" && \ + tar -xzf openshift-client-linux-${TARGETARCH}-rhel9.tar.gz -C /oc && \ cp ./kubectl /usr/local/bin && chmod +x /usr/local/bin/kubectl && \ cp ./oc /usr/local/bin && chmod +x /usr/local/bin/oc && \ rm -rf /oc