-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
143 lines (122 loc) · 3.62 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
# keeping for docker commands
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-web:
@docker-compose build web
build-base:
@docker build -t {{ project_name }}/base:$(VERSION) -f ./base/Dockerfile-base ./base
build-nginx:
@docker-compose build nginx
build-testing:
@docker-compose build testing
build: build-data build-db build-nginx build-base build-web build-testing
#run docker images
run-db:
@docker-compose up data db
run-web:
@docker-compose up web
run-nginx:
@docker-compose up nginx
run-testing:
@docker-compose up testing
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={{ project_name }}-db")
IMGS-DB=$(shell docker images -q -f "label=application={{ project_name }}-db")
CONTS-DATA=$(shell docker ps -a -q -f "name={{ project_name }}-data")
IMGS-DATA=$(shell docker images -q -f "label=application={{ project_name }}-data")
CONTS-WEB=$(shell docker ps -a -q -f "name={{ project_name }}-web")
IMGS-WEB=$(shell docker images -q -f "label=application={{ project_name }}-web")
CONTS-NGINX=$(shell docker ps -a -q -f "name={{ project_name }}-nginx")
IMGS-NGINX=$(shell docker images -q -f "label=application={{ project_name }}-nginx")
IMGS-BASE=$(shell docker images -q -f "label=application={{ project_name }}-base")
CONTS-TESTING=$(shell docker ps -a -q -f "name={{ project_name }}-testing")
IMGS-TESTING=$(shell docker images -q -f "label=application={{ project_name }}-testing")
#stop docker containers
stop-db:
-@docker stop $(CONTS-DB)
stop-data:
-@docker stop $(CONTS-DATA)
stop-web:
-@docker stop --time=1 $(CONTS-WEB)
stop-nginx:
-@docker stop $(CONTS-NGINX)
stop-testing:
-@docker stop $(CONTS-TESTING)
stop:
@docker-compose down
#start docker containers
start-db:
@docker start {{ project_name }}-data
@docker start {{ project_name }}-db
start-web:
@docker start {{ project_name }}-web
start-nginx:
@docker start {{ project_name }}-nginx
start-testing:
@docker start {{ project_name }}-testing
start: start-db start-web start-nginx start-testing
#remove docker containers
rm-data:
-@docker rm $(CONTS-DATA)
rm-db:
-@docker rm $(CONTS-DB)
rm-web:
-@docker rm $(CONTS-WEB)
rm-nginx:
-@docker rm $(CONTS-NGINX)
rm-testing:
-@docker rm $(CONTS-TESTING)
rm: rm-db rm-web rm-nginx
#remove docker images
rmi-data:
-@docker rmi -f $(IMGS-DATA)
rmi-db:
-@docker rmi -f $(IMGS-DB)
rmi-web:
-@docker rmi -f $(IMGS-WEB)
rmi-nginx:
-@docker rmi -f $(IMGS-NGINX)
rmi-base:
-@docker rmi -f $(IMGS-BASE)
rmi-testing:
-@docker rmi -f $(IMGS-TESTING)
rmi: rmi-db rmi-web rmi-nginx
# stop containters, rmove containers, remove images
clean-db: stop-db rm-db rmi-db
clean-web: stop-web rm-web rmi-web
clean-nginx: stop-nginx rm-nginx rmi-nginx
clean-testing: stop-testing rm-testing rmi-testing
clean-apps: clean-db clean-web clean-nginx clean-testing
clean-base: rmi-base
clean-data: stop-data rm-data rmi-data
clean-compose:
@docker-compose rm -f
clean-all: clean-db clean-web clean-nginx clean-testing clean-data clean-base clean-compose
reload-nginx:
@make clean-nginx
@make build-nginx
@make run-nginx
# open shell in container
shell-web:
@docker exec -it {{ project_name }}-web bash
shell-db:
@docker exec -it {{ project_name }}-db bash
shell-testing:
@docker exec -it {{ project_name }}-testing bash
logs:
@docker-compose logs
# run sbe test in {{ project_name }}-web container
sbe:
@docker exec -t {{ project_name }}-testing behave