-
Notifications
You must be signed in to change notification settings - Fork 12
/
Makefile
227 lines (175 loc) · 5.25 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
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
CFLAGS ?=
CXXFLAGS ?=
LDFLAGS ?=
REBAR ?= rebar3
REBAR3_PROFILE ?= prod
BONDY_ERL_NODENAME ?= [email protected]
BONDY_ERL_DISTRIBUTED_COOKIE ?= bondy
CT_SUITE_FILE ?=
ifdef CT_SUITE_FILE
CT_SUITE_ARGS = --suite ${CT_SUITE_FILE}
else
CT_SUITE_ARGS =
endif
CODESPELL = $(shell which codespell)
SPELLCHECK = $(CODESPELL) -S _build -S doc -S .git -L applys,nd,accout,mattern,pres,fo
SPELLFIX = $(SPELLCHECK) -i 3 -w
# Architecture Auto configuration
UNAME_M := $(shell uname -m)
ifeq ($(UNAME_M), x86_64)
DOCKER_PLATFORM = amd64
else ifeq ($(UNAME_M), aarch64)
DOCKER_PLATFORM = arm64
CFLAGS := $(CFLAGS) -arch arm64 -O2 -g
CXXFLAGS := $(CXXFLAGS) -arch arm64
LDFLAGS := $(LDFLAGS) -arch arm64
else ifeq ($(UNAME_M), arm64)
DOCKER_PLATFORM = arm64
CFLAGS := $(CFLAGS) -arch arm64 -O2 -g
CXXFLAGS := $(CXXFLAGS) -arch arm64
LDFLAGS := $(LDFLAGS) -arch arm64
else ifeq ($(UNAME_M), armv7l)
DOCKER_PLATFORM = arm32v7
endif
export CFLAGS
export CXXLAGS
export LDFLAGS
.PHONY: genvars compile check test xref eunit dialyzer release release-tar spellcheck spellfix
certs:
cd config && ./make_certs
genvars:
@cp config/prod/default_vars.config config/prod/vars.generated
compile:
${REBAR} compile
docs: xref
${REBAR} ex_doc
cp -r doc/js/* apps/bondy/doc/
cp -r doc/js/* apps/bondy_broker_bridge/doc/
mkdir -p apps/bondy/doc/assets/
mkdir -p apps/bondy_broker_bridge/doc/assets/
cp -r doc/assets/* apps/bondy/doc/assets/
cp -r doc/assets/* apps/bondy_broker_bridge/doc/assets/
mkdir -p apps/bondy_stdlib/doc/assets/
cp -r doc/assets/* apps/bondy/doc/assets/
cp -r doc/assets/* apps/bondy_stdlib/doc/assets/
clean: node1-clean node2-clean node3-clean
${REBAR} clean
clean-docs:
rm -rf apps/bondy/doc/*
rm -f apps/bondy/doc/.build
rm -rf apps/bondy_broker_bridge/doc/*
rm -f apps/bondy_broker_bridge/doc/.build
rm -rf apps/bondy_stdlib/doc/*
rm -f apps/bondy_stdlib/doc/.build
test: xref eunit
${REBAR} as test ct ${CT_SUITE_ARGS}
eunit:
${REBAR} eunit
xref:
${REBAR} xref skip_deps=true
check: kill test xref dialyzer eqwalizer spellcheck
xref: compile
${REBAR} xref skip_deps=true
dialyzer: compile
${REBAR} dialyzer
eqwalizer: compile
elp eqwalize-all
spellcheck:
$(if $(CODESPELL), $(SPELLCHECK), $(error "Aborting, command codespell not found in PATH"))
spellfix:
$(if $(CODESPELL), $(SPELLFIX), $(error "Aborting, command codespell not found in PATH"))
cover: xref
${REBAR} as test ct ${CT_SUITE_ARGS}, cover
dialyzer: compile
${REBAR} dialyzer
release:
rm -rf _build/${REBAR3_PROFILE}
${REBAR} as ${REBAR3_PROFILE} release
release-tar:
rm -rf _build/${REBAR3_PROFILE}
${REBAR} as ${REBAR3_PROFILE} tar
mkdir -p _build/tar
tar -zxvf _build/${REBAR3_PROFILE}/rel/*/*.tar.gz -C _build/tar
devrun:
${REBAR} as dev release
cp examples/config/security_config.json _build/dev/rel/bondy/etc/security_config.json
cp examples/config/api_spec.json _build/dev/rel/bondy/etc/api_spec.json
cp examples/config/broker_bridge_config.json _build/dev/rel/bondy/etc/broker_bridge_config.json
_build/dev/rel/bondy/bin/bondy console
prodrun:
${REBAR} as prod release
RELX_REPLACE_OS_VARS=true \
BONDY_ERL_NODENAME=${BONDY_ERL_NODENAME} \
BONDY_ERL_DISTRIBUTED_COOKIE=${BONDY_ERL_DISTRIBUTED_COOKIE} \
_build/prod/rel/bondy/bin/bondy console
prodtarrun: tar
BONDY_ERL_NODENAME=${BONDY_ERL_NODENAME} BONDY_ERL_DISTRIBUTED_COOKIE=${BONDY_ERL_DISTRIBUTED_COOKIE} _build/tar/bin/bondy console
node1:
${REBAR} as node1 release
ERL_DIST_PORT=27781 _build/node1/rel/bondy/bin/bondy console
node1-clean:
${REBAR} as node1 clean
node2:
${REBAR} as node2 release
ERL_DIST_PORT=27782 _build/node2/rel/bondy/bin/bondy console
node2-clean:
${REBAR} as node2 clean
node3:
${REBAR} as node3 release
ERL_DIST_PORT=27783 _build/node3/rel/bondy/bin/bondy console
node3-clean:
${REBAR} as node3 clean
edge1:
${REBAR} as edge1 release
EDGE1_DEVICE1_PRIVKEY=4ffddd896a530ce5ee8c86b83b0d31835490a97a9cd718cb2f09c9fd31c4a7d71766c9e6ec7d7b354fd7a2e4542753a23cae0b901228305621e5b8713299ccdd \
ERL_DIST_PORT=27784 \
_build/edge1/rel/bondy/bin/bondy console
run-node1:
_build/node1/rel/bondy/bin/bondy console
run-node2:
_build/node2/rel/bondy/bin/bondy console
run-node3:
_build/node3/rel/bondy/bin/bondy console
run-edge1:
_build/edge1/rel/bondy/bin/bondy console
# DOCKER
docker-build:
docker buildx install
docker stop bondy-prod || true
docker rm bondy-prod || true
docker rmi bondy-prod || true
docker build \
--pull \
--platform linux/$(DOCKER_PLATFORM) \
--load \
-t "bondy-prod" \
-f deployment/Dockerfile .
docker-build-alpine:
docker buildx install
docker stop bondy-prod || true
docker rm bondy-prod || true
docker rmi bondy-prod || true
docker build \
--pull \
--platform linux/$(DOCKER_PLATFORM) \
--load \
-t "bondy-prod" \
-f deployment/alpine.Dockerfile .
# Runs an image build using targets docker-build or docker-build-alpine
docker-run-prod:
# docker stop bondy-prod || true
# docker rm bondy-prod || true
docker run \
--rm \
-e [email protected] \
-e BONDY_ERL_DISTRIBUTED_COOKIE=bondy \
-p 18080:18080 \
-p 18081:18081 \
-p 18082:18082 \
-p 18086:18086 \
-u 0:1000 \
-v "$(PWD)/examples/custom_config/etc:/bondy/etc" \
--name bondy-prod \
bondy-prod:latest
docker-scan-prod:
docker scan bondy-prod