@@ -52,6 +52,9 @@ OPM_VERSION = v1.19.5
5252
5353CRD_OPTIONS ?= "crd:crdVersions=v1"
5454
55+ GOOS = linux
56+ GOARCH = amd64
57+
5558# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set)
5659ifeq (,$(shell go env GOBIN) )
5760 GOBIN =$(shell go env GOPATH) /bin
@@ -185,23 +188,48 @@ generate: controller-gen
185188# ## docker: Builds and pushes controller image
186189docker : _print_vars docker-build docker-push
187190
188- # ## docker-build: Builds the controller image
189- docker-build :
190- $(DOCKER ) build . -t ${DWO_IMG} -f build/Dockerfile
191+ # ## docker-build: Builds the images and the local manifest list
192+ docker-build : _docker-build-amd64 _docker-build-arm64
193+ # clean up any old local manifest list to avoid conflicts
194+ $(DOCKER ) manifest rm ${DWO_IMG} || true
195+ # create a new local manifest list from the freshly built images
196+ $(DOCKER ) manifest create ${DWO_IMG} ${DWO_IMG} -amd64 ${DWO_IMG} -arm64
197+
198+
199+ # ## _docker-build-amd64: Builds the amd64 image
200+ _docker-build-amd64 :
201+ $(DOCKER ) build . --platform linux/amd64 -t ${DWO_IMG} -amd64 -f build/Dockerfile
202+
203+ # ## _docker-build-arm64: Builds the arm64 image
204+ _docker-build-arm64 :
205+ $(DOCKER ) build . --platform linux/arm64 -t ${DWO_IMG} -arm64 -f build/Dockerfile
206+
207+
208+ # ## docker-push: Pushes the images and manifest to the registry
209+ docker-push : _docker-check-push
210+ # pushing architecture-specific images to the registry
211+ $(DOCKER ) push ${DWO_IMG} -amd64
212+ $(DOCKER ) push ${DWO_IMG} -arm64
213+
214+ # clean up any old local manifest list to avoid conflicts
215+ $(DOCKER) manifest rm ${DWO_IMG} || true
216+ # re-create the manifest right before pushing to ensure its state is clean
217+ $(DOCKER) manifest create ${DWO_IMG} ${DWO_IMG}-amd64 ${DWO_IMG}-arm64
218+ # push the manifest list and its images
219+ $(DOCKER) manifest push --all ${DWO_IMG}
191220
192- # ## docker- push: Pushes the controller image
193- docker -push :
221+ # ## _docker-check- push: Asks for confirmation before pushing the image, unless running in CI
222+ _docker-check -push :
194223 ifneq ($(INITIATOR),CI)
195224 ifeq ($(DWO_IMG ) ,quay.io/devfile/devworkspace-controller :next)
196225 @echo -n " Are you sure you want to push $( DWO_IMG) ? [y/N] " && read ans && [ $$ {ans:-N} = y ]
197226 endif
198227 endif
199- $(DOCKER) push ${DWO_IMG}
200228
201229# ## compile-devworkspace-controller: Compiles the devworkspace-controller binary
202230.PHONY : compile-devworkspace-controller
203231compile-devworkspace-controller :
204- CGO_ENABLED=0 GOOS=linux GOARCH=$(ARCH ) GO111MODULE=on go build \
232+ CGO_ENABLED=0 GOOS=linux GOARCH=$(GOARCH ) GO111MODULE=on go build \
205233 -a -o _output/bin/devworkspace-controller \
206234 -gcflags all=-trimpath=/ \
207235 -asmflags all=-trimpath=/ \
@@ -212,7 +240,7 @@ compile-devworkspace-controller:
212240# ## compile-webhook-server: Compiles the webhook-server
213241.PHONY : compile-webhook-server
214242compile-webhook-server :
215- CGO_ENABLED=0 GOOS=linux GOARCH=$(ARCH ) GO111MODULE=on go build \
243+ CGO_ENABLED=0 GOOS=linux GOARCH=$(GOARCH ) GO111MODULE=on go build \
216244 -o _output/bin/webhook-server \
217245 -gcflags all=-trimpath=/ \
218246 -asmflags all=-trimpath=/ \
0 commit comments