A cluster lifecycle orchestrator for Airship.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Makefile 4.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. # Copyright 2017 AT&T Intellectual Property. All other rights reserved.
  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_DIR := $(shell mktemp -d)
  15. BUILD_CTX ?= src/bin
  16. IMAGE_PREFIX ?= airshipit
  17. IMAGE_TAG ?= latest
  18. IMAGE_NAME := airflow shipyard
  19. # use this variable for image labels added in internal build process
  20. LABEL ?= org.airshipit.build=community
  21. COMMIT ?= $(shell git rev-parse HEAD)
  22. DOCKER_REGISTRY ?= quay.io
  23. PUSH_IMAGE ?= false
  24. HELM := $(BUILD_DIR)/helm
  25. PROXY ?= http://proxy.foo.com:8000
  26. NO_PROXY ?= localhost,127.0.0.1,.svc.cluster.local
  27. USE_PROXY ?= false
  28. DISTRO_BASE_IMAGE ?=
  29. DISTRO ?= ubuntu_xenial
  30. IMAGE:=${DOCKER_REGISTRY}/${IMAGE_PREFIX}/$(IMAGE_NAME):${IMAGE_TAG}-${DISTRO}
  31. IMAGE_DIR:=images/$(IMAGE_NAME)
  32. .PHONY: images
  33. #Build all images in the list
  34. images: $(IMAGE_NAME)
  35. #Build and run all images in list
  36. #sudo make images IMAGE_NAME=airflow will Build and Run airflow
  37. #sudo make images will build and run airflow and shipyard
  38. $(IMAGE_NAME):
  39. @echo
  40. @echo "===== Processing [$@] image ====="
  41. @make build IMAGE=${DOCKER_REGISTRY}/${IMAGE_PREFIX}/$@:${IMAGE_TAG}-${DISTRO} IMAGE_DIR=images/$@ IMAGE_NAME=$@
  42. @make run IMAGE=${DOCKER_REGISTRY}/${IMAGE_PREFIX}/$@:${IMAGE_TAG}-${DISTRO} SCRIPT=./tools/$@_image_run.sh
  43. # Build all docker images for this project
  44. # Create tgz of the chart
  45. .PHONY: charts
  46. charts: clean helm-init
  47. $(HELM) dep up charts/shipyard
  48. $(HELM) package charts/shipyard
  49. # Perform Linting
  50. .PHONY: lint
  51. lint: pep8 helm_lint build_docs
  52. # Dry run templating of chart
  53. .PHONY: dry-run
  54. dry-run: clean helm-init
  55. $(HELM) template charts/shipyard
  56. .PHONY: security
  57. security:
  58. cd $(BUILD_CTX)/shipyard_client; tox -e bandit
  59. cd $(BUILD_CTX)/shipyard_airflow; tox -e bandit
  60. .PHONY: tests
  61. tests:
  62. cd $(BUILD_CTX)/shipyard_client; tox
  63. cd $(BUILD_CTX)/shipyard_airflow; tox
  64. # Make targets intended for use by the primary targets above.
  65. .PHONY: run
  66. run:
  67. USE_PROXY=$(USE_PROXY) PROXY=$(PROXY) $(SCRIPT) $(IMAGE)
  68. _BASE_IMAGE_ARG := $(if $(DISTRO_BASE_IMAGE),--build-arg FROM="${DISTRO_BASE_IMAGE}" ,)
  69. .PHONY: build
  70. build:
  71. ifeq ($(USE_PROXY), true)
  72. docker build --network host -t $(IMAGE) --label $(LABEL) \
  73. --label "org.opencontainers.image.revision=$(COMMIT)" \
  74. --label "org.opencontainers.image.created=$(shell date --rfc-3339=seconds --utc)" \
  75. --label "org.opencontainers.image.title=$(IMAGE_NAME)" \
  76. -f $(IMAGE_DIR)/Dockerfile.$(DISTRO) \
  77. $(_BASE_IMAGE_ARG) \
  78. --build-arg http_proxy=$(PROXY) \
  79. --build-arg https_proxy=$(PROXY) \
  80. --build-arg HTTP_PROXY=$(PROXY) \
  81. --build-arg HTTPS_PROXY=$(PROXY) \
  82. --build-arg no_proxy=$(NO_PROXY) \
  83. --build-arg NO_PROXY=$(NO_PROXY) \
  84. --build-arg ctx_base=$(BUILD_CTX) .
  85. else
  86. docker build --network host -t $(IMAGE) --label $(LABEL) \
  87. --label "org.opencontainers.image.revision=$(COMMIT)" \
  88. --label "org.opencontainers.image.created=$(shell date --rfc-3339=seconds --utc)" \
  89. --label "org.opencontainers.image.title=$(IMAGE_NAME)" \
  90. -f $(IMAGE_DIR)/Dockerfile.$(DISTRO) \
  91. $(_BASE_IMAGE_ARG) \
  92. --build-arg ctx_base=$(BUILD_CTX) .
  93. endif
  94. ifeq ($(PUSH_IMAGE), true)
  95. docker push $(IMAGE)
  96. endif
  97. .PHONY: clean
  98. clean:
  99. rm -rf build
  100. rm -rf doc/build
  101. cd $(BUILD_CTX)/shipyard_client; rm -rf build
  102. cd $(BUILD_CTX)/shipyard_airflow; rm -rf build
  103. .PHONY: pep8
  104. pep8:
  105. cd $(BUILD_CTX)/shipyard_client; tox -e pep8
  106. cd $(BUILD_CTX)/shipyard_airflow; tox -e pep8
  107. .PHONY: helm_lint
  108. helm_lint: clean helm-init
  109. $(HELM) lint charts/shipyard
  110. # Initialize local helm config
  111. .PHONY: helm-init
  112. helm-init: helm-install
  113. tools/helm_tk.sh $(HELM)
  114. # Install helm binary
  115. .PHONY: helm-install
  116. helm-install:
  117. tools/helm_install.sh $(HELM)
  118. .PHONY: docs
  119. docs: clean build_docs
  120. .PHONY: build_docs
  121. build_docs:
  122. tox -e docs