Skip to content

Commit

Permalink
Customize golang version
Browse files Browse the repository at this point in the history
  • Loading branch information
wyike committed Jul 19, 2023
1 parent 5c95adf commit 4ff5e37
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
# limitations under the License.

# Build the manager binary
FROM public.ecr.aws/docker/library/golang:1.20.6 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
Expand Down
15 changes: 12 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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.20.6
GO_CONTAINER_IMAGE ?= public.ecr.aws/docker/library/golang:$(GO_VERSION)

# Directories.
ARTIFACTS ?= $(REPO_ROOT)/_artifacts
TOOLS_DIR := hack/tools
Expand Down Expand Up @@ -350,7 +354,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))
Expand Down Expand Up @@ -383,7 +387,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.
Expand Down Expand Up @@ -462,7 +466,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
Expand Down Expand Up @@ -690,3 +694,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)

0 comments on commit 4ff5e37

Please sign in to comment.