Makefile 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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 node-test image.
  15. #
  16. # Usage:
  17. # [ARCH=amd64] [REGISTRY="staging-k8s.gcr.io"] [BIN_DIR="../../../../_output/bin"] make (build|push) VERSION={some_version_number e.g. 0.1}
  18. # SYSTEM_SPEC_NAME is the name of the system spec used for the node conformance
  19. # test. The specs are expected to be in SYSTEM_SPEC_DIR.
  20. SYSTEM_SPEC_NAME?=
  21. SYSTEM_SPEC_DIR?=../../system/specs
  22. # TODO(random-liu): Add this into release progress.
  23. REGISTRY?=staging-k8s.gcr.io
  24. ARCH?=amd64
  25. # BIN_DIR is the directory to find binaries, overwrite with ../../../../_output/bin
  26. # for local development.
  27. BIN_DIR?=../../../../_output/dockerized/bin/linux/${ARCH}
  28. TEMP_DIR:=$(shell mktemp -d)
  29. BASEIMAGE_amd64=debian:jessie
  30. BASEIMAGE_arm=arm32v7/debian:jessie
  31. BASEIMAGE_arm64=arm64v8/debian:jessie
  32. BASEIMAGE_ppc64le=ppc64le/debian:jessie
  33. BASEIMAGE?=${BASEIMAGE_${ARCH}}
  34. IMAGE_NAME:=${REGISTRY}/node-test
  35. COPY_SYSTEM_SPEC_FILE=
  36. SYSTEM_SPEC_FILE_PATH=
  37. ifneq ($(strip $(SYSTEM_SPEC_NAME)),)
  38. IMAGE_NAME:=${IMAGE_NAME}-${SYSTEM_SPEC_NAME}
  39. COPY_SYSTEM_SPEC_FILE="'COPY system-spec.yaml /usr/local/etc/'"
  40. SYSTEM_SPEC_FILE_PATH="'/usr/local/etc/system-spec.yaml'"
  41. endif
  42. all: build
  43. build:
  44. ifndef VERSION
  45. $(error VERSION is undefined)
  46. endif
  47. cp -r ./* ${TEMP_DIR}
  48. cp ${BIN_DIR}/ginkgo ${TEMP_DIR}
  49. cp ${BIN_DIR}/e2e_node.test ${TEMP_DIR}
  50. ifneq ($(strip $(SYSTEM_SPEC_NAME)),)
  51. cp ${SYSTEM_SPEC_DIR}/${SYSTEM_SPEC_NAME}.yaml ${TEMP_DIR}/system-spec.yaml
  52. endif
  53. cd ${TEMP_DIR} && sed -i.back \
  54. "s|BASEIMAGE|${BASEIMAGE}|g;\
  55. s|COPY_SYSTEM_SPEC_FILE|${COPY_SYSTEM_SPEC_FILE}|g;\
  56. s|SYSTEM_SPEC_NAME|${SYSTEM_SPEC_NAME}|g;\
  57. s|SYSTEM_SPEC_FILE_PATH|${SYSTEM_SPEC_FILE_PATH}|g" Dockerfile
  58. # Make scripts executable before they are copied into the Docker image. If we make them executable later, in another layer
  59. # they'll take up twice the space because the new executable binary differs from the old one, but everything is cached in layers.
  60. cd ${TEMP_DIR} && chmod a+rx \
  61. e2e_node.test \
  62. ginkgo
  63. docker build --pull -t ${IMAGE_NAME}-${ARCH}:${VERSION} ${TEMP_DIR}
  64. push: build
  65. docker push ${IMAGE_NAME}-${ARCH}:${VERSION}
  66. ifeq ($(ARCH),amd64)
  67. docker tag ${IMAGE_NAME}-${ARCH}:${VERSION} ${IMAGE_NAME}:${VERSION}
  68. docker push ${IMAGE_NAME}:${VERSION}
  69. endif
  70. .PHONY: all