-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
181 lines (165 loc) · 4.44 KB
/
Copy pathdocker-compose.yml
File metadata and controls
181 lines (165 loc) · 4.44 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
# Инфраструктура для локальной разработки и продакшена (Postgres + Redis).
# Приложение (бот, Celery, uvicorn) запускайте на хосте или отдельными контейнерами — см. DEPLOY.md
services:
postgres:
image: postgres:15-alpine
restart: unless-stopped
environment:
POSTGRES_USER: metacleaner
# SECURITY FIX: Убран дефолтный пароль, теперь обязательно требуется переменная
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:?POSTGRES_PASSWORD environment variable is required}
POSTGRES_DB: metacleaner
ports:
- "127.0.0.1:${POSTGRES_PORT:-5432}:5432"
volumes:
- pgdata:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U metacleaner"]
interval: 10s
timeout: 5s
retries: 5
redis:
image: redis:7-alpine
restart: unless-stopped
ports:
- "127.0.0.1:${REDIS_PORT:-6379}:6379"
command: redis-server --appendonly yes
volumes:
- redisdata:/data
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 5s
timeout: 3s
retries: 5
# Только для локальной разработки без systemd
# bot:
# build: .
# command: python -m bot.main
# env_file: .env
# depends_on: [redis]
bot:
build: .
restart: unless-stopped
env_file: .env
depends_on:
postgres:
condition: service_healthy
redis:
condition: service_healthy
volumes:
- temp_data:/app/temp
- logs_data:/app/logs
command: python -m bot
cpus: "1.0"
mem_limit: 1g
# SECURITY FIX: Ограничения ресурсов
deploy:
resources:
limits:
cpus: '1.0'
memory: 1G
reservations:
cpus: '0.25'
memory: 256M
# Health check
healthcheck:
test: ["CMD-SHELL", "python -c 'import sys; sys.exit(0)'"]
interval: 30s
timeout: 10s
retries: 3
start_period: 40s
admin:
build: .
restart: unless-stopped
env_file: .env
ports:
- "${ADMIN_PORT:-8000}:8000"
depends_on:
postgres:
condition: service_healthy
redis:
condition: service_healthy
volumes:
- temp_data:/app/temp
- logs_data:/app/logs
command: python -m admin
cpus: "0.5"
mem_limit: 512m
# SECURITY FIX: Ограничения ресурсов
deploy:
resources:
limits:
cpus: '0.5'
memory: 512M
reservations:
cpus: '0.1'
memory: 128M
# Health check
healthcheck:
test: ["CMD-SHELL", "curl -f http://localhost:8000/health || exit 1"]
interval: 30s
timeout: 10s
retries: 3
start_period: 40s
# worker:
# build: .
# command: celery -A workers.celery_app worker --loglevel=info -Q video,cleanup,broadcast --pool=solo
# env_file: .env
# depends_on: [redis]
worker:
build: .
restart: unless-stopped
env_file: .env
depends_on:
postgres:
condition: service_healthy
redis:
condition: service_healthy
volumes:
- temp_data:/app/temp
- logs_data:/app/logs
command: celery -A workers.celery_app worker -l INFO -c 2 -Q video,broadcast,cleanup,celery
cpus: "2.0"
mem_limit: 4g
# SECURITY FIX: Ограничения ресурсов (больше для обработки видео)
deploy:
resources:
limits:
cpus: '2.0'
memory: 4G
reservations:
cpus: '0.5'
memory: 1G
# Health check
healthcheck:
test: ["CMD-SHELL", "celery -A workers.celery_app inspect ping -d celery@$$HOSTNAME || exit 1"]
interval: 30s
timeout: 10s
retries: 3
start_period: 40s
beat:
build: .
restart: unless-stopped
env_file: .env
depends_on:
postgres:
condition: service_healthy
redis:
condition: service_healthy
command: celery -A workers.celery_app beat -l INFO
cpus: "0.25"
mem_limit: 256m
# SECURITY FIX: Ограничения ресурсов
deploy:
resources:
limits:
cpus: '0.25'
memory: 256M
reservations:
cpus: '0.1'
memory: 64M
volumes:
pgdata:
redisdata:
temp_data:
logs_data: