generated from unleashed/rust-template
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
128 lines (98 loc) · 4.38 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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
MKFILE_PATH := $(abspath $(lastword $(MAKEFILE_LIST)))
PROJECT_PATH := $(patsubst %/,%,$(dir $(MKFILE_PATH)))
COMPOSEFILE := $(PROJECT_PATH)/compose/docker-compose.yaml
DOCKER_COMPOSE := docker-compose -f $(COMPOSEFILE)
OPEN_APP ?= xdg-open
.PHONY: fetch-protos doc help up up-container up-local stop status top kill \
down proxy-info proxy ingress-helper ingress-url ingress-open \
ingress-admin-url ingress-admin-open curl
.PHONY: fetch_protos
fetch_protos: ## Fetch protobuf files
$(Q) git submodule update --init --recursive
.PHONY: update_protos
update_protos: ## Update Protobuf files
$(Q) git submodule update --remote --merge
.PHONY: wasm_build
wasm_build: ## Build wasm filter
$(Q) cargo build --target=wasm32-unknown-unknown --lib --manifest-path $(PROJECT_PATH)/wasm_filter/Cargo.toml
$(Q) cp -fv $(PROJECT_PATH)/wasm_filter/target/wasm32-unknown-unknown/debug/filter.wasm $(PROJECT_PATH)/static/
.PHONY: auth-build
auth-build: ## Build 3scale auth wasm filter
$(MAKE) -C $(PROJECT_PATH)/threescale-wasm-auth build
mkdir -p $(PROJECT_PATH)/compose/control-plane/static
cp -fv $(PROJECT_PATH)/threescale-wasm-auth/compose/wasm/threescale_wasm_auth.wasm $(PROJECT_PATH)/static/
.PHONY: auth-build-clean
auth-build-clean: ## Build 3scale auth wasm filter
rm -f $(PROJECT_PATH)/compose/control-plane/static/threescale_wasm_auth.wasm
$(MAKE) -C $(PROJECT_PATH)/threescale-wasm-auth clean
doc: ## open project documentation
$(Q) cargo doc --open
up-container: export CONTROL_PLANE_LOCAL=control-plane-alt
up-container: export CONTROL_PLANE_DOCKER=control-plane-main
up-container: # Launch docker-compose with the control-plane as a container
@echo "Launch mode: control-plane in container (use LOCAL_CP=y to use localhost)"
$(DOCKER_COMPOSE) up
up-local: export CONTROL_PLANE_LOCAL=control-plane-main
up-local: export CONTROL_PLANE_DOCKER=control-plane-alt
up-local: # Launch docker-compose with the control-plane as a (pre-existing) local process
@echo "Launch mode: control-plane in localhost (use LOCAL_CP=n to use a container)"
$(DOCKER_COMPOSE) up
up-deps =
ifeq ($(LOCAL_CP),y)
up-deps = up-local
else
up-deps = up-container
endif
up: $(up-deps) ## Start docker-compose containers
stop: ## Stop docker-compose containers
$(DOCKER_COMPOSE) stop
.PHONY: build
build: ## Build containers
$(DOCKER_COMPOSE) build
status: ## Status of docker-compose containers
$(DOCKER_COMPOSE) ps
top: ## Show runtime information about docker-compose containers
$(DOCKER_COMPOSE) top
kill: ## Force-stop docker-compose containers
$(DOCKER_COMPOSE) kill
down: ## Stop and remove containers and other docker-compose resources
$(DOCKER_COMPOSE) down
proxy-info: export INDEX?=1
proxy-info: ## Obtain the local host address and port for a service (use SERVICE, PORT and optionally INDEX)
$(DOCKER_COMPOSE) port --index $(INDEX) $(SERVICE) $(PORT)
proxy-url: export INDEX?=1
proxy-url: export SCHEME?=http
proxy-url: ## Obtain a URL for the given service (use SERVICE, PORT and optionally INDEX)
$(DOCKER_COMPOSE) port --index $(INDEX) $(SERVICE) $(PORT)
proxy: export INDEX?=1
proxy: export SCHEME?=http
proxy: LOCALURL=$(shell $(DOCKER_COMPOSE) port --index $(INDEX) $(SERVICE) $(PORT))
proxy: ## Open service and port in a browser (same as proxy-info, but optionally define SCHEME and OPEN_APP)
$(OPEN_APP) $(SCHEME)://$(LOCALURL)
ingress-helper: export SERVICE?=ingress
ingress-helper: export PORT?=80
ingress-helper: export TARGET?=proxy-url
ingress-helper:
$(MAKE) $(TARGET)
ingress-url: ## Show the ingress URL
$(MAKE) ingress-helper
ingress-open: export TARGET?=proxy
ingress-open: ## Open the ingress URL
$(MAKE) ingress-helper
ingress-admin-url: export PORT?=8001
ingress-admin-url: ## Show the ingress admin URL
$(MAKE) ingress-helper
ingress-admin-open: export PORT?=8001
ingress-admin-open: export TARGET?=proxy
ingress-admin-open: ## Open the ingress admin URL
$(MAKE) ingress-helper
curl: export SCHEME?=http
curl: export SERVICE?=ingress
curl: export INDEX?=1
curl: export PORT?=80
curl: export HOST?=web.app
curl: ## Perform a request to a specific service (default ingress:80 with Host: web.app)
curl -vvv -H "Host: $(HOST)" "$(SCHEME)://$$($(DOCKER_COMPOSE) port --index $(INDEX) $(SERVICE) $(PORT))/"
# Check http://marmelab.com/blog/2016/02/29/auto-documented-makefile.html
help: ## Print this help
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST)