Makefile 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. # Copyright 2016 The Kubernetes Authors.
  2. #
  3. # Licensed under the Apache License, Version 2.0 (the "License");
  4. # you may not use this file except in compliance with the License.
  5. # You may obtain a copy of the License at
  6. #
  7. # http://www.apache.org/licenses/LICENSE-2.0
  8. #
  9. # Unless required by applicable law or agreed to in writing, software
  10. # distributed under the License is distributed on an "AS IS" BASIS,
  11. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. # See the License for the specific language governing permissions and
  13. # limitations under the License.
  14. .PHONY: build push all all-build all-push-images all-push push-manifest
  15. REGISTRY?="staging-k8s.gcr.io"
  16. IMAGE=$(REGISTRY)/debian-iptables
  17. TAG?=v12.0.1
  18. ARCH?=amd64
  19. ALL_ARCH = amd64 arm arm64 ppc64le s390x
  20. TEMP_DIR:=$(shell mktemp -d)
  21. BASEIMAGE?=k8s.gcr.io/debian-base-$(ARCH):v2.0.0
  22. # This option is for running docker manifest command
  23. export DOCKER_CLI_EXPERIMENTAL := enabled
  24. SUDO=$(if $(filter 0,$(shell id -u)),,sudo)
  25. build:
  26. cp ./* $(TEMP_DIR)
  27. cd $(TEMP_DIR) && sed -i "s|BASEIMAGE|$(BASEIMAGE)|g" Dockerfile
  28. ifneq ($(ARCH),amd64)
  29. # Register /usr/bin/qemu-ARCH-static as the handler for non-x86 binaries in the kernel
  30. $(SUDO) ../../third_party/multiarch/qemu-user-static/register/register.sh --reset
  31. endif
  32. docker build --pull -t $(IMAGE)-$(ARCH):$(TAG) $(TEMP_DIR)
  33. push: build
  34. docker push $(IMAGE)-$(ARCH):$(TAG)
  35. sub-build-%:
  36. $(MAKE) ARCH=$* build
  37. all-build: $(addprefix sub-build-,$(ALL_ARCH))
  38. sub-push-image-%:
  39. $(MAKE) ARCH=$* push
  40. all-push-images: $(addprefix sub-push-image-,$(ALL_ARCH))
  41. all-push: all-push-images push-manifest
  42. push-manifest:
  43. docker manifest create --amend $(IMAGE):$(TAG) $(shell echo $(ALL_ARCH) | sed -e "s~[^ ]*~$(IMAGE)\-&:$(TAG)~g")
  44. @for arch in $(ALL_ARCH); do docker manifest annotate --arch $${arch} ${IMAGE}:${TAG} ${IMAGE}-$${arch}:${TAG}; done
  45. docker manifest push --purge ${IMAGE}:${TAG}
  46. all: all-push