From 7550ea0ab3061686e86963f8b16140edd5cba8d6 Mon Sep 17 00:00:00 2001 From: Howard Zhang Date: Thu, 23 Apr 2020 18:00:03 +0800 Subject: [PATCH] fix cross build conformance image error After using docker buildx build --platform, conformance image can build from correct architecture debian:stretch-slim image. Signed-off-by: Howard Zhang --- cluster/images/conformance/Makefile | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/cluster/images/conformance/Makefile b/cluster/images/conformance/Makefile index 76bb6f10db2..ea2a5a0be6c 100644 --- a/cluster/images/conformance/Makefile +++ b/cluster/images/conformance/Makefile @@ -34,6 +34,9 @@ CLUSTER_DIR?=$(shell pwd)/../../../cluster/ BASEIMAGE=debian:stretch-slim TEMP_DIR:=$(shell mktemp -d -t conformanceXXXXXX) +#output format for docker buildx build [push, load] +OUTPUT=--load + all: build build: @@ -56,15 +59,14 @@ endif cd ${TEMP_DIR} && sed -i.back "s|BASEIMAGE|${BASEIMAGE}|g" Dockerfile - docker build --pull -t ${REGISTRY}/conformance-${ARCH}:${VERSION} ${TEMP_DIR} - rm -rf "${TEMP_DIR}" - -push: build - docker push ${REGISTRY}/conformance-${ARCH}:${VERSION} + DOCKER_CLI_EXPERIMENTAL=enabled docker buildx build --pull --platform linux/$(ARCH) $(OUTPUT) -t ${REGISTRY}/conformance-${ARCH}:${VERSION} ${TEMP_DIR} ifeq ($(ARCH),amd64) docker rmi ${REGISTRY}/conformance:${VERSION} 2>/dev/null || true - docker tag ${REGISTRY}/conformance-${ARCH}:${VERSION} ${REGISTRY}/conformance:${VERSION} - docker push ${REGISTRY}/conformance:${VERSION} + DOCKER_CLI_EXPERIMENTAL=enabled docker buildx build --pull --platform linux/$(ARCH) $(OUTPUT) -t ${REGISTRY}/conformance:${VERSION} ${TEMP_DIR} endif + rm -rf "${TEMP_DIR}" + +push: OUTPUT=--push +push: build .PHONY: build push all