-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
226 lines (217 loc) · 5.63 KB
/
docker-compose.yml
File metadata and controls
226 lines (217 loc) · 5.63 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
services:
postgres:
image: postgres:15-alpine
environment:
POSTGRES_USER: ${POSTGRES_USER:-postgres}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-postgres_password}
POSTGRES_DB: ${POSTGRES_DB:-ai_email_db}
ports:
- "5434:5432"
volumes:
- postgres_data:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER:-postgres} -d ${POSTGRES_DB:-ai_email_db}"]
interval: 10s
timeout: 5s
retries: 5
deploy:
resources:
limits:
cpus: '1.0'
memory: 1G
networks:
- app-network
redis:
image: redis:7-alpine
command: redis-server --appendonly yes --maxmemory 256mb --maxmemory-policy noeviction
ports:
- "6381:6379"
volumes:
- redis_data:/data
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 10s
timeout: 5s
retries: 5
deploy:
resources:
limits:
cpus: '0.5'
memory: 512M
networks:
- app-network
api:
build:
context: .
dockerfile: Dockerfile
command: uvicorn src.main:app --host 0.0.0.0 --port 8000 --reload
ports:
- "8002:8000"
env_file:
- .env
depends_on:
postgres:
condition: service_healthy
redis:
condition: service_healthy
volumes:
- ./src:/app/src
- ./token.json:/app/token.json
- ./credentials.json:/app/credentials.json
healthcheck:
test: ["CMD-SHELL", "curl -f http://localhost:8000/health || exit 1"]
interval: 15s
timeout: 5s
retries: 3
start_period: 10s
deploy:
resources:
limits:
cpus: '0.5'
memory: 512M
networks:
- app-network
celery-worker:
build:
context: .
dockerfile: Dockerfile
# Встановлюємо worker_shutdown_timeout рівним grace period, щоб Celery не чекав вічно
command: celery -A src.workers.celery_app worker -P threads -c 4 -E --loglevel=info
env_file:
- .env
depends_on:
redis:
condition: service_healthy
postgres:
condition: service_healthy
volumes:
- ./src:/app/src
- ./token.json:/app/token.json
- ./credentials.json:/app/credentials.json
healthcheck:
test: ["CMD-SHELL", "celery -A src.workers.celery_app inspect ping || exit 1"]
interval: 30s
timeout: 10s
retries: 3
start_period: 20s
stop_grace_period: 60s
deploy:
resources:
limits:
cpus: '1.0'
memory: 1G
networks:
- app-network
celery-beat:
build:
context: .
dockerfile: Dockerfile
command: celery -A src.workers.celery_app beat --loglevel=info
env_file:
- .env
depends_on:
redis:
condition: service_healthy
volumes:
- ./src:/app/src
- ./token.json:/app/token.json
- ./credentials.json:/app/credentials.json
stop_grace_period: 60s
deploy:
resources:
limits:
cpus: '0.2'
memory: 256M
networks:
- app-network
celery-exporter:
build:
context: .
dockerfile: Dockerfile
command: >
sh -c "pip install celery-prometheus-exporter &&
celery-prometheus-exporter --broker=${REDIS_URL:-redis://redis:6379/0} --addr=0.0.0.0:9808 --enable-events --queue-list default"
ports:
- "9808:9808"
networks:
- app-network
redis-exporter:
image: oliver006/redis_exporter:latest
environment:
- REDIS_ADDR=redis:6379
ports:
- "9121:9121"
networks:
- app-network
postgres-exporter:
image: prometheuscommunity/postgres-exporter:latest
environment:
DATA_SOURCE_NAME: "user=${POSTGRES_USER:-postgres} password=${POSTGRES_PASSWORD:-postgres_password} host=postgres port=5432 dbname=postgres sslmode=disable"
ports:
- "9187:9187"
networks:
- app-network
alertmanager:
image: prom/alertmanager:v0.25.0
ports:
- "9093:9093"
volumes:
- ./monitoring/alertmanager/config.yml:/etc/alertmanager/config.yml
command:
- '--config.file=/etc/alertmanager/config.yml'
networks:
- app-network
prometheus:
image: prom/prometheus:v2.45.0
volumes:
- ./monitoring/prometheus/prometheus.yml:/etc/prometheus/prometheus.yml
- ./monitoring/prometheus/alerts.yml:/etc/prometheus/alerts.yml
- prometheus_data:/prometheus
ports:
- "9092:9090"
command:
- '--config.file=/etc/prometheus/prometheus.yml'
- '--storage.tsdb.path=/prometheus'
networks:
- app-network
grafana:
image: grafana/grafana:10.0.3
ports:
- "3002:3000"
volumes:
- grafana_data:/var/lib/grafana
- ./monitoring/grafana/datasources:/etc/grafana/provisioning/datasources
environment:
- GF_SECURITY_ADMIN_PASSWORD=admin
networks:
- app-network
loki:
image: grafana/loki:2.8.2
ports:
- "3102:3100"
volumes:
- ./monitoring/loki/loki-config.yml:/etc/loki/local-config.yaml
- loki_data:/loki
command: -config.file=/etc/loki/local-config.yaml
networks:
- app-network
promtail:
image: grafana/promtail:2.8.2
volumes:
- ./monitoring/promtail/promtail-config.yml:/etc/promtail/config.yml
- /var/run/docker.sock:/var/run/docker.sock:ro
- /var/lib/docker/containers:/var/lib/docker/containers:ro
command: -config.file=/etc/promtail/config.yml
depends_on:
- loki
networks:
- app-network
networks:
app-network:
driver: bridge
volumes:
postgres_data:
redis_data:
prometheus_data:
grafana_data:
loki_data: