-
Notifications
You must be signed in to change notification settings - Fork 0
/
compose.yml
153 lines (144 loc) · 3.2 KB
/
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
version: "3.9"
x-common: &common
image: registry.anttek.io/kapusta/telegram-bot:${TAG:-latest}
deploy:
mode: replicated
replicas: 1
restart_policy:
condition: any
delay: 5s
max_attempts: 5
window: 60s
rollback_config:
delay: 10s
failure_action: continue
order: start-first
parallelism: 1
update_config:
delay: 10s
failure_action: rollback
order: start-first
parallelism: 1
restart: always
x-db-name: &DB_NAME kapusta_telegram_bot
x-db-user: &DB_USER kapusta_telegram_bot
x-db-password: &DB_PASSWORD kapusta_telegram_bot
x-common-env: &common-env
BOT_TOKEN: ${BOT_TOKEN?Variable BOT_TOKEN is required}
REDIS_BASE_URL: redis://redis:6379
DB_HOST: postgres
DB_PORT: 5432
DB_NAME: *DB_NAME
DB_USER: *DB_USER
DB_PASSWORD: *DB_PASSWORD
x-common-volumes:
volumes:
- &uploads uploads:/home/appuser/uploads
services:
postgres:
image: postgres:15
deploy:
mode: replicated
replicas: 1
resources:
limits:
cpus: "0.5"
memory: 256M
reservations:
cpus: "0.25"
memory: 128M
restart_policy:
condition: on-failure
delay: 10s
max_attempts: 5
window: 60s
rollback_config:
delay: 10s
failure_action: continue
order: stop-first
parallelism: 1
update_config:
delay: 10s
failure_action: rollback
order: stop-first
parallelism: 1
environment:
POSTGRES_DB: *DB_NAME
POSTGRES_USER: *DB_USER
POSTGRES_PASSWORD: *DB_PASSWORD
healthcheck:
test: [ "CMD", "pg_isready", "-q", "-d", *DB_NAME, "-U", *DB_USER ]
interval: 5s
timeout: 1s
retries: 10
volumes:
- postgres_data:/var/lib/postgresql/data/
redis:
image: redis:alpine
deploy:
mode: replicated
replicas: 1
resources:
limits:
cpus: "0.125"
memory: 64M
reservations:
cpus: "0.0625"
memory: 32M
restart_policy:
condition: on-failure
delay: 10s
max_attempts: 5
window: 60s
rollback_config:
delay: 10s
failure_action: continue
order: stop-first
parallelism: 1
update_config:
delay: 10s
failure_action: rollback
order: stop-first
parallelism: 1
healthcheck:
test: [ "CMD", "redis-cli", "ping" ]
interval: 5s
timeout: 1s
retries: 10
volumes:
- redis_data:/data
bot:
<<: *common
build: .
deploy:
resources:
limits:
cpus: "0.5"
memory: 256M
reservations:
cpus: "0.25"
memory: 128M
environment:
<<: *common-env
volumes:
- *uploads
celery:
<<: *common
command: -A core worker -l info -P prefork -c 2 -E -B # Run both worker and beat
deploy:
resources:
limits:
cpus: "0.5"
memory: 256M
reservations:
cpus: "0.25"
memory: 128M
entrypoint: celery
environment:
<<: *common-env
volumes:
- *uploads
volumes:
postgres_data:
redis_data:
uploads: