-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
291 lines (282 loc) · 6.43 KB
/
docker-compose.yml
File metadata and controls
291 lines (282 loc) · 6.43 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
285
286
287
288
289
290
291
networks:
app-network:
driver: bridge
volumes:
postgres_data:
redis_data:
minio_data:
nginx_logs:
app_logs:
services:
fastapi:
build:
context: .
dockerfile: docker/fastapi-service/DockerFile
ssh:
- default
args:
PYTHON_VERSION: ${PYTHON_VERSION}
SERVICE_PORT: ${SERVICE_PORT}
WORKERS_COUNT: ${WORKERS_COUNT}
container_name: fastapi-service
hostname: fastapi-service
env_file:
- .env
image: fastapi-service
ports:
- "${SERVICE_PORT}:${SERVICE_PORT}"
networks:
- app-network
depends_on:
- db
- minio
- redis_db
volumes:
- app_logs:/var/log/webapp
command: ./start.sh
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:${SERVICE_PORT}/test"]
interval: 30s
timeout: 10s
retries: 3
start_period: 40s
deploy:
resources:
limits:
memory: 512M
cpus: '1.0'
reservations:
memory: 256M
cpus: '0.5'
logging:
driver: "json-file"
options:
max-size: "10m"
max-file: "3"
restart: unless-stopped
redis_db:
image: redis:${REDIS_VERSION}
networks:
- app-network
ports:
- ${REDIS_PORT}:${REDIS_PORT}
container_name: redis_db
hostname: redis_db
volumes:
- redis_data:/data
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 30s
timeout: 10s
retries: 3
start_period: 20s
deploy:
resources:
limits:
memory: 128M
cpus: '0.5'
reservations:
memory: 64M
cpus: '0.25'
logging:
driver: "json-file"
options:
max-size: "10m"
max-file: "3"
restart: unless-stopped
db:
image: postgres:${POSTGRES_VERSION}
volumes:
- postgres_data:/var/lib/postgresql/data
- ./docker/postgres/init:/docker-entrypoint-initdb.d/
networks:
- app-network
container_name: db
hostname: db
ports:
- ${POSTGRES_PORT}:${POSTGRES_PORT}
environment:
- POSTGRES_DB=${POSTGRES_DB}
- POSTGRES_USER=${POSTGRES_USER}
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
healthcheck:
test: ["CMD", "pg_isready", "-U", "${POSTGRES_USER}"]
interval: 30s
timeout: 10s
retries: 3
start_period: 40s
deploy:
resources:
limits:
memory: 256M
cpus: '0.5'
reservations:
memory: 128M
cpus: '0.25'
logging:
driver: "json-file"
options:
max-size: "10m"
max-file: "3"
restart: unless-stopped
celery:
image: fastapi-service
command: celery -A src.celery worker --loglevel=info
container_name: celery
hostname: celery
env_file:
- .env
networks:
- app-network
depends_on:
- redis_db
- db
deploy:
resources:
limits:
memory: 256M
cpus: '0.5'
reservations:
memory: 128M
cpus: '0.25'
logging:
driver: "json-file"
options:
max-size: "10m"
max-file: "3"
restart: unless-stopped
nginx:
image: nginx:1.25-alpine
container_name: nginx
hostname: nginx
networks:
- app-network
ports:
- "80:80"
- "443:443"
volumes:
- ./nginx:/etc/nginx/conf.d:ro
- ./certbot/conf:/etc/letsencrypt:ro
- ./certbot/www:/var/www/certbot:ro
- nginx_logs:/var/log/nginx
command: '/bin/sh -c ''while :; do sleep 6h & wait $${!}; nginx -s reload; done & nginx -g "daemon off;"'''
depends_on:
- fastapi
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost/health"]
interval: 30s
timeout: 10s
retries: 3
start_period: 30s
deploy:
resources:
limits:
memory: 64M
cpus: '0.25'
reservations:
memory: 32M
cpus: '0.1'
logging:
driver: "json-file"
options:
max-size: "10m"
max-file: "3"
restart: unless-stopped
profiles:
- nginx
certbot:
image: certbot/certbot:latest
container_name: certbot
hostname: certbot
networks:
- app-network
volumes:
- ./certbot/conf:/etc/letsencrypt
- ./certbot/www:/var/www/certbot
entrypoint: "/bin/sh -c 'trap exit TERM; while :; do certbot renew --quiet; sleep 12h & wait $${!}; done;'"
depends_on:
- nginx
deploy:
resources:
limits:
memory: 64M
cpus: '0.25'
reservations:
memory: 32M
cpus: '0.1'
logging:
driver: "json-file"
options:
max-size: "10m"
max-file: "3"
restart: unless-stopped
profiles:
- nginx
minio:
image: minio/minio:${MINIO_VERSION}
container_name: minio
hostname: minio
networks:
- app-network
command: server --address ":${S3_PORT}" --console-address ":${MINIO_SERVER_PORT}" /data
ports:
- ${S3_PORT}:${S3_PORT}
- ${MINIO_SERVER_PORT}:${MINIO_SERVER_PORT}
environment:
- MINIO_ROOT_USER=${S3_ACCESS_KEY_ID}
- MINIO_ROOT_PASSWORD=${S3_ACCESS_KEY}
volumes:
- minio_data:/data
healthcheck:
test:
[
"CMD",
"curl",
"-f",
"http://localhost:${MINIO_SERVER_PORT}/minio/health/live",
]
interval: 30s
timeout: 10s
retries: 3
start_period: 30s
deploy:
resources:
limits:
memory: 128M
cpus: '0.5'
reservations:
memory: 64M
cpus: '0.25'
logging:
driver: "json-file"
options:
max-size: "10m"
max-file: "3"
restart: unless-stopped
createbuckets:
image: minio/mc
networks:
- app-network
depends_on:
- minio
entrypoint: >
/bin/sh -c "
/usr/bin/mc alias set myminio "http://minio:${S3_PORT}" "${S3_ACCESS_KEY_ID}" "${S3_ACCESS_KEY}";
/usr/bin/mc admin info myminio;
/usr/bin/mc mb myminio/clickhouse;
/usr/bin/mc policy set public myminio/clickhouse;
if [ -z "${S3_BUCKET}" ]; then exit 0; fi;
/usr/bin/mc mb myminio/${S3_BUCKET}
/usr/bin/mc policy set public myminio/${S3_BUCKET};
exit 0;
"
deploy:
resources:
limits:
memory: 64M
cpus: '0.25'
logging:
driver: "json-file"
options:
max-size: "10m"
max-file: "3"