-
Notifications
You must be signed in to change notification settings - Fork 23
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
238 lines (227 loc) · 6.22 KB
/
docker-compose.yml
File metadata and controls
238 lines (227 loc) · 6.22 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
services:
app:
build:
context: .
target: ${BUILD_TARGET:-main}
command: /code/.venv/bin/fastapi run app/main.py --port 8080 --proxy-headers
env_file: ${APP_VOLUME_PATH:-.}/.env
volumes:
- static_volume:/code/static
- ${APP_VOLUME_PATH:-/tmp}/app-logs:/code/logs
depends_on:
valkey:
condition: service_healthy
postgres:
condition: service_healthy
healthcheck:
test: ["CMD-SHELL", "wget --spider --quiet http://0.0.0.0:8080 || exit 1"]
interval: 5s
timeout: 5s
worker:
build:
context: .
target: ${BUILD_TARGET:-main}
command: /code/.venv/bin/taskiq worker app.adapters.tasks.worker:broker --workers 1
env_file: ${APP_VOLUME_PATH:-.}/.env
ports:
- "${PROMETHEUS_WORKER_PORT:-9091}:9091"
volumes:
- ${APP_VOLUME_PATH:-/tmp}/worker-logs:/code/logs
depends_on:
valkey:
condition: service_healthy
postgres:
condition: service_healthy
healthcheck:
test: ["CMD-SHELL", "pgrep -f 'taskiq worker' || exit 1"]
interval: 10s
timeout: 5s
scheduler:
build:
context: .
target: ${BUILD_TARGET:-main}
command: /code/.venv/bin/taskiq scheduler app.adapters.tasks.worker:scheduler
env_file: ${APP_VOLUME_PATH:-.}/.env
volumes:
- ${APP_VOLUME_PATH:-/tmp}/worker-logs:/code/logs
depends_on:
valkey:
condition: service_healthy
postgres:
condition: service_healthy
healthcheck:
test: ["CMD-SHELL", "pgrep -f 'taskiq scheduler' || exit 1"]
interval: 10s
timeout: 5s
postgres:
image: postgres:18-alpine
environment:
- POSTGRES_DB=${POSTGRES_DB:-overfast}
- POSTGRES_USER=${POSTGRES_USER:-overfast}
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD:-overfast}
volumes:
- pg-data:/var/lib/postgresql
healthcheck:
test:
[
"CMD-SHELL",
"pg_isready -U ${POSTGRES_USER:-overfast} -d ${POSTGRES_DB:-overfast}",
]
interval: 5s
timeout: 3s
retries: 5
valkey:
build:
context: ./build/valkey
command: sh -c "./entrypoint.sh"
env_file: ${APP_VOLUME_PATH:-.}/.env
# Run as privileged to allow the container to change the vm.overcommit_memory setting
privileged: true
restart: always
deploy:
resources:
limits:
memory: ${VALKEY_MEMORY_LIMIT:-1gb}
volumes:
- valkey-data:/data
healthcheck:
test: ["CMD", "valkey-cli", "ping"]
interval: 3s
timeout: 2s
nginx:
build:
context: ./build/nginx
ports:
- "${APP_PORT}:80"
- "${PROMETHEUS_NGINX_PORT:-9145}:9145"
entrypoint: ["/entrypoint.sh"]
env_file: ${APP_VOLUME_PATH:-.}/.env
volumes:
- static_volume:/static
depends_on:
app:
condition: service_healthy
valkey:
condition: service_healthy
healthcheck:
test: ["CMD-SHELL", "wget --spider --quiet http://localhost || exit 1"]
interval: 5s
timeout: 2s
reverse-proxy:
profiles:
- testing
image: nginx:alpine
ports:
- "8080:80"
volumes:
- ./build/reverse-proxy/default.conf:/etc/nginx/conf.d/default.conf
- ./build/reverse-proxy/nginx.conf:/etc/nginx/nginx.conf
depends_on:
nginx:
condition: service_started
healthcheck:
test: ["CMD-SHELL", "wget --spider --quiet http://localhost || exit 1"]
interval: 5s
timeout: 2s
valkey-exporter:
profiles:
- monitoring
- prometheus
image: oliver006/redis_exporter:alpine
environment:
- REDIS_ADDR=valkey:6379
ports:
- "${VALKEY_EXPORTER_PORT:-9121}:9121"
depends_on:
valkey:
condition: service_healthy
healthcheck:
test:
[
"CMD",
"wget",
"-q",
"-O",
"/dev/null",
"http://localhost:9121/metrics",
]
interval: 15s
timeout: 5s
retries: 3
restart: unless-stopped
postgres-exporter:
profiles:
- monitoring
- prometheus
image: prometheuscommunity/postgres-exporter:latest
command: ["--config.file="]
environment:
- DATA_SOURCE_NAME=postgresql://${POSTGRES_USER:-overfast}:${POSTGRES_PASSWORD:-overfast}@postgres:5432/${POSTGRES_DB:-overfast}?sslmode=disable
ports:
- "${POSTGRES_EXPORTER_PORT:-9187}:9187"
depends_on:
postgres:
condition: service_healthy
healthcheck:
test: ["CMD", "wget", "--spider", "-q", "http://localhost:9187/metrics"]
interval: 15s
timeout: 5s
retries: 3
restart: unless-stopped
prometheus:
profiles:
- monitoring
- prometheus
image: prom/prometheus:latest
command:
- "--config.file=/etc/prometheus/prometheus.yml"
- "--storage.tsdb.path=/prometheus"
- "--web.console.libraries=/etc/prometheus/console_libraries"
- "--web.console.templates=/etc/prometheus/consoles"
- "--web.enable-lifecycle"
volumes:
- ./build/prometheus/prometheus.yml:/etc/prometheus/prometheus.yml
- prometheus-data:/prometheus
ports:
- "${PROMETHEUS_PORT:-9090}:9090"
depends_on:
- nginx
- app
restart: unless-stopped
healthcheck:
test: ["CMD", "wget", "--spider", "-q", "http://localhost:9090/-/healthy"]
interval: 10s
timeout: 5s
retries: 3
start_period: 10s
grafana:
profiles:
- monitoring
- grafana
image: grafana/grafana:latest
volumes:
- ./build/grafana/provisioning:/etc/grafana/provisioning
- grafana-data:/var/lib/grafana
ports:
- "${GRAFANA_PORT:-3000}:3000"
environment:
- GF_SECURITY_ADMIN_USER=${GRAFANA_ADMIN_USER:-admin}
- GF_SECURITY_ADMIN_PASSWORD=${GRAFANA_ADMIN_PASSWORD:-admin}
- GF_SERVER_ROOT_URL=${GRAFANA_SERVER_ROOT_URL:-%(protocol)s://%(domain)s:%(http_port)s/}
- GF_USERS_ALLOW_SIGN_UP=false
depends_on:
- prometheus
restart: unless-stopped
healthcheck:
test:
["CMD", "wget", "--spider", "-q", "http://localhost:3000/api/health"]
interval: 10s
timeout: 5s
retries: 3
start_period: 30s
volumes:
static_volume:
valkey-data:
pg-data:
prometheus-data:
grafana-data: