forked from Sholex-Team/LilSholex
-
Notifications
You must be signed in to change notification settings - Fork 0
/
docker-compose.yml
424 lines (424 loc) · 9.69 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
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
version: "3.8"
services:
db:
image: mysql:8.0.27
command: --default-authentication-plugin=mysql_native_password
environment:
MYSQL_ROOT_PASSWORD_FILE: "/run/secrets/db_password"
MYSQL_PASSWORD_FILE: "/run/secrets/db_password"
MYSQL_USER: "sholex"
MYSQL_DATABASE: "lilsholex"
secrets:
- db_password
healthcheck:
test: mysqladmin -u root --password=`cat $MYSQL_ROOT_PASSWORD_FILE` ping
interval: 30s
retries: 3
timeout: 10s
start_period: 1m
deploy:
replicas: 1
placement:
constraints:
- node.labels.db==true
restart_policy:
condition: any
max_attempts: 3
window: 20s
delay: 10s
update_config:
parallelism: 1
delay: 5s
failure_action: rollback
monitor: 10s
order: stop-first
rollback_config:
parallelism: 1
delay: 5s
failure_action: pause
monitor: 10s
order: stop-first
networks:
- db_django
volumes:
- type: volume
source: db
target: /var/lib/mysql
configs:
- source: mysql
target: /etc/mysql/conf.d/mysql.cnf
rabbitmq:
image: rabbitmq:3.9.12
healthcheck:
test: "rabbitmq-diagnostics -q ping"
interval: 30s
timeout: 5s
start_period: 5m
retries: 3
networks:
- tasks_django
deploy:
replicas: 1
placement:
constraints:
- node.labels.task_master==true
restart_policy:
condition: any
max_attempts: 3
window: 20s
delay: 10s
update_config:
parallelism: 1
delay: 2s
failure_action: rollback
monitor: 10s
order: stop-first
rollback_config:
parallelism: 1
delay: 5s
failure_action: pause
monitor: 10s
order: stop-first
volumes:
- type: volume
source: rabbitmq_dump
target: /var/lib/rabbitmq
configs:
- source: rabbitmq
target: /etc/rabbitmq/rabbitmq.conf
nginx:
image: ghcr.io/sholex-team/nginx:3.8
networks:
- nginx_lilsholex
- internet
healthcheck:
test: python3.9 nginx.py
interval: 30s
timeout: 5s
start_period: 1m
retries: 3
depends_on:
- gunicorn
- daphne
volumes:
- ./lilsholex-dev/static:/root/lilsholex/static:ro
- type: volume
source: nginx
target: /var/log/nginx
deploy:
replicas: 1
placement:
preferences:
- spread: node.labels.zone
constraints:
- node.labels.nginx==true
restart_policy:
condition: any
max_attempts: 3
window: 10s
delay: 5s
update_config:
parallelism: 1
delay: 5s
failure_action: rollback
monitor: 10s
order: start-first
rollback_config:
parallelism: 1
delay: 5s
failure_action: pause
monitor: 10s
order: stop-first
secrets:
- ssl_certificate
- ssl_key
- dhparam
ports:
- "443:443/tcp"
- "80:80/tcp"
lilsholex:
image: ghcr.io/sholex-team/lilsholex:5.3
networks:
- db_django
- nginx_lilsholex
- cache_django
- internet
- tasks_django
secrets:
- db_password
- persianmeme_channel
- persianmeme_reports
- source: persianmeme_help_messages
target: persianmeme_help_messages
- persianmeme_token
- secret_key
- persianmeme_logs
- persianmeme_messages
- domain
depends_on:
- db
- migrations
healthcheck:
test: python healthchecks/gunicorn.py
interval: 20s
timeout: 20s
start_period: 30s
retries: 3
deploy:
replicas: 6
placement:
preferences:
- spread: node.labels.zone
constraints:
- node.labels.webserver==true
update_config:
parallelism: 3
delay: 5s
failure_action: rollback
monitor: 5s
order: start-first
rollback_config:
parallelism: 2
delay: 5s
failure_action: pause
monitor: 10s
order: stop-first
restart_policy:
condition: any
max_attempts: 3
window: 10s
delay: 5s
celery: &celery_base
image: ghcr.io/sholex-team/lilsholex-dev:6.1.5
command: "celery -A LilSholex worker -Q celery -l info -c 2 -E"
networks:
- db_django
- internet
- tasks_django
secrets:
- db_password
- secret_key
- persianmeme_token
- persianmeme_channel
- persianmeme_reports
- source: persianmeme_help_messages
target: persianmeme_help_messages
- persianmeme_logs
- persianmeme_messages
- domain
volumes:
- type: volume
source: state
target: /home/sholex/state
depends_on:
- db
- migrations
- rabbitmq
deploy:
replicas: 1
placement:
preferences:
- spread: node.labels.zone
constraints:
- node.labels.task_master==true
update_config:
parallelism: 1
delay: 5s
failure_action: rollback
monitor: 10s
order: stop-first
rollback_config:
parallelism: 1
delay: 5s
failure_action: pause
monitor: 10s
order: stop-first
restart_policy:
condition: any
max_attempts: 3
window: 10s
delay: 5s
celery_flower:
<<: *celery_base
command: "celery -A LilSholex flower --url_prefix=flower"
depends_on:
- celery
environment:
FLOWER_BASIC_AUTH: "sholex:flower_password"
lilsholex_broadcasts:
image: ghcr.io/sholex-team/lilsholex:5.3
command: "python manage.py process_broadcasts"
networks:
- db_django
- internet
secrets:
- db_password
- secret_key
- persianmeme_token
- persianmeme_channel
- persianmeme_reports
- source: persianmeme_help_messages
target: persianmeme_help_messages
- persianmeme_logs
- persianmeme_messages
- domain
depends_on:
- db
- migrations
deploy:
replicas: 1
placement:
constraints:
- node.labels.task_master==true
update_config:
parallelism: 1
delay: 5s
failure_action: rollback
monitor: 10s
order: stop-first
rollback_config:
parallelism: 1
delay: 5s
failure_action: pause
monitor: 10s
order: stop-first
restart_policy:
condition: any
max_attempts: 3
window: 10s
delay: 5s
memcached:
image: memcached:1.6.12
command: "memcached -m 256"
networks:
- cache_django
deploy:
replicas: 1
placement:
preferences:
- spread: node.labels.zone
constraints:
- node.labels.cache==true
restart_policy:
condition: any
max_attempts: 3
window: 20s
delay: 10s
update_config:
parallelism: 1
delay: 2s
failure_action: rollback
monitor: 10s
order: start-first
rollback_config:
parallelism: 1
delay: 5s
failure_action: pause
monitor: 10s
order: start-first
lilsholex_migrations:
image: ghcr.io/sholex-team/lilsholex:5.3
command: "bash -c 'yes | python manage.py makemigrations persianmeme && \
yes | python manage.py migrate && python manage.py collectstatic --noinput'"
secrets:
- db_password
- secret_key
- persianmeme_token
- persianmeme_channel
- persianmeme_reports
- source: persianmeme_help_messages
target: persianmeme_help_messages
- persianmeme_logs
- persianmeme_messages
- domain
depends_on:
- db
networks:
- db_django
deploy:
replicas: 1
placement:
constraints:
- node.labels.db==true
update_config:
parallelism: 1
delay: 5s
failure_action: pause
monitor: 10s
order: stop-first
rollback_config:
parallelism: 1
delay: 5s
failure_action: pause
monitor: 10s
order: stop-first
restart_policy:
condition: on-failure
max_attempts: 3
window: 10s
delay: 15s
volumes:
- type: volume
source: persianmeme
target: /home/sholex/persianmeme/migrations
networks:
db_django:
driver: "overlay"
name: "db_django"
internal: true
nginx_lilsholex:
driver: "overlay"
name: "nginx_lilsholex"
internal: true
cache_django:
driver: "overlay"
name: "cache_django"
internal: true
internet:
driver: "overlay"
name: "internet"
tasks_django:
driver: "overlay"
name: "tasks_django"
internal: true
volumes:
db:
name: "db"
persianmeme:
name: "persianmeme"
nginx:
name: "nginx"
state:
name: "state"
rabbitmq_dump:
name: "rabbitmq_dump"
secrets:
db_password:
external: true
persianmeme_channel:
external: true
persianmeme_token:
external: true
persianmeme_logs:
external: true
persianmeme_messages:
external: true
persianmeme_reports:
external: true
persianmeme_help_messages:
file: lilsholex-dev/secrets/help_messages.json # Replace file_id of animations.
secret_key:
external: true
ssl_certificate:
file: ./ssl/fullchain.pem
ssl_key:
file: ./ssl/privkey.pem
dhparam:
file: ./ssl/dhparam.pem
domain:
external: true
configs:
mysql:
file: conf/my.cnf # Change MySQL configuration based on your host.
rabbitmq:
file: conf/rabbitmq.conf