A declarative framework for resilient Kubernetes deployment.
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.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. # Copyright 2018 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. DOCKER_REGISTRY ?= quay.io
  16. HELM := $(BUILD_DIR)/helm
  17. IMAGE_PREFIX ?= airshipit
  18. IMAGE_NAME ?= promenade
  19. IMAGE_TAG ?= latest
  20. PROXY ?= http://proxy.foo.com:8000
  21. NO_PROXY ?= localhost,127.0.0.1,.svc.cluster.local
  22. USE_PROXY ?= false
  23. PUSH_IMAGE ?= false
  24. # use this variable for image labels added in internal build process
  25. LABEL ?= org.airshipit.build=community
  26. COMMIT ?= $(shell git rev-parse HEAD)
  27. PYTHON = python3
  28. CHARTS := $(patsubst charts/%/.,%,$(wildcard charts/*/.))
  29. IMAGE := ${DOCKER_REGISTRY}/${IMAGE_PREFIX}/${IMAGE_NAME}:${IMAGE_TAG}
  30. PYTHON_BASE_IMAGE ?= python:3.6
  31. HELM_PIDFILE ?= $(abspath ./.helm-pid)
  32. CHARTS := $(patsubst charts/%/.,%,$(wildcard charts/*/.))
  33. .PHONY: all
  34. all: charts lint
  35. .PHONY: tests
  36. tests: external-deps gate-lint
  37. tox
  38. .PHONY: tests-security
  39. tests-security:
  40. tox -e bandit
  41. .PHONY: docs
  42. docs:
  43. tox -e docs
  44. .PHONY: tests-unit
  45. tests-unit: external-deps
  46. tox -e py35
  47. .PHONY: external-deps
  48. external-deps:
  49. ./tools/install-external-deps.sh
  50. .PHONY: tests-pep8
  51. tests-pep8:
  52. tox -e pep8
  53. chartbanner:
  54. @echo Building charts: $(CHARTS)
  55. .PHONY: charts
  56. charts: $(CHARTS)
  57. @echo Done building charts.
  58. .PHONY: helm-init
  59. helm-init: $(addprefix helm-init-,$(CHARTS))
  60. .PHONY: helm-init-%
  61. helm-init-%: helm-serve
  62. @echo Initializing chart $*
  63. cd charts;if [ -s $*/requirements.yaml ]; then echo "Initializing $*";$(HELM) dep up $*; fi
  64. .PHONY: lint
  65. lint: helm-lint gate-lint
  66. .PHONY: gate-lint
  67. gate-lint: gate-lint-deps
  68. tox -e gate-lint
  69. .PHONY: gate-lint-deps
  70. gate-lint-deps:
  71. sudo apt-get install -y --no-install-recommends shellcheck
  72. .PHONY: helm-lint
  73. helm-lint: $(addprefix helm-lint-,$(CHARTS))
  74. .PHONY: helm-lint-%
  75. helm-lint-%: helm-install helm-init-%
  76. @echo Linting chart $*
  77. cd charts;$(HELM) lint $*
  78. .PHONY: images
  79. images: check-docker build_promenade
  80. .PHONY: check-docker
  81. check-docker:
  82. @if [ -z $$(which docker) ]; then \
  83. echo "Missing \`docker\` client which is required for development"; \
  84. exit 2; \
  85. fi
  86. .PHONY: dry-run
  87. dry-run: $(addprefix dry-run-,$(CHARTS))
  88. .PHONY: dry-run-%
  89. dry-run-%: helm-lint-%
  90. echo Running Dry-Run on chart $*
  91. cd charts;$(HELM) template --set pod.resources.enabled=true $*
  92. .PHONY: $(CHARTS)
  93. $(CHARTS): $(addprefix dry-run-,$(CHARTS)) chartbanner
  94. $(HELM) package -d charts charts/$@
  95. .PHONY: build_promenade
  96. build_promenade:
  97. ifeq ($(USE_PROXY), true)
  98. docker build --network host -t $(IMAGE) --label $(LABEL) \
  99. --label "org.opencontainers.image.revision=$(COMMIT)" \
  100. --label "org.opencontainers.image.created=$(shell date --rfc-3339=seconds --utc)" \
  101. --label "org.opencontainers.image.title=$(IMAGE_NAME)" \
  102. -f ./Dockerfile \
  103. --build-arg FROM=$(PYTHON_BASE_IMAGE) \
  104. --build-arg http_proxy=$(PROXY) \
  105. --build-arg https_proxy=$(PROXY) \
  106. --build-arg HTTP_PROXY=$(PROXY) \
  107. --build-arg HTTPS_PROXY=$(PROXY) \
  108. --build-arg no_proxy=$(NO_PROXY) \
  109. --build-arg NO_PROXY=$(NO_PROXY) .
  110. else
  111. docker build --network host -t $(IMAGE) --label $(LABEL) \
  112. --label "org.opencontainers.image.revision=$(COMMIT)" \
  113. --label "org.opencontainers.image.created=$(shell date --rfc-3339=seconds --utc)" \
  114. --label "org.opencontainers.image.title=$(IMAGE_NAME)" \
  115. -f ./Dockerfile \
  116. --build-arg FROM=$(PYTHON_BASE_IMAGE) .
  117. endif
  118. ifeq ($(PUSH_IMAGE), true)
  119. docker push $(IMAGE)
  120. endif
  121. .PHONY: helm-serve
  122. helm-serve: helm-install
  123. ./tools/helm_tk.sh $(HELM) $(HELM_PIDFILE)
  124. .PHONY: clean
  125. clean:
  126. rm -f charts/*.tgz
  127. rm -f charts/*/requirements.lock
  128. rm -rf charts/*/charts
  129. # Install helm binary
  130. .PHONY: helm-install
  131. helm-install:
  132. tools/helm_install.sh $(HELM)