forked from lulzseq/fullstack-fastapi-react
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
284 lines (267 loc) · 6.37 KB
/
docker-compose.yml
File metadata and controls
284 lines (267 loc) · 6.37 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
282
283
284
services:
postgres:
image: postgres:16
container_name: postgres
restart: always
healthcheck:
test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER?Variable not set} -d ${POSTGRES_DB?Variable not set}"]
interval: 10s
retries: 5
start_period: 60s
timeout: 10s
env_file:
- .env
volumes:
- postgres_data:/var/lib/postgresql/data
pgadmin:
container_name: pgadmin
image: dpage/pgadmin4:latest
env_file:
- .env
volumes:
- pgadmin_data:/var/lib/pgadmin
ports:
- "127.0.0.1:5050:80"
restart: always
depends_on:
- postgres
postgres_exporter:
container_name: postgres_exporter
image: prometheuscommunity/postgres-exporter:latest
environment:
DATA_SOURCE_URI: "postgres:5432/${POSTGRES_DB}?sslmode=disable"
DATA_SOURCE_USER: "${POSTGRES_USER?Variable not set}"
DATA_SOURCE_PASS: "${POSTGRES_PASSWORD?Variable not set}"
expose:
- "9187"
restart: always
depends_on:
- postgres
rabbitmq:
image: rabbitmq:4-management
container_name: rabbitmq
restart: always
expose:
- "5672"
ports:
- "127.0.0.1:15672:15672"
healthcheck:
test: ["CMD", "rabbitmq-diagnostics", "ping"]
interval: 10s
start_period: 60s
timeout: 60s
retries: 3
volumes:
- ./rabbitmq/rabbitmq.conf:/etc/rabbitmq/rabbitmq.conf:ro
- rabbitmq_data:/var/lib/rabbitmq
env_file:
- .env
rabbit_worker:
build:
context: ./backend
command: python app/core/rabbit_mq.py
container_name: rabbit_worker
restart: always
depends_on:
- rabbitmq
env_file:
- .env
redis:
image: redis:latest
container_name: redis
restart: always
expose:
- "6379"
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 5s
timeout: 10s
retries: 5
promtail:
image: grafana/promtail:latest
container_name: promtail
expose:
- "9080"
volumes:
- /var/lib/docker/containers:/var/lib/docker/containers:ro
- /var/run/docker.sock:/var/run/docker.sock
- ./monitoring/promtail/promtail-config.yaml:/etc/promtail/config.yml
command: -config.file=/etc/promtail/config.yml
env_file:
- .env
logging:
driver: json-file
options:
max-size: "10m"
max-file: "3"
loki:
image: grafana/loki:latest
container_name: loki
expose:
- "3100"
volumes:
- ./monitoring/loki/loki-config.yaml:/etc/loki/local-config.yaml
- ./monitoring/loki/data:/loki
command: -config.file=/etc/loki/local-config.yaml
env_file:
- .env
healthcheck:
test: ["CMD", "wget", "--spider", "-q", "http://localhost:3100/ready"]
interval: 30s
timeout: 5s
retries: 3
start_period: 60s
logging:
driver: json-file
options:
max-size: "10m"
max-file: "3"
prometheus:
image: prom/prometheus:latest
container_name: prometheus
ports:
- "127.0.0.1:9090:9090"
volumes:
- ./monitoring/prometheus/prometheus.yml:/etc/prometheus/prometheus.yml
- prometheus_data:/prometheus
command:
- '--config.file=/etc/prometheus/prometheus.yml'
- '--log.level=warn'
env_file:
- .env
logging:
driver: json-file
options:
max-size: "10m"
max-file: "3"
grafana:
image: grafana/grafana:latest
container_name: grafana
ports:
- "127.0.0.1:3000:3000"
volumes:
- ./monitoring/grafana/grafana.ini:/etc/grafana/grafana.ini
- ./monitoring/grafana/provisioning:/etc/grafana/provisioning
- grafana_data:/var/lib/grafana
env_file:
- .env
logging:
driver: json-file
options:
max-size: "10m"
max-file: "3"
prestart:
build:
context: ./backend
container_name: prestart
depends_on:
postgres:
condition: service_healthy
command: bash /app/scripts/prestart.sh
env_file:
- .env
backend:
build:
context: ./backend
container_name: backend
restart: always
depends_on:
prestart:
condition: service_completed_successfully
restart: true
redis:
condition: service_healthy
restart: true
postgres:
condition: service_healthy
restart: true
rabbitmq:
condition: service_healthy
restart: true
env_file:
- .env
expose:
- "8000"
dns:
- 8.8.8.8
- 1.1.1.1
logging:
driver: json-file
options:
tag: "{{.ImageName}}|{{.Name}}|{{.ImageFullID}}|{{.FullID}}"
max-size: "10m"
max-file: "3"
healthcheck:
test: ["CMD", "python", "-c", "import urllib.request; urllib.request.urlopen('http://localhost:8000/health')"]
interval: 30s
timeout: 20s
retries: 3
start_period: 60s
frontend:
build:
context: ./frontend
target: production
container_name: frontend
restart: always
depends_on:
backend:
condition: service_healthy
ports:
- "80:80"
env_file:
- .env
healthcheck:
test: ["CMD", "wget", "--quiet", "--tries=1", "--spider", "http://127.0.0.1/health"]
interval: 30s
timeout: 10s
retries: 3
start_period: 60s
logging:
driver: json-file
options:
max-size: "10m"
max-file: "3"
nginx-exporter:
image: nginx/nginx-prometheus-exporter:latest
container_name: nginx_exporter
expose:
- "9113"
command:
- -nginx.scrape-uri=http://frontend/nginx_status
depends_on:
- frontend
restart: always
healthcheck:
test: ["CMD", "wget", "--quiet", "--tries=1", "--spider", "http://localhost:9113/metrics"]
interval: 30s
timeout: 10s
retries: 3
start_period: 10s
cleanup:
image: alpine:latest
container_name: cleanup_scheduler
volumes:
- /var/run/docker.sock:/var/run/docker.sock
command: >
sh -c "
apk add --no-cache docker-cli &&
while true; do
sleep 300;
docker system prune -af --volumes;
sleep 86400;
done
"
restart: always
deploy:
resources:
limits:
memory: 128M
volumes:
postgres_data:
pgadmin_data:
rabbitmq_data:
grafana_data:
prometheus_data:
networks:
default:
driver: bridge