diff --git a/Makefile b/Makefile index 0017afbb..e3461896 100644 --- a/Makefile +++ b/Makefile @@ -23,6 +23,7 @@ GIT_SHA=$(shell git rev-parse --short HEAD) TEST_IMAGE=$(TEST_REPO)-testimages:$(VERSION) DOCKER_TEST_PASS=testzkop@123 DOCKER_TEST_USER=testzkop +IMG?=$(REPO):$(VERSION) .PHONY: all build check clean test # Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set) ifeq (,$(shell go env GOBIN)) @@ -133,6 +134,23 @@ build-image: docker build --build-arg VERSION=$(VERSION) --build-arg DOCKER_REGISTRY=$(DOCKER_REGISTRY) --build-arg DISTROLESS_DOCKER_REGISTRY=$(DISTROLESS_DOCKER_REGISTRY) --build-arg GIT_SHA=$(GIT_SHA) -t $(REPO):$(VERSION) . docker tag $(REPO):$(VERSION) $(REPO):latest +# PLATFORMS defines the target platforms for the manager image be built to provide support to multiple +# architectures. (i.e. make docker-buildx IMG=myregistry/mypoperator:0.0.1). To use this option you need to: +# - be able to use docker buildx. More info: https://docs.docker.com/build/buildx/ +# - have enabled BuildKit. More info: https://docs.docker.com/develop/develop-images/build_enhancements/ +# - be able to push the image to your registry (i.e. if you do not set a valid value via IMG=> then the export will fail) +# To adequately provide solutions that are compatible with multiple platforms, you should consider using this option. +PLATFORMS ?= linux/arm64,linux/amd64 +.PHONY: docker-buildx +docker-buildx: ## Build and push docker image for the manager for cross-platform support + # copy existing Dockerfile and insert --platform=${BUILDPLATFORM} into Dockerfile.cross, and preserve the original Dockerfile + sed -e '1 s/\(^FROM\)/FROM --platform=\$$\{BUILDPLATFORM\}/; t' -e ' 1,// s//FROM --platform=\$$\{BUILDPLATFORM\}/' Dockerfile > Dockerfile.cross + - docker buildx create --name zookeeper-builder + docker buildx use zookeeper-builder + docker buildx build --push --platform=$(PLATFORMS) --tag $(IMG) -f Dockerfile.cross . + - docker buildx rm zookeeper-builder + rm Dockerfile.cross + build-zk-image: docker build --build-arg VERSION=$(VERSION) --build-arg DOCKER_REGISTRY=$(DOCKER_REGISTRY) --build-arg GIT_SHA=$(GIT_SHA) -t $(APP_REPO):$(VERSION) ./docker