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
# 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.
# this can take up to two hours.

View file

@ -50,7 +50,6 @@ apt -q=3 install \
curl \
make \
htop \
parallel \
software-properties-common --yes
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
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
@ -82,14 +78,11 @@ cd ingress-nginx/images/nginx
docker run --rm --privileged docker/binfmt:66f9012c56a8316f9244ffd7622d7c21c1f6f28d
docker buildx create --name ingress-nginx
docker buildx use ingress-nginx
docker buildx install
docker buildx create --use --name ingress-nginx
export TAG=$(git rev-parse HEAD)
echo "Building NGINX image in parallel:"
echo "
make sub-push-amd64
make sub-push-arm
make sub-push-arm64
" | parallel --joblog /tmp/log {} || cat /tmp/log
echo "Building NGINX images..."
make release

View file

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

View file

@ -43,7 +43,7 @@ export LUA_BRIDGE_TRACER_VERSION=0.1.1
export NGINX_INFLUXDB_VERSION=5b09391cb7b9a889687c0aa67964c06a2d933e8b
export GEOIP2_VERSION=3.3
export NGINX_AJP_VERSION=bf6cd93f2098b59260de8d494f0f4b1f11a84627
export RESTY_LUAROCKS_VERSION=3.2.1
export RESTY_LUAROCKS_VERSION=3.1.3
export LUAJIT_VERSION=9d5750d28478abfdcaefdfdc408f87752a21e431
export LUA_RESTY_BALANCER=0.03
export LUA_RESTY_CORE=0.1.17
@ -194,7 +194,7 @@ get_src 41378438c833e313a18869d0c4a72704b4835c30acaf7fd68013ab6732ff78a7 \
get_src 5f629a50ba22347c441421091da70fdc2ac14586619934534e5a0f8a1390a950 \
"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"
get_src 5d16e623d17d4f42cc64ea9cfb69ca960d313e12f5d828f785dd227cc483fcbd \