diff --git a/build/images/nginx/Dockerfile b/build/images/nginx/Dockerfile index 1b9c8774a..90fe42ea2 100644 --- a/build/images/nginx/Dockerfile +++ b/build/images/nginx/Dockerfile @@ -1,6 +1,6 @@ FROM quay.io/kubernetes-ingress-controller/debian-base-amd64:0.1 -ENV TERRAFORM_VERSION 0.12.16 +ENV TERRAFORM_VERSION 0.12.19 RUN clean-install \ bash \ diff --git a/build/images/nginx/build-nginx.sh b/build/images/nginx/build-nginx.sh index 21a5cdf2f..ab6f44e0f 100644 --- a/build/images/nginx/build-nginx.sh +++ b/build/images/nginx/build-nginx.sh @@ -64,18 +64,26 @@ apt -q=3 update apt -q=3 install docker-ce --yes +export DOCKER_CLI_EXPERIMENTAL=enabled + +mkdir -p ~/.docker +echo '{ "experimental": "enabled", "aliases": { "builder": "buildx" } }' > ~/.docker/config.json + echo ${docker_password} | docker login -u ${docker_username} --password-stdin quay.io curl -sL -o /usr/local/bin/gimme https://raw.githubusercontent.com/travis-ci/gimme/master/gimme chmod +x /usr/local/bin/gimme -eval "$(gimme 1.13)" +eval "$(gimme 1.13.6)" git clone https://github.com/kubernetes/ingress-nginx cd ingress-nginx/images/nginx -make register-qemu +docker run --rm --privileged docker/binfmt:66f9012c56a8316f9244ffd7622d7c21c1f6f28d + +docker buildx create --name ingress-nginx +docker buildx use ingress-nginx export TAG=$(git rev-parse HEAD) diff --git a/images/nginx/Makefile b/images/nginx/Makefile index f221dd2cc..7b681bf2c 100644 --- a/images/nginx/Makefile +++ b/images/nginx/Makefile @@ -19,28 +19,11 @@ ARCH ?= $(shell go env GOARCH) DOCKER ?= docker ALL_ARCH = amd64 arm arm64 -SED_I?=sed -i -GOHOSTOS ?= $(shell go env GOHOSTOS) - -ifeq ($(GOHOSTOS),darwin) - SED_I=sed -i '' -endif - -QEMUVERSION=v4.1.1-1 IMGNAME = nginx IMAGE = $(REGISTRY)/$(IMGNAME) MULTI_ARCH_IMG = $(IMAGE)-$(ARCH) -ifeq ($(ARCH),arm) - QEMUARCH=arm -endif -ifeq ($(ARCH),arm64) - QEMUARCH=aarch64 -endif - -TEMP_DIR := $(shell mktemp -d) - all: all-container image-info: @@ -58,30 +41,17 @@ all-push: $(addprefix sub-push-,$(ALL_ARCH)) container: .container-$(ARCH) .container-$(ARCH): - cp -r ./rootfs/* $(TEMP_DIR) - cd $(TEMP_DIR) && $(SED_I) "s|ARCH|$(QEMUARCH)|g" Dockerfile - -ifeq ($(ARCH),amd64) - # When building "normally" for amd64, remove the whole line, it has no part in the amd64 image - cd $(TEMP_DIR) && $(SED_I) "/CROSS_BUILD_/d" Dockerfile -else - # When cross-building, only the placeholder "CROSS_BUILD_" should be removed - curl -sSL https://github.com/multiarch/qemu-user-static/releases/download/$(QEMUVERSION)/x86_64_qemu-$(QEMUARCH)-static.tar.gz | tar -xz -C $(TEMP_DIR) - cd $(TEMP_DIR) && $(SED_I) "s/CROSS_BUILD_//g" Dockerfile -endif - - $(DOCKER) build --no-cache -t $(MULTI_ARCH_IMG):$(TAG) $(TEMP_DIR) + $(DOCKER) buildx build \ + --no-cache \ + --progress plain \ + --platform linux/$(ARCH) \ + -t $(MULTI_ARCH_IMG):$(TAG) rootfs ifeq ($(ARCH), amd64) # This is for to maintain the backward compatibility $(DOCKER) tag $(MULTI_ARCH_IMG):$(TAG) $(IMAGE):$(TAG) endif -.PHONY: register-qemu -register-qemu: - # Register /usr/bin/qemu-ARCH-static as the handler for binaries in multiple platforms - $(DOCKER) run --rm --privileged multiarch/qemu-user-static:register --reset - push: .push-$(ARCH) .push-$(ARCH): .container-$(ARCH) $(DOCKER) push $(MULTI_ARCH_IMG):$(TAG) diff --git a/images/nginx/rootfs/Dockerfile b/images/nginx/rootfs/Dockerfile index e4767dfe7..e4955d42a 100644 --- a/images/nginx/rootfs/Dockerfile +++ b/images/nginx/rootfs/Dockerfile @@ -15,8 +15,6 @@ FROM alpine:3.11 as builder -CROSS_BUILD_COPY qemu-ARCH-static /usr/bin/ - COPY . / RUN apk add -U bash \