Makefile 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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. IMAGE=staging-k8s.gcr.io/kube-addon-manager
  15. ARCH?=amd64
  16. TEMP_DIR:=$(shell mktemp -d)
  17. VERSION=v9.0.2
  18. KUBECTL_VERSION?=v1.13.2
  19. BASEIMAGE=k8s.gcr.io/debian-base-$(ARCH):v1.0.0
  20. SUDO=$(if $(filter 0,$(shell id -u)),,sudo)
  21. .PHONY: build push
  22. all: build
  23. build:
  24. cp ./* $(TEMP_DIR)
  25. curl -sSL --retry 5 https://dl.k8s.io/release/$(KUBECTL_VERSION)/bin/linux/$(ARCH)/kubectl > $(TEMP_DIR)/kubectl
  26. chmod +x $(TEMP_DIR)/kubectl
  27. cd $(TEMP_DIR) && sed -i.back "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):$(VERSION) $(TEMP_DIR)
  33. push: build
  34. docker push $(IMAGE)-$(ARCH):$(VERSION)
  35. ifeq ($(ARCH),amd64)
  36. # Backward compatibility. TODO: deprecate this image tag
  37. docker rmi $(IMAGE):$(VERSION) 2>/dev/null || true
  38. docker tag $(IMAGE)-$(ARCH):$(VERSION) $(IMAGE):$(VERSION)
  39. docker push $(IMAGE):$(VERSION)
  40. endif
  41. clean:
  42. docker rmi -f $(IMAGE)-$(ARCH):$(VERSION)