-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
281 lines (273 loc) · 6.25 KB
/
docker-compose.yml
File metadata and controls
281 lines (273 loc) · 6.25 KB
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
services:
# PostgreSQL база данных
postgres:
image: postgres:16-alpine
container_name: medbooker_postgres
restart: unless-stopped
command:
- "postgres"
- "-c"
- "shared_buffers=128MB"
- "-c"
- "effective_cache_size=384MB"
- "-c"
- "work_mem=2MB"
- "-c"
- "maintenance_work_mem=32MB"
- "-c"
- "max_connections=50"
- "-c"
- "wal_buffers=4MB"
- "-c"
- "min_wal_size=128MB"
- "-c"
- "max_wal_size=512MB"
- "-c"
- "checkpoint_completion_target=0.9"
- "-c"
- "checkpoint_timeout=15min"
- "-c"
- "random_page_cost=1.1"
- "-c"
- "effective_io_concurrency=200"
- "-c"
- "max_worker_processes=2"
- "-c"
- "max_parallel_workers_per_gather=1"
- "-c"
- "max_parallel_workers=2"
- "-c"
- "default_statistics_target=100"
- "-c"
- "log_statement=none"
- "-c"
- "log_duration=off"
- "-c"
- "log_line_prefix=%t [%p]: [%l-1] user=%u,db=%d,app=%a,client=%h "
environment:
POSTGRES_DB: ${POSTGRES_DB}
POSTGRES_USER: ${POSTGRES_USER}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
volumes:
- postgres_data:/var/lib/postgresql/data
- ./backups:/backups
networks:
- medbooker_network
deploy:
resources:
limits:
cpus: '0.5'
memory: 512M
reservations:
memory: 256M
healthcheck:
test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER} -d ${POSTGRES_DB}"]
interval: 10s
timeout: 5s
retries: 5
start_period: 30s
logging:
driver: "json-file"
options:
max-size: "10m"
max-file: "3"
# Django Backend с Gunicorn
backend:
build:
context: ./backend
dockerfile: Dockerfile
container_name: medbooker_backend
restart: unless-stopped
env_file:
- ./backend/.env
volumes:
- static_volume:/app/staticfiles
- media_volume:/app/media
- ./backend/logs:/app/logs
# ports:
# - "8000:8000"
depends_on:
postgres:
condition: service_healthy
networks:
- medbooker_network
deploy:
resources:
limits:
cpus: '0.75'
memory: 512M
reservations:
memory: 256M
healthcheck:
test: ["CMD-SHELL", "exit 0"]
interval: 10s
retries: 1
start_period: 0s
logging:
driver: "json-file"
options:
max-size: "10m"
max-file: "3"
# Telegram-бот (polling) — единственный экземпляр
telegram-bot:
build:
context: ./backend
dockerfile: Dockerfile
container_name: medbooker_telegram_bot
restart: unless-stopped
command: python manage.py run_bot
env_file:
- ./backend/.env
volumes:
- ./backend/logs:/app/logs
deploy:
resources:
limits:
cpus: '0.25'
memory: 256M
reservations:
memory: 128M
depends_on:
postgres:
condition: service_healthy
networks:
- medbooker_network
logging:
driver: "json-file"
options:
max-size: "10m"
max-file: "3"
# React Frontend с Nginx
frontend:
build:
context: ./frontend
dockerfile: Dockerfile
container_name: medbooker_frontend
restart: unless-stopped
ports:
- "80:80"
deploy:
resources:
limits:
cpus: '0.25'
memory: 128M
reservations:
memory: 64M
depends_on:
backend:
condition: service_healthy
networks:
- medbooker_network
logging:
driver: "json-file"
options:
max-size: "10m"
max-file: "3"
# Redis — брокер и бэкенд для Celery
redis:
image: redis:7-alpine
container_name: medbooker_redis
restart: unless-stopped
command: redis-server --save "" --appendonly no --maxmemory 64mb --maxmemory-policy allkeys-lru
networks:
- medbooker_network
deploy:
resources:
limits:
cpus: '0.1'
memory: 96M
reservations:
memory: 64M
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 10s
timeout: 5s
retries: 5
logging:
driver: "json-file"
options:
max-size: "5m"
max-file: "2"
# Celery Worker — выполняет задачи из очереди backup
celery-worker:
build:
context: ./backend
dockerfile: Dockerfile
container_name: medbooker_celery_worker
restart: unless-stopped
command: >
celery -A backend worker
--queues=backup
--concurrency=1
--loglevel=info
--max-tasks-per-child=10
env_file:
- ./backend/.env
volumes:
- ./backups:/app/backups
depends_on:
postgres:
condition: service_healthy
redis:
condition: service_healthy
networks:
- medbooker_network
deploy:
resources:
limits:
cpus: '0.25'
memory: 192M
reservations:
memory: 96M
logging:
driver: "json-file"
options:
max-size: "10m"
max-file: "3"
# Celery Beat — планировщик (запускает задачи по расписанию)
celery-beat:
build:
context: ./backend
dockerfile: Dockerfile
container_name: medbooker_celery_beat
restart: unless-stopped
command: >
celery -A backend beat
--scheduler django_celery_beat.schedulers:DatabaseScheduler
--loglevel=info
env_file:
- ./backend/.env
volumes:
- ./backups:/app/backups
depends_on:
postgres:
condition: service_healthy
redis:
condition: service_healthy
networks:
- medbooker_network
deploy:
resources:
limits:
cpus: '0.1'
memory: 128M
reservations:
memory: 64M
logging:
driver: "json-file"
options:
max-size: "5m"
max-file: "2"
volumes:
postgres_data:
driver: local
static_volume:
driver: local
media_volume:
driver: local
networks:
medbooker_network:
driver: bridge
ipam:
config:
- subnet: 172.25.0.0/16