Skip to content

Commit 0c57cd0

Browse files
authored
Merge pull request #4399 from wyike/customize_golang_version
Customize golang version
2 parents 5c95adf + 4ff5e37 commit 0c57cd0

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515
# limitations under the License.
1616

1717
# Build the manager binary
18-
FROM public.ecr.aws/docker/library/golang:1.20.6 as toolchain
18+
ARG builder_image
19+
FROM ${builder_image} as toolchain
1920

2021
# Run this with docker build --build_arg $(go env GOPROXY) to override the goproxy
2122
ARG goproxy=https://proxy.golang.org

Makefile

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ include $(ROOT_DIR_RELATIVE)/common.mk
1919
# If you update this file, please follow
2020
# https://suva.sh/posts/well-documented-makefiles
2121

22+
# Go
23+
GO_VERSION ?=1.20.6
24+
GO_CONTAINER_IMAGE ?= public.ecr.aws/docker/library/golang:$(GO_VERSION)
25+
2226
# Directories.
2327
ARTIFACTS ?= $(REPO_ROOT)/_artifacts
2428
TOOLS_DIR := hack/tools
@@ -350,7 +354,7 @@ clusterawsadm: ## Build clusterawsadm binary
350354

351355
.PHONY: docker-build
352356
docker-build: docker-pull-prerequisites ## Build the docker image for controller-manager
353-
docker build --build-arg ARCH=$(ARCH) --build-arg LDFLAGS="$(LDFLAGS)" . -t $(CORE_CONTROLLER_IMG)-$(ARCH):$(TAG)
357+
docker build --build-arg ARCH=$(ARCH) --build-arg builder_image=$(GO_CONTAINER_IMAGE) --build-arg LDFLAGS="$(LDFLAGS)" . -t $(CORE_CONTROLLER_IMG)-$(ARCH):$(TAG)
354358

355359
.PHONY: docker-build-all ## Build all the architecture docker images
356360
docker-build-all: $(addprefix docker-build-,$(ALL_ARCH))
@@ -383,7 +387,7 @@ generate-test-flavors: $(KUSTOMIZE) ## Generate test template flavors
383387

384388
.PHONY: e2e-image
385389
e2e-image: docker-pull-prerequisites $(TOOLS_BIN_DIR)/start.sh $(TOOLS_BIN_DIR)/restart.sh ## Build an e2e test image
386-
docker build -f Dockerfile --tag="gcr.io/k8s-staging-cluster-api/capa-manager:e2e" .
390+
docker build --build-arg builder_image=$(GO_CONTAINER_IMAGE) -f Dockerfile --tag="gcr.io/k8s-staging-cluster-api/capa-manager:e2e" .
387391

388392
.PHONY: install-setup-envtest
389393
install-setup-envtest: # Install setup-envtest so that setup-envtest's eval is executed after the tool has been installed.
@@ -462,7 +466,7 @@ $(RELEASE_DIR):
462466

463467
.PHONY: build-toolchain
464468
build-toolchain: ## Build the toolchain
465-
docker build --target toolchain -t $(TOOLCHAIN_IMAGE) .
469+
docker build --build-arg builder_image=$(GO_CONTAINER_IMAGE) --target toolchain -t $(TOOLCHAIN_IMAGE) .
466470

467471
.PHONY: check-github-token
468472
check-github-token: ## Check if the github token is set
@@ -690,3 +694,8 @@ clean-temporary: ## Remove all temporary files and folders
690694
rm -rf test/e2e/capi-kubeadm-control-plane-controller-manager
691695
rm -rf test/e2e/logs
692696
rm -rf test/e2e/resources
697+
698+
##@ helpers:
699+
700+
go-version: ## Print the go version we use to compile our binaries and images
701+
@echo $(GO_VERSION)

0 commit comments

Comments
 (0)