-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
115 lines (85 loc) · 2.03 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
EXECUTABLES = lein docker docker-compose
LIITERI_CONFIG ?= ../ataru-secrets/virkailija-local-dev.edn
LIITERI=liiteri-16832
PM2=npx pm2 --no-autorestart
START_ONLY=start pm2.config.js --only
STOP_ONLY=stop pm2.config.js --only
DOCKER_COMPOSE=COMPOSE_PARALLEL_LIMIT=8 docker-compose
NODE_MODULES=node_modules/pm2/bin/pm2
# ----------------
# Check that all necessary tools are in path
# ----------------
check-tools:
$(info Checking commands in path: $(EXECUTABLES) ...)
$(foreach exec,$(EXECUTABLES),\
$(if $(shell which $(exec)),$(info .. $(exec) found),$(error No $(exec) in PATH)))
# ----------------
# Docker build
# ----------------
build-docker-images: check-tools
$(DOCKER_COMPOSE) build
# ----------------
# Npm installation
# ----------------
$(NODE_MODULES):
npm install
# ----------------
# Start apps
# ----------------
start-docker: build-docker-images
$(DOCKER_COMPOSE) up -d
start-pm2: $(NODE_MODULES) start-docker
$(PM2) start pm2.config.js
start-liiteri: start-docker
$(PM2) $(START_ONLY) $(LIITERI)
# ----------------
# Stop apps
# ----------------
stop-pm2: $(NODE_MODULES)
$(PM2) stop pm2.config.js
stop-liiteri:
$(PM2) $(STOP_ONLY) $(LIITERI)
# ----------------
# Restart apps
# ----------------
restart-liiteri: start-liiteri
restart-docker: stop-docker start-docker
# ----------------
# Clean commands
# ----------------
clean-docker:
docker-compose stop
docker-compose rm
docker system prune -f
clean-lein:
lein clean
# ----------------
# Top-level commands (all apps)
# ----------------
start: start-pm2
stop: stop-pm2
restart: stop-pm2 start-pm2
clean: stop clean-lein clean-docker
rm -f *.log
rm -rf node_modules
status: $(NODE_MODULES)
docker ps
$(PM2) status
log: $(NODE_MODULES)
$(PM2) logs
# Alias for log
logs: log
lint: $(NODE_MODULES)
npx eslint .
help:
@cat Makefile.md
# ----------------
# Test db management
# ----------------
test: start-docker
lein test-local
# ----------------
# Kill PM2 and all apps managed by it (= everything)
# ----------------
kill: stop-pm2 stop-docker
$(PM2) kill