-
Notifications
You must be signed in to change notification settings - Fork 14
/
Makefile
75 lines (62 loc) · 2.24 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
SHELL = /usr/bin/env bash -o pipefail
.SHELLFLAGS = -ec
CI ?= false
PROJECT_DIR := $(shell dirname $(abspath $(lastword $(MAKEFILE_LIST))))
CRUISE_CONTROL_VERSION ?= 2.5.123
CRUISE_CONTROL_UI_GIT_REF ?= b1208a6f020c21ff967297814c2e893eed3f3183
DOCKER_COMPOSE_PROJECT_NAME := "docker-cruise-control"
DOCKER_COMPOSE_PROJECT_DIR := "./deploy"
DOCKER_COMPOSE_TIMEOUT := 120
GIT_SHA := $(shell git rev-parse HEAD)
GIT_SHA_SHORT := $(shell git rev-parse --short HEAD)
GIT_REF := $(shell git describe --dirty --always)
export CRUISE_CONTROL_IMAGE ?= "ghcr.io/banzaicloud/cruise-control:$(GIT_SHA_SHORT)"
##@ General
.PHONY: help
help: ## Display this help.
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n"} /^[a-zA-Z_0-9-]+:.*?##/ { printf " \033[36m%-20s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)
##@ Development
.PHONY: build
build: ## Build Cruise Control container image
@docker build \
--build-arg "CRUISE_CONTROL_VERSION=$(CRUISE_CONTROL_VERSION)" \
--build-arg "CRUISE_CONTROL_UI_GIT_REF=$(CRUISE_CONTROL_UI_GIT_REF)" \
--tag $(CRUISE_CONTROL_IMAGE) \
--label "org.opencontainers.image.version=$(CRUISE_CONTROL_VERSION)" \
--label "org.opencontainers.image.revision=$(GIT_SHA)" \
--label "org.opencontainers.image.ref.name=$(GIT_REF)" \
.
.PHONY: start
start: ## Start test environment
@docker compose \
--project-name "$(DOCKER_COMPOSE_PROJECT_NAME)" \
--project-directory "$(DOCKER_COMPOSE_PROJECT_DIR)" \
up -d \
--remove-orphans \
--timeout "$(DOCKER_COMPOSE_TIMEOUT)" \
--wait
.PHONY: stop
stop: ## Stop test environment
@docker compose \
--project-name "$(DOCKER_COMPOSE_PROJECT_NAME)" \
--project-directory "$(DOCKER_COMPOSE_PROJECT_DIR)" \
down \
--remove-orphans \
--volumes \
--timeout "$(DOCKER_COMPOSE_TIMEOUT)"
.PHONY: test
test: ## Run tests
@./test.sh
## Skip building container image in CI
ifeq ($(CI),true)
test:
else
test: build
endif
##@ CI
.PHONY: cruise-control-version
cruise-control-version: ## Print Cruise Control version
@printf 'version=%s\n' "$(CRUISE_CONTROL_VERSION)"
.PHONY: cruise-control-version
cruise-control-ui-version: ## Print Cruise Control UI version
@printf 'version=%s\n' "$(CRUISE_CONTROL_UI_GIT_REF)"