This repository has been archived by the owner on Apr 29, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 91
/
Makefile
179 lines (147 loc) · 4.08 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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
### Deploy configs
BRANCH=$(shell git rev-parse --abbrev-ref HEAD)
REMOTE="https://github.com/WalletConnect/node-walletconnect-bridge"
REMOTE_HASH=$(shell git ls-remote $(REMOTE) $(BRANCH) | head -n1 | cut -f1)
project=walletconnect
redisImage='redis:5-alpine'
nginxImage='$(project)/nginx:$(BRANCH)'
walletConnectImage='$(project)/bridge:$(BRANCH)'
### Makefile internal coordination
flags=.makeFlags
VPATH=$(flags)
$(shell mkdir -p $(flags))
.PHONY: all clean default
define DEFAULT_TEXT
Available make rules:
pull:\tdownloads docker images
setup:\tconfigures domain an certbot email
build:\tbuilds docker images
dev:\truns local docker stack with open ports
deploy:\tdeploys to production
deploy-monitoring:
\tdeploys to production with grafana
cloudflare: asks for a cloudflare DNS api and creates a docker secret
stop:\tstops all walletconnect docker stacks
upgrade:
\tpulls from remote git. Builds the containers and updates each individual
\tcontainer currently running with the new version that was just built.
clean:\tcleans current docker build
reset:\treset local config
endef
### Rules
export DEFAULT_TEXT
default:
@echo -e "$$DEFAULT_TEXT"
pull:
docker pull $(redisImage)
@touch $(flags)/$@
@echo "MAKE: Done with $@"
@echo
setup:
@read -p 'Bridge URL domain: ' bridge; \
echo "BRIDGE_URL="$$bridge > config
@read -p 'Email for SSL certificate (default [email protected]): ' email; \
echo "CERTBOT_EMAIL="$$email >> config
@read -p 'Is your DNS configured with cloudflare proxy? [y/N]: ' cf; \
echo "CLOUDFLARE="$${cf:-false} >> config
@touch $(flags)/$@
@echo "MAKE: Done with $@"
@echo
build-node: pull
docker build \
-t $(walletConnectImage) \
--build-arg BRANCH=$(BRANCH) \
--build-arg REMOTE_HASH=$(REMOTE_HASH) \
-f ops/node.Dockerfile .
@touch $(flags)/$@
@echo "MAKE: Done with $@"
@echo
build-nginx: pull
docker build \
-t $(nginxImage) \
--build-arg BRANCH=$(BRANCH) \
--build-arg REMOTE_HASH=$(REMOTE_HASH) \
-f ops/nginx/nginx.Dockerfile ./ops/nginx
@touch $(flags)/$@
@echo "MAKE: Done with $@"
@echo
build: pull build-node build-nginx
@touch $(flags)/$@
@echo "MAKE: Done with $@"
@echo
dev: pull build
BRIDGE_IMAGE=$(walletConnectImage) \
NGINX_IMAGE=$(nginxImage) \
docker stack deploy \
-c ops/docker-compose.yml \
-c ops/docker-compose.dev.yml \
dev_$(project)
@echo "MAKE: Done with $@"
@echo
dev-monitoring: pull build
BRIDGE_IMAGE=$(walletConnectImage) \
NGINX_IMAGE=$(nginxImage) \
docker stack deploy \
-c ops/docker-compose.yml \
-c ops/docker-compose.dev.yml \
-c ops/docker-compose.monitor.yml \
dev_$(project)
@echo "MAKE: Done with $@"
@echo
redeploy:
$(MAKE) clean
$(MAKE) down
$(MAKE) dev-monitoring
cloudflare: setup
bash ops/cloudflare-secret.sh $(project)
@touch $(flags)/$@
@echo "MAKE: Done with $@"
@echo
deploy: setup build cloudflare
BRIDGE_IMAGE=$(walletConnectImage) \
NGINX_IMAGE=$(nginxImage) \
PROJECT=$(project) \
bash ops/deploy.sh
@echo "MAKE: Done with $@"
@echo
deploy-monitoring: setup build cloudflare
BRIDGE_IMAGE=$(walletConnectImage) \
NGINX_IMAGE=$(nginxImage) \
PROJECT=$(project) \
MONITORING=true \
bash ops/deploy.sh
@echo "MAKE: Done with $@"
@echo
down: stop
stop:
docker stack rm $(project)
docker stack rm dev_$(project)
while [ -n "`docker network ls --quiet --filter label=com.docker.stack.namespace=$(project)`" ]; do echo -n '.' && sleep 1; done
@echo
while [ -n "`docker network ls --quiet --filter label=com.docker.stack.namespace=dev_$(project)`" ]; do echo -n '.' && sleep 1; done
@echo "MAKE: Done with $@"
@echo
upgrade: setup
rm -f $(flags)/build*
$(MAKE) build
@echo "MAKE: Done with $@"
@echo
git fetch origin $(BRANCH)
git merge origin/$(BRANCH)
docker service update --force $(project)_bridge0
docker service update --force $(project)_bridge1
docker service update --force $(project)_nginx
docker service update --force $(project)_redis
reset:
$(MAKE) clean-all
rm -f config
@echo "MAKE: Done with $@"
@echo
clean:
rm -rf .makeFlags/build*
@echo "MAKE: Done with $@"
@echo
clean-all:
rm -rf .makeFlags
@echo "MAKE: Done with $@"
@echo