@@ -20,6 +20,9 @@ SHELL:=/usr/bin/env bash
2020
2121.DEFAULT_GOAL: =help
2222
23+ GO_VERSION ?= 1.16.5
24+ GO_CONTAINER_IMAGE ?= docker.io/library/golang:$(GO_VERSION )
25+
2326# Use GOPROXY environment variable if set
2427GOPROXY := $(shell go env GOPROXY)
2528ifeq ($(GOPROXY ) ,)
@@ -372,7 +375,7 @@ modules: ## Runs go mod to ensure modules are up to date.
372375.PHONY : docker-pull-prerequisites
373376docker-pull-prerequisites :
374377 docker pull docker.io/docker/dockerfile:1.1-experimental
375- docker pull docker.io/library/golang:1.16.4
378+ docker pull $( GO_CONTAINER_IMAGE )
376379 docker pull gcr.io/distroless/static:latest
377380
378381.PHONY : docker-build
@@ -383,19 +386,19 @@ docker-build: docker-pull-prerequisites ## Build the docker images for controlle
383386
384387.PHONY : docker-build-core
385388docker-build-core : # # Build the docker image for core controller manager
386- DOCKER_BUILDKIT=1 docker build --build-arg goproxy=$(GOPROXY ) --build-arg ARCH=$(ARCH ) --build-arg ldflags=" $( LDFLAGS) " . -t $(CONTROLLER_IMG ) -$(ARCH ) :$(TAG )
389+ DOCKER_BUILDKIT=1 docker build --build-arg builder_image= $( GO_CONTAINER_IMAGE ) --build-arg goproxy=$(GOPROXY ) --build-arg ARCH=$(ARCH ) --build-arg ldflags=" $( LDFLAGS) " . -t $(CONTROLLER_IMG ) -$(ARCH ) :$(TAG )
387390 $(MAKE ) set-manifest-image MANIFEST_IMG=$(CONTROLLER_IMG ) -$(ARCH ) MANIFEST_TAG=$(TAG ) TARGET_RESOURCE=" ./config/default/manager_image_patch.yaml"
388391 $(MAKE ) set-manifest-pull-policy TARGET_RESOURCE=" ./config/default/manager_pull_policy.yaml"
389392
390393.PHONY : docker-build-kubeadm-bootstrap
391394docker-build-kubeadm-bootstrap : # # Build the docker image for kubeadm bootstrap controller manager
392- DOCKER_BUILDKIT=1 docker build --build-arg goproxy=$(GOPROXY ) --build-arg ARCH=$(ARCH ) --build-arg package=./bootstrap/kubeadm --build-arg ldflags=" $( LDFLAGS) " . -t $(KUBEADM_BOOTSTRAP_CONTROLLER_IMG ) -$(ARCH ) :$(TAG )
395+ DOCKER_BUILDKIT=1 docker build --build-arg builder_image= $( GO_CONTAINER_IMAGE ) --build-arg goproxy=$(GOPROXY ) --build-arg ARCH=$(ARCH ) --build-arg package=./bootstrap/kubeadm --build-arg ldflags=" $( LDFLAGS) " . -t $(KUBEADM_BOOTSTRAP_CONTROLLER_IMG ) -$(ARCH ) :$(TAG )
393396 $(MAKE ) set-manifest-image MANIFEST_IMG=$(KUBEADM_BOOTSTRAP_CONTROLLER_IMG ) -$(ARCH ) MANIFEST_TAG=$(TAG ) TARGET_RESOURCE=" ./bootstrap/kubeadm/config/default/manager_image_patch.yaml"
394397 $(MAKE ) set-manifest-pull-policy TARGET_RESOURCE=" ./bootstrap/kubeadm/config/default/manager_pull_policy.yaml"
395398
396399.PHONY : docker-build-kubeadm-control-plane
397400docker-build-kubeadm-control-plane : # # Build the docker image for kubeadm control plane controller manager
398- DOCKER_BUILDKIT=1 docker build --build-arg goproxy=$(GOPROXY ) --build-arg ARCH=$(ARCH ) --build-arg package=./controlplane/kubeadm --build-arg ldflags=" $( LDFLAGS) " . -t $(KUBEADM_CONTROL_PLANE_CONTROLLER_IMG ) -$(ARCH ) :$(TAG )
401+ DOCKER_BUILDKIT=1 docker build --build-arg builder_image= $( GO_CONTAINER_IMAGE ) --build-arg goproxy=$(GOPROXY ) --build-arg ARCH=$(ARCH ) --build-arg package=./controlplane/kubeadm --build-arg ldflags=" $( LDFLAGS) " . -t $(KUBEADM_CONTROL_PLANE_CONTROLLER_IMG ) -$(ARCH ) :$(TAG )
399402 $(MAKE ) set-manifest-image MANIFEST_IMG=$(KUBEADM_CONTROL_PLANE_CONTROLLER_IMG ) -$(ARCH ) MANIFEST_TAG=$(TAG ) TARGET_RESOURCE=" ./controlplane/kubeadm/config/default/manager_image_patch.yaml"
400403 $(MAKE ) set-manifest-pull-policy TARGET_RESOURCE=" ./controlplane/kubeadm/config/default/manager_pull_policy.yaml"
401404
@@ -541,7 +544,7 @@ release-binary: $(RELEASE_DIR)
541544 -e GOARCH=$(GOARCH ) \
542545 -v " $$ (pwd):/workspace$( DOCKER_VOL_OPTS) " \
543546 -w /workspace \
544- golang:1.16.4 \
547+ golang:$( GOLANG_VERSION ) \
545548 go build -a -ldflags " $( LDFLAGS) -extldflags '-static'" \
546549 -o $(RELEASE_DIR ) /$(notdir $(RELEASE_BINARY ) ) -$(GOOS ) -$(GOARCH ) $(RELEASE_BINARY )
547550
0 commit comments