diff --git a/Makefile b/Makefile index 974506f64..0cf58edd8 100644 --- a/Makefile +++ b/Makefile @@ -75,7 +75,8 @@ ARCH ?= amd64 OSVERSION ?= 1809 # Output type of docker buildx build OUTPUT_TYPE ?= registry -QEMUVERSION ?= 5.2.0-2 +BUILDX_BUILDER_NAME ?= img-builder +QEMU_VERSION ?= 5.2.0-2 # Binaries GOLANGCI_LINT := $(TOOLS_BIN_DIR)/golangci-lint @@ -286,20 +287,20 @@ endif .PHONY: e2e-provider-container e2e-provider-container: - docker build --no-cache -t $(E2E_PROVIDER_IMAGE_TAG) -f test/e2eprovider/Dockerfile . + docker buildx build --no-cache -t $(E2E_PROVIDER_IMAGE_TAG) -f test/e2eprovider/Dockerfile --progress=plain . .PHONY: container container: crd-container - docker build --no-cache --build-arg IMAGE_VERSION=$(IMAGE_VERSION) -t $(IMAGE_TAG) -f docker/Dockerfile . + docker buildx build --no-cache --build-arg IMAGE_VERSION=$(IMAGE_VERSION) -t $(IMAGE_TAG) -f docker/Dockerfile --progress=plain . .PHONY: crd-container crd-container: build-crds - docker build --no-cache --build-arg ARCH=$(ARCH) -t $(CRD_IMAGE_TAG) -f docker/crd.Dockerfile _output/crds/ + docker buildx build --no-cache -t $(CRD_IMAGE_TAG) -f docker/crd.Dockerfile --progress=plain _output/crds/ .PHONY: crd-container-linux crd-container-linux: build-crds docker-buildx-builder docker buildx build --no-cache --output=type=$(OUTPUT_TYPE) --platform="linux/$(ARCH)" \ - --build-arg ARCH=$(ARCH) -t $(CRD_IMAGE_TAG)-linux-$(ARCH) -f docker/crd.Dockerfile _output/crds/ + -t $(CRD_IMAGE_TAG)-linux-$(ARCH) -f docker/crd.Dockerfile _output/crds/ .PHONY: container-linux container-linux: docker-buildx-builder @@ -315,15 +316,14 @@ container-windows: docker-buildx-builder .PHONY: docker-buildx-builder docker-buildx-builder: - @if ! docker buildx ls | grep -q container-builder; then\ - DOCKER_CLI_EXPERIMENTAL=enabled docker buildx create --name container-builder --use;\ + @if ! docker buildx ls | grep $(BUILDX_BUILDER_NAME); then \ + docker run --rm --privileged multiarch/qemu-user-static:$(QEMU_VERSION) --reset -p yes; \ + docker buildx create --name $(BUILDX_BUILDER_NAME) --use; \ + docker buildx inspect $(BUILDX_BUILDER_NAME) --bootstrap; \ fi .PHONY: container-all -container-all: - # Enable execution of multi-architecture containers - docker run --rm --privileged multiarch/qemu-user-static:$(QEMUVERSION) --reset -p yes - +container-all: docker-buildx-builder for arch in $(ALL_ARCH.linux); do \ ARCH=$${arch} $(MAKE) container-linux; \ ARCH=$${arch} $(MAKE) crd-container-linux; \ @@ -378,8 +378,7 @@ ifdef TEST_WINDOWS $(MAKE) container-all push-manifest else $(MAKE) container - kind load docker-image --name kind $(IMAGE_TAG) - kind load docker-image --name kind $(CRD_IMAGE_TAG) + kind load docker-image --name kind $(IMAGE_TAG) $(CRD_IMAGE_TAG) endif .PHONY: e2e-mock-provider-container diff --git a/docker/build.sh b/docker/build.sh index 78e0d7654..9666fc7f1 100755 --- a/docker/build.sh +++ b/docker/build.sh @@ -111,7 +111,7 @@ build_and_push() { # charts to prod dir. So we can use manifest_staging charts for the image build. if find ../manifest_staging/charts/secrets-store-csi-driver/crds -mindepth 1 -maxdepth 1 | read -r; then if [[ "$os_name" != "windows" ]]; then - docker buildx build --no-cache --pull --push --platform "${os_name}/${arch}" --build-arg ARCH="${arch}" -t "${CRD_IMAGE_TAG}-${suffix}" \ + docker buildx build --no-cache --pull --push --platform "${os_name}/${arch}" -t "${CRD_IMAGE_TAG}-${suffix}" \ -f crd.Dockerfile ../manifest_staging/charts/secrets-store-csi-driver/crds fi fi diff --git a/docker/crd.Dockerfile b/docker/crd.Dockerfile index 9c0e5c106..e69660901 100644 --- a/docker/crd.Dockerfile +++ b/docker/crd.Dockerfile @@ -14,10 +14,10 @@ FROM alpine as builder ARG KUBE_VERSION=v1.21.2 -ARG ARCH +ARG TARGETARCH RUN apk add --no-cache curl && \ - curl -LO https://storage.googleapis.com/kubernetes-release/release/${KUBE_VERSION}/bin/linux/${ARCH}/kubectl && \ + curl -LO https://storage.googleapis.com/kubernetes-release/release/${KUBE_VERSION}/bin/linux/${TARGETARCH}/kubectl && \ chmod +x kubectl FROM gcr.io/distroless/static