-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
159 lines (135 loc) · 4.02 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
VERSION=$(shell cat VERSION)
all:
@make build
@make run
VERSION=$(shell cat VERSION)
#building docker images for each service
build-db:
@docker-compose build db
build-data:
@docker-compose build data
build-server:
@docker-compose build server
build-client:
@docker-compose build client
build-base:
@docker build -t zenofcoder/base -f ./base/Dockerfile-base ./base
build-nginx:
@docker-compose build nginx
build: build-data build-db build-nginx build-base build-server build-client
#run docker images
run-db:
@docker-compose up data db
run-server:
@docker-compose up server
run-nginx:
@docker-compose up nginx
run:
@docker-compose up -d
# the only right way to run it on production
run-prod:
@docker-compose -f docker-compose.yml -f docker-compose.prod.yml up -d
#containers and images ids
CONTS-DB=$(shell docker ps -a -q -f "name=zenofcoder-db")
IMGS-DB=$(shell docker images -q -f "label=application=zenofcoder-db")
CONTS-DATA=$(shell docker ps -a -q -f "name=zenofcoder-data")
IMGS-DATA=$(shell docker images -q -f "label=application=zenofcoder-data")
CONTS-SERVER=$(shell docker ps -a -q -f "name=zenofcoder-web-server")
IMGS-SERVER=$(shell docker images -q -f "label=application=zenofcoder-web-server")
CONTS-CLIENT=$(shell docker ps -a -q -f "name=zenofcoder-web-client")
IMGS-CLIENT=$(shell docker images -a -q -f "name=zenofcoder-web-client")
CONTS-NGINX=$(shell docker ps -a -q -f "name=zenofcoder-nginx")
IMGS-NGINX=$(shell docker images -q -f "label=application=zenofcoder-nginx")
IMGS-BASE=$(shell docker images -q -f "label=application=zenofcoder-base")
#stop docker containers
stop-db:
-@docker stop $(CONTS-DB)
stop-data:
-@docker stop $(CONTS-DATA)
stop-server:
-@docker stop --time=1 $(CONTS-SERVER)
stop-client:
-@docker stop $(CONTS-CLIENT)
stop-nginx:
-@docker stop $(CONTS-NGINX)
stop:
@docker-compose down
#start docker containers
start-db:
@docker start zenofcoder-data
@docker start zenofcoder-db
start-server:
@docker start zenofcoder-web-server
start-client:
@docker start zenofcoder-web-client
start-nginx:
@docker start zenofcoder-nginx
start: start-db start-server start-client start-nginx
#remove docker containers
rm-data:
-@docker rm $(CONTS-DATA)
rm-db:
-@docker rm $(CONTS-DB)
rm-server:
-@docker rm $(CONTS-SERVER)
rm-client:
-@docker rm $(CONTS-CLIENT)
rm-nginx:
-@docker rm $(CONTS-NGINX)
rm: rm-db rm-server rm-client rm-nginx
#remove docker images
rmi-data:
-@docker rmi -f $(IMGS-DATA)
rmi-db:
-@docker rmi -f $(IMGS-DB)
rmi-server:
-@docker rmi -f $(IMGS-SERVER)
rmi-client:
-@docker rmi -f $(IMGS-CLIENT)
rmi-nginx:
-@docker rmi -f $(IMGS-NGINX)
rmi-base:
-@docker rmi -f $(IMGS-BASE)
rmi: rmi-db rmi-server rmi-client rmi-nginx
# stop containters, remove containers, remove images
clean-db: stop-db rm-db rmi-db
clean-server: stop-server rm-server rmi-server
clean-client: stop-client rm-client rmi-client
clean-nginx: stop-nginx rm-nginx rmi-nginx
clean-apps: clean-db clean-web clean-nginx
clean-base: rmi-base
clean-data: stop-data rm-data rmi-data
clean-compose:
@docker-compose rm -f
clean-all: clean-db clean-server clean-client clean-nginx clean-data clean-base clean-compose
reload-nginx:
@make clean-nginx
@make build-nginx
@make run-nginx
#rebuild images
rebuild: clean-all build
# open shell in container
shell-server:
@docker exec -it zenofcoder-web-server bash
shell-client:
@docker exec -it zenofcoder-web-client bash
shell-db:
@docker exec -it zenofcoder-db bash
logs-server:
@docker-compose logs -f | grep zenofcoder-web-server
logs-client:
@docker-compose logs -f | grep zenofcoder-web-client
logs-db:
@docker-compose logs -f | grep zenofcoder-db
logs-https:
@docker-compose logs -f | grep zenofcoder-https
logs-testing:
@docker-compose logs -f | grep zenofcoder-testing
logs:
@docker-compose logs -f
# Reload static files in web container
reload_static:
@docker exec zenfocoder-web python manage.py collectstatic --no-input
# Reload static files automatically after every change.
dev_static:
@when-changed -1 -v -r `find ./zenofcoder-web/server/* -name 'static'` -c make reload_static