Makefile 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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 conformance image.
  15. #
  16. # Usage:
  17. # [ARCH=amd64] [REGISTRY="k8s.gcr.io"] make (build|push) VERSION={some_released_version_of_kubernetes}
  18. REGISTRY?=k8s.gcr.io
  19. ARCH?=amd64
  20. OUT_DIR?=_output
  21. LOCAL_OUTPUT_PATH=$(shell pwd)/../../../$(OUT_DIR)/local/bin/linux/$(ARCH)
  22. DOCKERIZED_OUTPUT_PATH=$(shell pwd)/../../../$(OUT_DIR)/dockerized/bin/linux/$(ARCH)
  23. GINKGO_BIN?=$(shell test -f $(LOCAL_OUTPUT_PATH)/ginkgo && echo $(LOCAL_OUTPUT_PATH)/ginkgo || echo $(DOCKERIZED_OUTPUT_PATH)/ginkgo)
  24. KUBECTL_BIN?=$(shell test -f $(LOCAL_OUTPUT_PATH)/kubectl && echo $(LOCAL_OUTPUT_PATH)/kubectl || echo $(DOCKERIZED_OUTPUT_PATH)/kubectl)
  25. E2E_TEST_BIN?=$(shell test -f $(LOCAL_OUTPUT_PATH)/e2e.test && echo $(LOCAL_OUTPUT_PATH)/e2e.test || echo $(DOCKERIZED_OUTPUT_PATH)/e2e.test)
  26. E2E_GO_RUNNER_BIN?=$(shell test -f $(LOCAL_OUTPUT_PATH)/go-runner && echo $(LOCAL_OUTPUT_PATH)/go-runner || echo $(DOCKERIZED_OUTPUT_PATH)/go-runner)
  27. CLUSTER_DIR?=$(shell pwd)/../../../cluster/
  28. BASEIMAGE=k8s.gcr.io/debian-hyperkube-base-$(ARCH):0.12.1
  29. TEMP_DIR:=$(shell mktemp -d -t conformanceXXXXXX)
  30. all: build
  31. build:
  32. ifndef VERSION
  33. $(error VERSION is undefined)
  34. endif
  35. cp -r ./* ${TEMP_DIR}
  36. cp ${GINKGO_BIN} ${TEMP_DIR}
  37. cp ${KUBECTL_BIN} ${TEMP_DIR}
  38. cp ${E2E_TEST_BIN} ${TEMP_DIR}
  39. cp ${E2E_GO_RUNNER_BIN} ${TEMP_DIR}/gorunner
  40. cp -r ${CLUSTER_DIR} ${TEMP_DIR}/cluster
  41. chmod a+rx ${TEMP_DIR}/ginkgo
  42. chmod a+rx ${TEMP_DIR}/kubectl
  43. chmod a+rx ${TEMP_DIR}/e2e.test
  44. chmod a+rx ${TEMP_DIR}/gorunner
  45. cd ${TEMP_DIR} && sed -i.back "s|BASEIMAGE|${BASEIMAGE}|g" Dockerfile
  46. docker build --pull -t ${REGISTRY}/conformance-${ARCH}:${VERSION} ${TEMP_DIR}
  47. rm -rf "${TEMP_DIR}"
  48. push: build
  49. docker push ${REGISTRY}/conformance-${ARCH}:${VERSION}
  50. ifeq ($(ARCH),amd64)
  51. docker rmi ${REGISTRY}/conformance:${VERSION} 2>/dev/null || true
  52. docker tag ${REGISTRY}/conformance-${ARCH}:${VERSION} ${REGISTRY}/conformance:${VERSION}
  53. docker push ${REGISTRY}/conformance:${VERSION}
  54. endif
  55. .PHONY: build push all