diff --git a/Dockerfile b/Dockerfile index 244389c6..1e63f423 100644 --- a/Dockerfile +++ b/Dockerfile @@ -48,7 +48,8 @@ # Copy the controller-manager into a thin image #FROM alpine:3.11 FROM gcr.io/distroless/static:latest +ARG ARCH WORKDIR / -COPY bin/manager ./ +COPY bin/${ARCH}/manager ./ USER nobody ENTRYPOINT ["/manager"] \ No newline at end of file diff --git a/Makefile b/Makefile index 01a0bdbd..b47d1860 100644 --- a/Makefile +++ b/Makefile @@ -68,7 +68,7 @@ PROD_REGISTRY := mocimages.azurecr.io IMAGE_NAME ?= caphcontroller CONTROLLER_IMG ?= $(REGISTRY)/$(IMAGE_NAME) TAG := $(MAJOR_VER).$(MINOR_VER).$(PATCH_VER)${TAGSUFFIX_APPEND} -ARCH := amd64 +ARCH ?= amd64 ALL_ARCH = amd64 arm arm64 ppc64le s390x # Local repository path for development @@ -125,7 +125,7 @@ binaries: manager ## Builds and installs all binaries .PHONY: manager manager: ## Build manager binary. - CGO_ENABLED=0 GOOS=linux go build -a -ldflags '-extldflags "-static"' -o bin/manager cmd/manager/main.go + CGO_ENABLED=0 GOOS=linux GOARCH=$(ARCH) go build -a -ldflags '-extldflags "-static"' -o bin/$(ARCH)/manager cmd/manager/main.go ## -------------------------------------- ## Tooling Binaries @@ -220,7 +220,7 @@ docker-login: ## Login docker to a private registry .PHONY: docker-build-img docker-build-img: manager #docker build --pull --build-arg ARCH=$(ARCH) . -t $(CONTROLLER_IMG)-$(ARCH):$(TAG) - docker build --pull --build-arg ARCH=$(ARCH) . -t $(CONTROLLER_IMG):$(TAG) + docker build --pull --build-arg ARCH=$(ARCH) . -t $(CONTROLLER_IMG):$(TAG) .PHONY: docker-build docker-build: docker-build-img ## Build the docker image for controller-manager