-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
408 lines (326 loc) · 8.27 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
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
PROJECT=beta-platform
OS_TYPE=$(shell uname -a)
BRANCH=$(shell git rev-parse --abbrev-ref HEAD)
GITCOMMIT=$(shell git rev-parse HEAD)
BUILDDATE=$(shell date -u +'%Y-%m-%dT%H:%M:%SZ')
MAJOR=0
MINOR=1
PATCH=6
REVISION=alpha
VERSION=v$(MAJOR).$(MINOR).$(PATCH)
GOVERSION=1.11
LONGVERSION=v$(MAJOR).$(MINOR).$(PATCH)-$(REVISION)
CWD=$(shell pwd)
VPATH=github.com/medtune/beta-platform/internal
PROJECTPATH=$(CWD)
AUTHORS=El.bouchti.Alaa/Hilaly.Mohammed-Amine
OWNERS=$(AUTHORS)
LICENSETYPE=Apache-v2.0
LICENSEURL=https://raw.githubusercontent.com/medtune/beta-platform/master/LICENSE.txt
# Compile prod version of binaries
release:
go build \
-tags=prod \
-o medtune-beta \
-ldflags="\
-X $(VPATH).GitCommit=$(GITCOMMIT) \
-X $(VPATH).Major=$(MAJOR) \
-X $(VPATH).Minor=$(MINOR) \
-X $(VPATH).Patch=$(PATCH) \
-X $(VPATH).Revision=$(REVISION) \
-X $(VPATH).Authors=$(AUTHORS) \
-X $(VPATH).Owners=$(OWNERS) \
-X $(VPATH).LicenseURL=$(LICENSEURL) \
-X $(VPATH).LicenseType=$(LICENSETYPE) \
-X $(VPATH).BuildDate=$(BUILDDATE)" \
cmd/main_prod.go \
# Compile all possible commands binaries
release-cmd:
go build \
-o medtune-beta \
-ldflags="\
-X $(VPATH).GitCommit=$(GITCOMMIT) \
-X $(VPATH).Major=$(MAJOR) \
-X $(VPATH).Minor=$(MINOR) \
-X $(VPATH).Patch=$(PATCH) \
-X $(VPATH).Revision=$(REVISION) \
-X $(VPATH).Authors=$(AUTHORS) \
-X $(VPATH).Owners=$(OWNERS) \
-X $(VPATH).LicenseURL=$(LICENSEURL) \
-X $(VPATH).LicenseType=$(LICENSETYPE) \
-X $(VPATH).BuildDate=$(BUILDDATE)" \
cmd/main.go
# Compile developpement version
# GOCV under darwin/amd64
release-dev:
go build \
-tags="gocv" \
-o medtune-beta \
-ldflags="\
-X $(VPATH).GitCommit=$(GITCOMMIT) \
-X $(VPATH).Major=$(MAJOR) \
-X $(VPATH).Minor=$(MINOR) \
-X $(VPATH).Patch=$(PATCH) \
-X $(VPATH).Revision=$(REVISION) \
-X $(VPATH).Authors=$(AUTHORS) \
-X $(VPATH).Owners=$(OWNERS) \
-X $(VPATH).LicenseURL=$(LICENSEURL) \
-X $(VPATH).LicenseType=$(LICENSETYPE) \
-X $(VPATH).BuildDate=$(BUILDDATE)" \
cmd/main.go \
# Compile linux version
# 30Mb IMAGE !!
release-linux:
GOARCH=amd64 \
CGO_ENABLED=0 \
GOOS=linux \
go build \
-tags="prod" \
-o medtune-beta \
-ldflags="\
-X $(VPATH).GitCommit=$(GITCOMMIT) \
-X $(VPATH).Major=$(MAJOR) \
-X $(VPATH).Minor=$(MINOR) \
-X $(VPATH).Patch=$(PATCH) \
-X $(VPATH).Revision=$(REVISION) \
-X $(VPATH).Authors=$(AUTHORS) \
-X $(VPATH).Owners=$(OWNERS) \
-X $(VPATH).LicenseURL=$(LICENSEURL) \
-X $(VPATH).LicenseType=$(LICENSETYPE) \
-X $(VPATH).BuildDate=$(BUILDDATE)" \
cmd/main_prod.go \
# Compile debug binaries
release-debug:
go build \
-tags="debug" \
-o medtune-beta \
-ldflags="\
-X $(VPATH).GitCommit=$(GITCOMMIT) \
-X $(VPATH).Major=$(MAJOR) \
-X $(VPATH).Minor=$(MINOR) \
-X $(VPATH).Patch=$(PATCH) \
-X $(VPATH).Revision=$(REVISION) \
-X $(VPATH).Authors=$(AUTHORS) \
-X $(VPATH).Owners=$(OWNERS) \
-X $(VPATH).LicenseURL=$(LICENSEURL) \
-X $(VPATH).LicenseType=$(LICENSETYPE) \
-X $(VPATH).BuildDate=$(BUILDDATE)" \
cmd/main_debug.go \
# Build light image version (30mb)
build-alpine: build-base build-compile
docker rm build-stage
docker run --name=build-stage medtune/beta-platform:build
docker cp build-stage:/go/src/github.com/medtune/beta-platform/medtune-beta $(PWD)/medtune-beta
@echo building linux prod container
docker build \
-t medtune/beta-platform:prod-alpine \
-f build/prod.linux.Dockerfile \
.
# Build base image
# Doesnt compile anything
build-base:
@echo building base image
docker build \
-t medtune/beta-platform:base \
-f build/base.Dockerfile \
.
docker tag \
medtune/beta-platform:base \
medtune/beta-platform:go-1.10-linux-$(VERSION)-base
# 1 - Build compile use build-base image and compile
# the binaries using this makefile
# 2 - Tag image specifications
build-compile:
@echo building build image
docker build \
-t medtune/beta-platform:build \
-f build/build.Dockerfile \
.
@echo tag build images
docker tag \
medtune/beta-platform:build \
medtune/beta-platform:go-1.10-linux-$(VERSION)-build
docker tag \
medtune/beta-platform:build \
medtune/beta-platform:build
# Build production image (based on build-compile)
build-prod:
@echo building prod image
docker build \
-t medtune/beta-platform:prod \
-f build/prod.Dockerfile \
.
@echo tag prod images
docker tag \
medtune/beta-platform:prod \
medtune/beta-platform:go-1.10-linux-$(VERSION)-prod
docker tag \
medtune/beta-platform:prod \
medtune/beta-platform:$(VERSION)
docker tag \
medtune/beta-platform:prod \
medtune/beta-platform:latest
# Build k8s
build-k8s: #build-base build-compile
@echo building kubernetes prod image
docker build \
-t medtune/beta-platform:k8s \
-f build/prod.k8s.Dockerfile \
.
# Just let the make make the magic
build-all: build-base build-compile build-prod
# Public images in docker hub (hub.docker.com/medtune)
push-image:
docker push medtune/beta-platform:$(VERSION)
docker push medtune/beta-platform:latest
gen-k8s:
rm -rf deploy/kubernetes/*
kompose convert -f deployments/docker-compose.k8s-gen.yml -o deployments/k8s-generated
# Test package
tests:
@echo running global test
docker build \
-t medtune/beta-platform:test \
-f test/test.Dockerfile \
.
# Test coverage and push results to codecov
test-cov:
@echo running global code coverage tests
docker build \
-t medtune/beta-platform:test \
-f test/test-codecov.Dockerfile \
--build-arg CODECOV_TOKEN=$(CODECOV_TOKEN) \
.
docker run \
-v "$(PWD)/shared":/shared \
medtune/beta-platform:test
# setup capsules
mnist:
docker run -dti \
--name mnist \
-p 10000:10000 \
medtune/capsul:mnist
inception:
docker run -dti \
--name inception \
-p 10010:10010 \
medtune/capsul:inception
mura-mn-v2:
docker run -dti \
--name mura-mn-v2 \
-p 10020:10020 \
medtune/capsul:mura-mn-v2
mura-mn-v2-cam:
docker run -dti \
--name mura-mn-v2-cam \
-p 11020:11020 \
-v $(PROJECTPATH)/static/demos/mura/images:/medtune/data \
medtune/capsul:mura-mn-v2-cam
mura-irn-v2:
docker run -dti \
--name mura-irn-v2 \
-p 10021:10021 \
medtune/capsul:mura-irn-v2
chexray-dn-121:
docker run -dti \
--name chexray-dn-121 \
-p 10031:10031 \
medtune/capsul:chexray-dn-121
chexray-dn-121-cam:
docker run -dti \
--name chexray-dn-121-cam \
-p 10031:10031 \
medtune/capsul:chexray-dn-121-cam
chexray-pp:
docker run -dti \
--name chexray-pp-helper \
-p 12030:12030 \
-v $(PROJECTPATH)/static/demos/chexray/images:/medtune/data \
medtune/capsul:chexray-pp-helper
run-capsules: mnist \
inception \
mura-mn-v2 \
mura-mn-v2-cam \
mura-irn-v2 \
chexray-dn-121 \
chexray-pp
start-capsules:
docker start mnist \
inception \
mura-mn-v2 \
mura-mn-v2-cam \
mura-irn-v2 \
chexray-dn-121 \
chexray-pp-helper
stop-capsules:
docker stop mnist \
inception \
mura-mn-v2 \
mura-mn-v2-cam \
mura-irn-v2 \
chexray-dn-121 \
chexray-pp-helper
kill-capsules:
docker kill mnist \
inception \
mura-mn-v2 \
mura-mn-v2-cam \
mura-irn-v2 \
chexray-dn-121 \
chexray-pp-helper
docker rm mnist \
inception \
mura-mn-v2 \
mura-mn-v2-cam \
mura-irn-v2 \
chexray-dn-121 \
chexray-pp-helper
start:
./medtune-beta start \
-f etc/dev.config.yml \
--syncdb \
--create-users \
--sync-cxpba \
--wait \
--gin-mode 1
run:
go run -ldflags="\
-X $(VPATH).Major=$(MAJOR) \
-X $(VPATH).Minor=$(MINOR) \
-X $(VPATH).Patch=$(PATCH)" \
-tags=gocv \
./cmd/main.go \
start \
-f etc/dev.config.yml \
--syncdb \
--sync-cxpba \
--create-users \
--gin-mode 0
debug:
./medtune-beta debug
up:
docker-compose up
down:
docker-compose down
clean:
rm medtune-beta
clean-gen:
rm -rf genered-views
clean-demos:
rm -f static/demos/mura/images/*_mn_v2_cam.*
rm -f static/demos/mura/images/[^image_*]*
rm -f static/demos/chexray/images/[^debug.png][^image_*]*
rm -f static/demos/chexray/images/[^image_*]*
verify:
GO111MODULE=on go mod verify
vendor:
GO111MODULE=on go mod vendor
loc:
scc --pbl static/reveal.js-3.7.0,vendor,.dev,.git
start-scene: start-capsules
docker start postgreshost redis
stop-scene: stop-capsules
docker stop postgreshost redis
kill-scene: kill-capsules
docker kill postgreshost redis
docker rm postgreshost redis