Skip to content

Commit

Permalink
feat: enable multiarch image build by default
Browse files Browse the repository at this point in the history
To achieve this, we need to implement additional logic in the
controller-gen, alongside the traditional process of building for
different architectures and combining them into a single manifest.
The challenge arises from the fact that GOBIN cannot be used in
conjunction with cross compiling.

While the workaround is somewhat hacky, I have not identified a
more straightforward solution.

Signed-off-by: Nestor Acuna Blanco <[email protected]>
  • Loading branch information
nestoracunablanco committed Sep 24, 2024
1 parent dd98731 commit de58f9f
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -196,14 +196,14 @@ container-build: unittest bundle
mkdir -p data/crd
cp bundle/manifests/ssp-operator.clusterserviceversion.yaml data/olm-catalog/ssp-operator.clusterserviceversion.yaml
cp bundle/manifests/ssp.kubevirt.io_ssps.yaml data/crd/ssp.kubevirt.io_ssps.yaml
podman build -t ${IMG} \
--build-arg VALIDATOR_IMG=${VALIDATOR_IMG} \
.
podman manifest rm ${IMG} || true
podman build --build-arg TARGET_ARCH=amd64 --build-arg VALIDATOR_IMG=${VALIDATOR_IMG} --manifest=${IMG} . && \
podman build --build-arg TARGET_ARCH=s390x --build-arg VALIDATOR_IMG=${VALIDATOR_IMG} --manifest=${IMG} .

# Push the container image
.PHONY: container-push
container-push:
podman push ${IMG}
podman manifest push ${IMG}

.PHONY: build-template-validator
build-template-validator:
Expand Down Expand Up @@ -244,10 +244,12 @@ kustomize: $(KUSTOMIZE) ## Download kustomize locally if necessary.
$(KUSTOMIZE): $(LOCALBIN)
test -s $(LOCALBIN)/kustomize || curl -s $(KUSTOMIZE_INSTALL_SCRIPT) | bash -s -- $(subst v,,$(KUSTOMIZE_VERSION)) $(LOCALBIN)

# The final line allows for downloading and copying into the LOCALBIN folder when cross-compiling, as GOBIN is not compatible with setting a different GOARCH
.PHONY: controller-gen
controller-gen: $(CONTROLLER_GEN) ## Download controller-gen locally if necessary.
$(CONTROLLER_GEN): $(LOCALBIN)
test -s $(LOCALBIN)/controller-gen || GOBIN=$(LOCALBIN) go install sigs.k8s.io/controller-tools/cmd/controller-gen@$(CONTROLLER_TOOLS_VERSION)
test -s $(LOCALBIN)/controller-gen || \
GOBIN=$(LOCALBIN) GOARCH=$(ARCH) go install sigs.k8s.io/controller-tools/cmd/controller-gen@$(CONTROLLER_TOOLS_VERSION)

# Download operator-sdk locally if necessary
$(OPERATOR_SDK): $(LOCALBIN)
Expand Down

0 comments on commit de58f9f

Please sign in to comment.