From 21f3cce13c5d9b5c7a88d8c01dde8ee4a0f009ef Mon Sep 17 00:00:00 2001 From: Leo Ryu Date: Fri, 23 Apr 2021 22:05:11 +0800 Subject: [PATCH] fix(ci): build images without buildkit (#1224) --- Makefile | 3 +++ build/docker/tools/provider-res/download.sh | 9 +++++++-- build/lib/docker-buildx.mk | 15 ++++++++++++++- build/lib/image.mk | 8 ++------ 4 files changed, 26 insertions(+), 9 deletions(-) diff --git a/Makefile b/Makefile index 826b722fb..3e1169b21 100644 --- a/Makefile +++ b/Makefile @@ -136,6 +136,9 @@ test: .PHONY: release.build release.build: +ifeq ($(NEED_BUILD_PROVIDER),true) + cd build/docker/tools/provider-res && make all +endif make push.multiarch ## release: Release tke diff --git a/build/docker/tools/provider-res/download.sh b/build/docker/tools/provider-res/download.sh index f4ed7f1ee..6f030a8e0 100755 --- a/build/docker/tools/provider-res/download.sh +++ b/build/docker/tools/provider-res/download.sh @@ -58,8 +58,13 @@ function download::docker() { function download::kubernetes() { for version in ${K8S_VERSIONS}; do - wget -c "https://dl.k8s.io/${version}/kubernetes-node-${platform}.tar.gz" \ - -O "kubernetes-node-${platform}-${version}.tar.gz" + if [[ "${version}" =~ "tke" ]]; then + wget -c "https://tke-release-1251707795.cos.ap-guangzhou.myqcloud.com/kubernetes-node-linux-amd64-${version}.tar.gz" \ + -O "kubernetes-node-linux-amd64-${version}.tar.gz" + else + wget -c "https://dl.k8s.io/${version}/kubernetes-node-${platform}.tar.gz" \ + -O "kubernetes-node-${platform}-${version}.tar.gz" + fi done } diff --git a/build/lib/docker-buildx.mk b/build/lib/docker-buildx.mk index 121be892f..bc785aaa1 100644 --- a/build/lib/docker-buildx.mk +++ b/build/lib/docker-buildx.mk @@ -61,8 +61,21 @@ docker.buildx.%: docker.verify DOCKER_CLI_EXPERIMENTAL=enabled $(DOCKER) buildx build --pull --platform $(IMAGE_PLAT) --load \ -t $(IMAGE_NAME) $(_DOCKER_BUILD_EXTRA_ARGS) $(WORK_DIR) +.PHONY: docker.build.% +docker.build.%: docker.verify + $(eval IMAGE := $(word 2,$(subst ., ,$*))) + $(eval PLATFORM := $(word 1,$(subst ., ,$*))) + $(eval OS := $(word 1,$(subst _, ,$(PLATFORM)))) + $(eval ARCH := $(word 2,$(subst _, ,$(PLATFORM)))) + $(eval IMAGE_PLAT := $(subst _,/,$(PLATFORM))) + $(eval IMAGE_NAME := $(REGISTRY_PREFIX)/$(IMAGE)-$(ARCH):$(VERSION)) + @echo "===========> Building docker image $(IMAGE) $(VERSION) for $(IMAGE_PLAT)" + + $(eval BUILD_SUFFIX := $(_DOCKER_BUILD_EXTRA_ARGS) --pull -t $(REGISTRY_PREFIX)/$(IMAGE)-$(ARCH):$(VERSION) $(WORK_DIR)) + $(DOCKER) build --platform $(IMAGE_PLAT) $(BUILD_SUFFIX) + .PHONY: docker.push.% -docker.push.%: docker.buildx.% +docker.push.%: docker.build.% @echo "===========> Pushing image $(IMAGE_NAME)" $(DOCKER) push $(IMAGE_NAME) diff --git a/build/lib/image.mk b/build/lib/image.mk index 700940ea1..edaabd41e 100644 --- a/build/lib/image.mk +++ b/build/lib/image.mk @@ -79,12 +79,8 @@ image.build.%: go.build.% @cp $(OUTPUT_DIR)/$(IMAGE_PLAT)/$(IMAGE) $(TMP_DIR)/$(IMAGE)/ @DST_DIR=$(TMP_DIR)/$(IMAGE) $(ROOT_DIR)/build/docker/$(IMAGE)/build.sh 2>/dev/null || true $(eval BUILD_SUFFIX := $(_DOCKER_BUILD_EXTRA_ARGS) --pull -t $(REGISTRY_PREFIX)/$(IMAGE)-$(ARCH):$(VERSION) $(TMP_DIR)/$(IMAGE)) - @if [ $(shell $(GO) env GOARCH) != $(ARCH) ] ; then \ - $(MAKE) image.daemon.verify ;\ - $(DOCKER) build --platform $(IMAGE_PLAT) $(BUILD_SUFFIX) ; \ - else \ - $(DOCKER) build $(BUILD_SUFFIX) ; \ - fi + $(MAKE) image.daemon.verify + $(DOCKER) build --platform $(IMAGE_PLAT) $(BUILD_SUFFIX) @rm -rf $(TMP_DIR)/$(IMAGE) .PHONY: image.push