From d46283b6b14d1b7ffe007469672dbfa5b0d61fd0 Mon Sep 17 00:00:00 2001 From: Manjunath A Kumatagi Date: Wed, 19 Sep 2018 09:46:07 +0530 Subject: [PATCH] Manifest for debian-iptables image --- build/debian-iptables/Makefile | 31 ++++++++++++++++++++++++++----- build/debian-iptables/README.md | 14 +++----------- 2 files changed, 29 insertions(+), 16 deletions(-) diff --git a/build/debian-iptables/Makefile b/build/debian-iptables/Makefile index 582df5d260d..8c793db5aac 100644 --- a/build/debian-iptables/Makefile +++ b/build/debian-iptables/Makefile @@ -12,16 +12,20 @@ # See the License for the specific language governing permissions and # limitations under the License. -.PHONY: build push +.PHONY: build push all all-build all-push-images all-push push-manifest REGISTRY?="staging-k8s.gcr.io" -IMAGE=debian-iptables +IMAGE=$(REGISTRY)/debian-iptables TAG?=v10.2 ARCH?=amd64 +ALL_ARCH = amd64 arm arm64 ppc64le s390x TEMP_DIR:=$(shell mktemp -d) BASEIMAGE?=k8s.gcr.io/debian-base-$(ARCH):0.3.2 +# This option is for running docker manifest command +export DOCKER_CLI_EXPERIMENTAL := enabled + build: cp ./* $(TEMP_DIR) cd $(TEMP_DIR) && sed -i "s|BASEIMAGE|$(BASEIMAGE)|g" Dockerfile @@ -31,9 +35,26 @@ ifneq ($(ARCH),amd64) docker run --rm --privileged multiarch/qemu-user-static:register --reset endif - docker build --pull -t $(REGISTRY)/$(IMAGE)-$(ARCH):$(TAG) $(TEMP_DIR) + docker build --pull -t $(IMAGE)-$(ARCH):$(TAG) $(TEMP_DIR) push: build - docker push $(REGISTRY)/$(IMAGE)-$(ARCH):$(TAG) + docker push $(IMAGE)-$(ARCH):$(TAG) -all: push +sub-build-%: + $(MAKE) ARCH=$* build + +all-build: $(addprefix sub-build-,$(ALL_ARCH)) + +sub-push-image-%: + $(MAKE) ARCH=$* push + +all-push-images: $(addprefix sub-push-image-,$(ALL_ARCH)) + +all-push: all-push-images push-manifest + +push-manifest: + docker manifest create --amend $(IMAGE):$(TAG) $(shell echo $(ALL_ARCH) | sed -e "s~[^ ]*~$(IMAGE)\-&:$(TAG)~g") + @for arch in $(ALL_ARCH); do docker manifest annotate --arch $${arch} ${IMAGE}:${TAG} ${IMAGE}-$${arch}:${TAG}; done + docker manifest push ${IMAGE}:${TAG} + +all: all-push diff --git a/build/debian-iptables/README.md b/build/debian-iptables/README.md index a961cd6f6df..6900a857ed2 100644 --- a/build/debian-iptables/README.md +++ b/build/debian-iptables/README.md @@ -9,24 +9,16 @@ This image is compiled for multiple architectures. If you're editing the Dockerfile or some other thing, please bump the `TAG` in the Makefile. ```console -# Build for linux/amd64 (default) -$ make push ARCH=amd64 +Build and push images for all the architectures +$ make all-push # ---> staging-k8s.gcr.io/debian-iptables-amd64:TAG - -$ make push ARCH=arm # ---> staging-k8s.gcr.io/debian-iptables-arm:TAG - -$ make push ARCH=arm64 # ---> staging-k8s.gcr.io/debian-iptables-arm64:TAG - -$ make push ARCH=ppc64le # ---> staging-k8s.gcr.io/debian-iptables-ppc64le:TAG - -$ make push ARCH=s390x # ---> staging-k8s.gcr.io/debian-iptables-s390x:TAG ``` -If you don't want to push the images, run `make` or `make build` instead +If you don't want to push the images, run `make build ARCH={target_arch}` or `make all-build` instead [![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/build/debian-iptables/README.md?pixel)]()