Skip to content

Commit

Permalink
fix(ci): build images without buildkit (#1224)
Browse files Browse the repository at this point in the history
  • Loading branch information
Leo Ryu authored Apr 23, 2021
1 parent 8ba52cd commit 21f3cce
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 9 deletions.
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 7 additions & 2 deletions build/docker/tools/provider-res/download.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
15 changes: 14 additions & 1 deletion build/lib/docker-buildx.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
8 changes: 2 additions & 6 deletions build/lib/image.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 21f3cce

Please sign in to comment.