diff --git a/Dockerfile b/Dockerfile index 73296b2368..155b9519a7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -15,7 +15,8 @@ # limitations under the License. # Build the manager binary -FROM golang:1.18.3 as toolchain +ARG builder_image +FROM ${builder_image} as toolchain # Run this with docker build --build_arg $(go env GOPROXY) to override the goproxy ARG goproxy=https://proxy.golang.org diff --git a/Makefile b/Makefile index 470471879d..d7843fc1a8 100644 --- a/Makefile +++ b/Makefile @@ -19,6 +19,10 @@ include $(ROOT_DIR_RELATIVE)/common.mk # If you update this file, please follow # https://suva.sh/posts/well-documented-makefiles +# Go +GO_VERSION ?=1.18.3 +GO_CONTAINER_IMAGE ?= public.ecr.aws/docker/library/golang:$(GO_VERSION) + # Directories. ARTIFACTS ?= $(REPO_ROOT)/_artifacts TOOLS_DIR := hack/tools @@ -340,7 +344,7 @@ clusterawsadm: ## Build clusterawsadm binary .PHONY: docker-build docker-build: docker-pull-prerequisites ## Build the docker image for controller-manager - docker build --build-arg ARCH=$(ARCH) --build-arg LDFLAGS="$(LDFLAGS)" . -t $(CORE_CONTROLLER_IMG)-$(ARCH):$(TAG) + docker build --build-arg ARCH=$(ARCH) --build-arg builder_image=$(GO_CONTAINER_IMAGE) --build-arg LDFLAGS="$(LDFLAGS)" . -t $(CORE_CONTROLLER_IMG)-$(ARCH):$(TAG) .PHONY: docker-build-all ## Build all the architecture docker images docker-build-all: $(addprefix docker-build-,$(ALL_ARCH)) @@ -373,7 +377,7 @@ generate-test-flavors: $(KUSTOMIZE) ## Generate test template flavors .PHONY: e2e-image e2e-image: docker-pull-prerequisites $(TOOLS_BIN_DIR)/start.sh $(TOOLS_BIN_DIR)/restart.sh ## Build an e2e test image - docker build -f Dockerfile --tag="gcr.io/k8s-staging-cluster-api/capa-manager:e2e" . + docker build --build-arg builder_image=$(GO_CONTAINER_IMAGE) -f Dockerfile --tag="gcr.io/k8s-staging-cluster-api/capa-manager:e2e" . .PHONY: install-setup-envtest install-setup-envtest: # Install setup-envtest so that setup-envtest's eval is executed after the tool has been installed. @@ -456,7 +460,7 @@ $(RELEASE_DIR): .PHONY: build-toolchain build-toolchain: ## Build the toolchain - docker build --target toolchain -t $(TOOLCHAIN_IMAGE) . + docker build --build-arg builder_image=$(GO_CONTAINER_IMAGE) --target toolchain -t $(TOOLCHAIN_IMAGE) . .PHONY: check-github-token check-github-token: ## Check if the github token is set @@ -679,3 +683,8 @@ clean-temporary: ## Remove all temporary files and folders rm -rf test/e2e/capi-kubeadm-control-plane-controller-manager rm -rf test/e2e/logs rm -rf test/e2e/resources + +##@ helpers: + +go-version: ## Print the go version we use to compile our binaries and images + @echo $(GO_VERSION)