Cleanup docker build of nginx image (#4925)

This commit is contained in:
Manuel Alejandro de Brito Fontes 2020-01-14 13:57:44 -03:00 committed by GitHub
parent c86e4e0d9a
commit 26f574dc27
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 36 additions and 47 deletions

View file

@ -38,7 +38,11 @@ if [ ! -f "${ENV_FILE}" ]; then
fi fi
# build local terraform image to build nginx # build local terraform image to build nginx
docker build -t build-nginx-terraform $DIR/images/nginx export DOCKER_CLI_EXPERIMENTAL=enabled
docker buildx build \
--no-cache \
--platform linux/amd64 \
--tag build-nginx-terraform $DIR/images/nginx
# build nginx and publish docker images to quay.io. # build nginx and publish docker images to quay.io.
# this can take up to two hours. # this can take up to two hours.

View file

@ -50,7 +50,6 @@ apt -q=3 install \
curl \ curl \
make \ make \
htop \ htop \
parallel \
software-properties-common --yes software-properties-common --yes
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
@ -66,9 +65,6 @@ apt -q=3 install docker-ce --yes
export DOCKER_CLI_EXPERIMENTAL=enabled 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 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 curl -sL -o /usr/local/bin/gimme https://raw.githubusercontent.com/travis-ci/gimme/master/gimme
@ -82,14 +78,11 @@ cd ingress-nginx/images/nginx
docker run --rm --privileged docker/binfmt:66f9012c56a8316f9244ffd7622d7c21c1f6f28d docker run --rm --privileged docker/binfmt:66f9012c56a8316f9244ffd7622d7c21c1f6f28d
docker buildx create --name ingress-nginx docker buildx install
docker buildx use ingress-nginx
docker buildx create --use --name ingress-nginx
export TAG=$(git rev-parse HEAD) export TAG=$(git rev-parse HEAD)
echo "Building NGINX image in parallel:" echo "Building NGINX images..."
echo " make release
make sub-push-amd64
make sub-push-arm
make sub-push-arm64
" | parallel --joblog /tmp/log {} || cat /tmp/log

View file

@ -15,53 +15,45 @@
# 0.0.0 shouldn't clobber any released builds # 0.0.0 shouldn't clobber any released builds
TAG ?= 0.96 TAG ?= 0.96
REGISTRY ?= quay.io/kubernetes-ingress-controller REGISTRY ?= quay.io/kubernetes-ingress-controller
ARCH ?= $(shell go env GOARCH)
DOCKER ?= docker
ALL_ARCH = amd64 arm arm64
IMGNAME = nginx IMGNAME = nginx
IMAGE = $(REGISTRY)/$(IMGNAME) IMAGE = $(REGISTRY)/$(IMGNAME)
MULTI_ARCH_IMG = $(IMAGE)-$(ARCH)
all: all-container PLATFORMS = amd64 arm arm64
image-info: EMPTY :=
echo -n '{"image":"$(IMAGE)","tag":"$(TAG)"}' SPACE := $(EMPTY) $(EMPTY)
COMMA := ,
sub-container-%: all: container
$(MAKE) ARCH=$* container
sub-push-%: container:
$(MAKE) ARCH=$* push DOCKER_CLI_EXPERIMENTAL=enabled docker buildx build \
all-container: $(addprefix sub-container-,$(ALL_ARCH))
all-push: $(addprefix sub-push-,$(ALL_ARCH))
container: .container-$(ARCH)
.container-$(ARCH):
$(DOCKER) buildx build \
--no-cache \ --no-cache \
--progress plain \ --progress plain \
--platform linux/$(ARCH) \ --platform $(subst $(SPACE),$(COMMA),$(PLATFORMS)) \
-t $(MULTI_ARCH_IMG):$(TAG) rootfs --tag $(IMAGE):$(TAG) rootfs
# https://github.com/docker/buildx/issues/59
$(foreach PLATFORM,$(PLATFORMS), \
DOCKER_CLI_EXPERIMENTAL=enabled docker buildx build \
--load \
--progress plain \
--platform $(PLATFORM) \
--tag $(IMAGE)-$(PLATFORM):$(TAG) rootfs;)
ifeq ($(ARCH), amd64) ifeq ($(ARCH), amd64)
# This is for to maintain the backward compatibility # This is for to maintain the backward compatibility
$(DOCKER) tag $(MULTI_ARCH_IMG):$(TAG) $(IMAGE):$(TAG) docker tag $(MULTI_ARCH_IMG):$(TAG) $(IMAGE):$(TAG)
endif endif
push: .push-$(ARCH) push: container
.push-$(ARCH): .container-$(ARCH) $(foreach PLATFORM,$(PLATFORMS), \
$(DOCKER) push $(MULTI_ARCH_IMG):$(TAG) docker push $(IMAGE)-$(PLATFORM):$(TAG);)
ifeq ($(ARCH), amd64) ifeq ($(ARCH), amd64)
$(DOCKER) push $(IMAGE):$(TAG) docker push $(IMAGE):$(TAG)
endif endif
clean: $(addprefix sub-clean-,$(ALL_ARCH)) release: push
sub-clean-%:
$(DOCKER) rmi -f $(IMAGE)-$*:$(TAG) || true
release: all-container all-push
echo "done" echo "done"

View file

@ -43,7 +43,7 @@ export LUA_BRIDGE_TRACER_VERSION=0.1.1
export NGINX_INFLUXDB_VERSION=5b09391cb7b9a889687c0aa67964c06a2d933e8b export NGINX_INFLUXDB_VERSION=5b09391cb7b9a889687c0aa67964c06a2d933e8b
export GEOIP2_VERSION=3.3 export GEOIP2_VERSION=3.3
export NGINX_AJP_VERSION=bf6cd93f2098b59260de8d494f0f4b1f11a84627 export NGINX_AJP_VERSION=bf6cd93f2098b59260de8d494f0f4b1f11a84627
export RESTY_LUAROCKS_VERSION=3.2.1 export RESTY_LUAROCKS_VERSION=3.1.3
export LUAJIT_VERSION=9d5750d28478abfdcaefdfdc408f87752a21e431 export LUAJIT_VERSION=9d5750d28478abfdcaefdfdc408f87752a21e431
export LUA_RESTY_BALANCER=0.03 export LUA_RESTY_BALANCER=0.03
export LUA_RESTY_CORE=0.1.17 export LUA_RESTY_CORE=0.1.17
@ -194,7 +194,7 @@ get_src 41378438c833e313a18869d0c4a72704b4835c30acaf7fd68013ab6732ff78a7 \
get_src 5f629a50ba22347c441421091da70fdc2ac14586619934534e5a0f8a1390a950 \ get_src 5f629a50ba22347c441421091da70fdc2ac14586619934534e5a0f8a1390a950 \
"https://github.com/yaoweibin/nginx_ajp_module/archive/$NGINX_AJP_VERSION.tar.gz" "https://github.com/yaoweibin/nginx_ajp_module/archive/$NGINX_AJP_VERSION.tar.gz"
get_src f27e20c9cdb3ffb991ccdb85796c36a0690566676f8e1a59b0d0ee6598907d04 \ get_src c573435f495aac159e34eaa0a3847172a2298eb6295fcdc35d565f9f9b990513 \
"https://luarocks.github.io/luarocks/releases/luarocks-${RESTY_LUAROCKS_VERSION}.tar.gz" "https://luarocks.github.io/luarocks/releases/luarocks-${RESTY_LUAROCKS_VERSION}.tar.gz"
get_src 5d16e623d17d4f42cc64ea9cfb69ca960d313e12f5d828f785dd227cc483fcbd \ get_src 5d16e623d17d4f42cc64ea9cfb69ca960d313e12f5d828f785dd227cc483fcbd \