Makefile 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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. # Build the hyperkube image.
  15. #
  16. # Usage:
  17. # [ARCH=amd64] [REGISTRY="staging-k8s.gcr.io"] make (build|push) VERSION={some_released_version_of_kubernetes}
  18. REGISTRY?=staging-k8s.gcr.io
  19. ARCH?=amd64
  20. OUT_DIR?=_output
  21. HYPERKUBE_BIN?=$(shell pwd)/../../../$(OUT_DIR)/dockerized/bin/linux/$(ARCH)/hyperkube
  22. BASEIMAGE=k8s.gcr.io/debian-hyperkube-base-$(ARCH):0.12.1
  23. TEMP_DIR:=$(shell mktemp -d -t hyperkubeXXXXXX)
  24. all: build
  25. build:
  26. ifndef VERSION
  27. $(error VERSION is undefined)
  28. endif
  29. cp -r ./* ${TEMP_DIR}
  30. cp ${HYPERKUBE_BIN} ${TEMP_DIR}
  31. chmod a+rx ${TEMP_DIR}/hyperkube
  32. cd ${TEMP_DIR} && sed -i.back "s|BASEIMAGE|${BASEIMAGE}|g" Dockerfile
  33. docker build --pull -t ${REGISTRY}/hyperkube-${ARCH}:${VERSION} ${TEMP_DIR}
  34. rm -rf "${TEMP_DIR}"
  35. push: build
  36. docker push ${REGISTRY}/hyperkube-${ARCH}:${VERSION}
  37. ifeq ($(ARCH),amd64)
  38. docker rmi ${REGISTRY}/hyperkube:${VERSION} 2>/dev/null || true
  39. docker tag ${REGISTRY}/hyperkube-${ARCH}:${VERSION} ${REGISTRY}/hyperkube:${VERSION}
  40. docker push ${REGISTRY}/hyperkube:${VERSION}
  41. endif
  42. .PHONY: build push all