-
Notifications
You must be signed in to change notification settings - Fork 1
/
docker-compose.yml
322 lines (295 loc) · 8.43 KB
/
docker-compose.yml
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
version: "3.8"
volumes:
build_folder: null
services:
mysqldb:
build: ./backend/db
container_name: mysqldb
env_file:
- "./backend/db/.env"
ports:
- "3306:3306"
volumes:
# - ./elk/logs/mysql_data:/var/var/log
- ./init/:/docker-entrypoint-initdb.d/
- ./backend/db/init.sql:/docker-entrypoint-initdb.d/init.sql
healthcheck:
test: ["CMD", "mysqladmin", "ping", "-h", "mysqldb"]
timeout: 20s
retries: 10
command: ["--general-log", "--general-log-file=/var/log/mysql.log"]
# mysql_exporter:
# image: prom/mysqld-exporter
# container_name: mysql_exporter
# volumes:
# - ./mysql_exporter/my.cnf:/root/.my.cnf
# command:
# - '--collect.global_status'
# - '--collect.info_schema.innodb_metrics'
# - '--collect.auto_increment.columns'
# - '--collect.info_schema.processlist'
# - '--collect.binlog_size'
# - '--collect.info_schema.tablestats'
# - '--collect.global_variables'
# - '--collect.info_schema.query_response_time'
# - '--collect.info_schema.userstats'
# - '--collect.info_schema.tables'
# - '--collect.perf_schema.tablelocks'
# - '--collect.perf_schema.file_events'
# - '--collect.perf_schema.eventswaits'
# - '--collect.perf_schema.indexiowaits'
# - '--collect.perf_schema.tableiowaits'
# ports:
# - 9104:9104
# depends_on:
# - mysqldb
backend:
build:
context: ./backend/django_back/
dockerfile: Dockerfile
container_name: backend
command: >
bash -c "python wait_mysql.py &&
python manage.py migrate &&
python manage.py makemigrations baseapp &&
python manage.py migrate &&
python manage.py makemigrations users &&
python manage.py migrate &&
python manage.py makemigrations musics &&
python manage.py migrate &&
python manage.py makemigrations themes &&
python manage.py migrate &&
python manage.py makemigrations capsules &&
python manage.py migrate &&
python manage.py makemigrations videos &&
python manage.py migrate &&
python manage.py makemigrations stories &&
python manage.py migrate &&
python manage.py runserver 0.0.0.0:8080"
ports:
- "8080:8080"
volumes:
- ./backend/django_back:/app
depends_on:
mysqldb:
condition: service_healthy
rabbitmq:
container_name: rabbitmq
image: rabbitmq:3-management-alpine
environment:
- RABBITMQ_USER=guest
- RABBITMQ_PASSWORD=guest
- TZ=Asia/Seoul
ports:
- "5672:5672" # Default Port
- "15672:15672" # For UI
expose:
- "15672"
volumes:
- "./backend/rabbitmq/enabled_plugins:/etc/rabbitmq/enabled_plugins"
healthcheck:
test: ["CMD", "rabbitmq-diagnostics", "check_running"]
interval: 30s
timeout: 15s
retries: 10
# rabbitmq-exporter:
# depends_on:
# rabbitmq:
# condition: service_healthy
# image: kbudde/rabbitmq-exporter
# ports:
# - "9419:9419"
# container_name: rabbitmq-exporter
# environment:
# - RABBITMQ_HOST=rabbitmq
# - RABBITMQ_USER=guest
# - RABBITMQ_PASSWORD=guest
# command: [ "./rabbitmq_wait.sh", "rabbitmq", "rabbitmq_exporter" ]
# healthcheck:
# test: [ "CMD", "wget", "-q", "-O", "-", "http://localhost:9419" ]
# interval: 20s
# timeout: 10s
# retries: 5
celery_worker:
container_name: celery_worker
build: ./backend/django_back/
volumes:
- ./backend/django_back:/backend
ports: []
depends_on:
rabbitmq:
condition: service_healthy
environment:
- C_FORCE_ROOT=true
- TZ=Asia/Seoul
- broker_connection_retry_on_startup=true
command: sh -c "python wait_mysql.py &&
celery -A django_back worker --loglevel=info"
deploy:
resources:
limits:
memory: 10G
redis_container:
image: redis:latest
container_name: redis
environment:
- TZ=Asia/Seoul
ports:
- "6379:6379"
volumes:
- ./backend/redis/data:/data
- ./backend/redis/conf/redis.conf:/usr/local/conf/redis.conf
depends_on:
- celery_worker
- backend
# 컨테이너에 docker label을 이용해서 메타데이터 추가
labels:
- "name=redis"
- "mode=standalone"
restart: always
command: redis-server /usr/local/conf/redis.conf
prometheus: # 프로메테우스 서비스 추가
image: prom/prometheus
ports:
- "9090:9090"
volumes:
- ./backend/monitoring/prometheus:/etc/prometheus
command:
- "--config.file=/etc/prometheus/prometheus.yml"
flower:
image: mher/flower
container_name: flower
environment:
- CELERY_BROKER_URL=amqp://guest:guest@rabbitmq:5672/
- CELERY_RESULT_BACKEND=redis://redis:6379/0
- TZ=Asia/Seoul
ports:
- '5555:5555'
depends_on:
rabbitmq:
condition: service_healthy
celery_worker:
condition: service_started
grafana: # 그라파나 서비스 추가
image: grafana/grafana
ports:
- "3000:3000"
depends_on:
- prometheus
- cadvisor
- node-exporter
cadvisor:
image: gcr.io/cadvisor/cadvisor:v0.47.0
container_name: cadvisor
privileged: true
ports:
- "9000:8080"
volumes:
- /:/rootfs:ro
- /var/run:/var/run:rw
- /sys:/sys:ro
- /var/lib/docker/:/var/lib/docker:ro
- /proc/cpuinfo:/host/proc/cpuinfo:ro
- /dev/disk:/dev/disk/:ro
devices:
- /dev/kmsg:/dev/kmsg
node-exporter:
image: prom/node-exporter:latest
ports:
- "9100:9100"
gunicorn:
image: gunicorn:latest
build:
context: ./backend/django_back/
dockerfile: Dockerfile
container_name: gunicorn
command: gunicorn django_back.wsgi:application -b 0.0.0.0:8000 --access-logfile -
ports:
- "8000:8000"
volumes:
- ./backend/django_back:/app
# - ./elk/logs/gunicorn_data:/var/log
depends_on:
- mysqldb
- celery_worker
nginx:
image: nginx:1.15-alpine
restart: unless-stopped
container_name: nginx
ports:
- "80:80"
- "443:443"
volumes:
# - ./elk/logs/nginx_data:/var/log/nginx
- ./backend/nginx/nginx_develop.conf:/etc/nginx/nginx.conf
- ./backend/certbot/conf:/etc/letsencrypt
- ./backend/certbot/www:/var/www/certbot
- build_folder:/var/www/frontend
depends_on:
- backend
- frontend
- gunicorn
expose:
- '80'
- '443'
command: '/bin/sh -c ''while :; do sleep 6h & wait $${!}; nginx -s reload; done & nginx -g "daemon off;"'''
certbot:
image: certbot/certbot
restart: unless-stopped
volumes:
- ./backend/certbot/conf:/etc/letsencrypt
- ./backend/certbot/www:/var/www/certbot
entrypoint: "/bin/sh -c 'trap exit TERM; while :; do certbot renew; sleep 12h & wait $${!}; done;'"
depends_on:
- nginx
frontend:
container_name: frontend
build:
context: ./frontend
dockerfile: Dockerfile
command: ["npm", "run", "dev"]
volumes:
- ./frontend:/frontend
- /frontend/node_modules
- ./frontend/.npm/_cacache:/frontend/.npm/_cacache
- build_folder:/frontend/dist
ports:
- "5173:5173"
tty: true
environment:
- npm_config_cache=/frontend/.npm/_cacache
# alertmanager:
# image: prom/alertmanager
# volumes:
# - ./backend/monitoring/alertmanager.yml:/etc/alertmanager/alertmanager.yml
# - ./backend/monitoring/prometheus/alert.rules.yml:/etc/prometheus/alert.rules.yml # 이 줄 추가
# command:
# - '--config.file=/etc/alertmanager/alertmanager.yml'
# ports:
# - 9093:9093
# influxdb:
# image: influxdb:1.8
# ports:
# - "8086:8086"
# environment:
# - INFLUXDB_DB=k6
# k6:
# image: grafana/k6:latest
# platform: linux/amd64
# ports:
# - "6565:6565"
# environment:
# - K6_OUT=influxdb=http://influxdb:8086/k6
# volumes:
# - ./backend/monitoring/samples:/scripts
# command: run /scripts/main.js
# k6:
# image: grafana/k6:latest
# platform: linux/amd64
# ports:
# - "6565:6565"
# environment:
# - K6_OUT=influxdb=http://influxdb:8086/k6
# volumes:
# - ./backend/monitoring/samples:/scripts
# command: run /scripts/main.js