-
Notifications
You must be signed in to change notification settings - Fork 1
/
docker-compose-prod.yml
177 lines (166 loc) · 4.55 KB
/
docker-compose-prod.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
version: '3'
services:
redis:
image: redis:6
ports:
- '6379:6379'
networks:
- mvs
rabbitmq:
image: rabbitmq:3-management
ports:
- '5672:5672'
- '15672:15672'
environment:
RABBITMQ_DEFAULT_USER: guest
RABBITMQ_DEFAULT_PASS: guest
healthcheck:
test: ['CMD', 'rabbitmqctl', 'status']
interval: 30s
timeout: 10s
retries: 5
networks:
- mvs
celery:
build:
context: ./MVStudio-Backend
ports:
- '5555:5555'
depends_on:
- rabbitmq
- redis
networks:
- mvs
command: >
sh -c "
celery -A config worker --loglevel=info --concurrency=2 -Q default -n worker_1_@%h &
celery -A config worker --loglevel=info --concurrency=2 -Q music_queue -n worker_2_@%h &
celery -A config worker --loglevel=info --concurrency=10 -Q video_queue -n worker_3_@%h &
celery -A config worker --loglevel=info --concurrency=2 -Q final_queue -n worker_4_@%h &
celery -A config flower --port=5555 --broker=$CELERY_BROKER_URL --broker-api=http://guest:guest@rabbitmq:15672/api/"
environment:
- CELERY_BROKER_URL=amqp://guest:guest@rabbitmq:5672/
celery-beat:
build:
context: ./MVStudio-Backend
command: celery -A config beat --loglevel=info
depends_on:
- redis
- rabbitmq
networks:
- mvs
elasticsearch:
image: docker.elastic.co/elasticsearch/elasticsearch:7.10.1
environment:
- discovery.type=single-node
- ES_JAVA_OPTS=-Xms512m -Xmx512m
ulimits:
memlock:
soft: -1
hard: -1
volumes:
- es_data:/usr/share/elasticsearch/data
ports:
- '9200:9200'
user: '1000:1000' # 비루트 사용자로 설정
command: >
sh -c "elasticsearch-plugin install analysis-nori &&
bin/elasticsearch"
healthcheck:
test:
[
'CMD-SHELL',
'curl -s http://localhost:9200/_cluster/health | grep -vq ''"status":"red"''',
]
interval: 10s
timeout: 5s
retries: 10
networks:
- mvs
backend-blue:
container_name: MVStudio-Backend-blue
build:
context: ./MVStudio-Backend
volumes:
- ./MVStudio-Backend:/MVStudio-Backend
ports:
- '8000:8000'
depends_on:
redis:
condition: service_started
rabbitmq:
condition: service_started
elasticsearch:
condition: service_healthy
# db:
# condition: service_started
networks:
- mvs
restart: always
command: >
sh -c "
python manage.py makemigrations &&
python manage.py makemigrations member &&
python manage.py makemigrations music_videos &&
python manage.py migrate &&
if [ '$$INIT_INDEX' = 'false' ]; then
python manage.py search_index --create &&
export INIT_INDEX=true
fi &&
python manage.py search_index --rebuild -f&&
gunicorn --bind 0.0.0.0:8000 config.wsgi:application -w 2"
backend-green:
container_name: MVStudio-Backend-green
build:
context: ./MVStudio-Backend
volumes:
- ./MVStudio-Backend:/MVStudio-Backend
ports:
- '8001:8001'
depends_on:
redis:
condition: service_started
rabbitmq:
condition: service_started
elasticsearch:
condition: service_healthy
networks:
- mvs
restart: always
command: >
sh -c "
python manage.py makemigrations &&
python manage.py makemigrations member &&
python manage.py makemigrations music_videos &&
python manage.py migrate &&
python manage.py search_index --rebuild -f&&
gunicorn --bind 0.0.0.0:8001 config.wsgi:application -w 2"
nginx:
container_name: MVStudio-Nginx
build:
context: ./nginx
ports:
- '80:80'
- '443:443'
volumes:
- ./MVStudio-Frontend/dist:/var/www/frontend
- ./nginx/logs:/var/log/nginx
- ./certbot/conf:/etc/letsencrypt
- ./certbot/www:/var/www/certbot
networks:
- mvs
certbot:
container_name: certbot
image: certbot/certbot
restart: unless-stopped
volumes:
- ./certbot/conf:/etc/letsencrypt #nginx컨테이너에 certbot컨테이너 연결
- ./certbot/www:/var/www/certbot
depends_on:
- nginx
entrypoint: "/bin/sh -c 'trap exit TERM; while :; do certbot renew; sleep 12h & wait $${!}; done;'"
volumes:
build_folder:
es_data:
networks:
mvs: