forked from Sunyata-OU/Web-Service-Python
-
Notifications
You must be signed in to change notification settings - Fork 0
/
docker-compose.yml
153 lines (145 loc) · 3.83 KB
/
docker-compose.yml
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
version: "3"
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}"
network_mode: host
depends_on:
- db
- minio
- redis_db
volumes:
- ./data/web/logs:/var/log/webapp
command: ./start.sh
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:${SERVICE_PORT}/test"]
interval: 5s
timeout: 30s
retries: 50
redis_db:
image: redis:${REDIS_VERSION}
network_mode: host
ports:
- ${REDIS_PORT}:${REDIS_PORT}
container_name: redis_db
hostname: redis_db
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 5s
timeout: 30s
retries: 50
db:
image: postgres:${POSTGRES_VERSION}
volumes:
- ./data/db:/var/lib/postgresql/data
- ./docker/postgres/init :/docker-entrypoint-initdb.d/
network_mode: host
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: 5s
retries: 5
restart: always
celery:
image: fastapi-service
command: celery -A src.celery worker --loglevel=info
container_name: celery
hostname: celery
depends_on:
- redis_db
network_mode: host
nginx:
image: nginx:alpine
container_name: nginx
hostname: nginx
ports:
- mode: host
protocol: tcp
published: 80
target: 80
- mode: host
protocol: tcp
published: 443
target: 443
volumes:
- ./nginx:/etc/nginx/conf.d
- ./certbot/conf:/etc/letsencrypt
- ./certbot/www:/var/www/certbot
command: '/bin/sh -c ''while :; do sleep 6h & wait $${!}; nginx -s reload; done & nginx -g "daemon off;"'''
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:80"]
interval: 5s
timeout: 30s
retries: 50
profiles:
- nginx
certbot:
image: certbot/certbot
container_name: certbot
hostname: certbot
volumes:
- ./certbot/conf:/etc/letsencrypt
- ./certbot/www:/var/www/certbot
entrypoint: "/bin/sh -c 'trap exit TERM; while :; do certbot renew; sleep 12h & wait $${!}; done;'"
profiles:
- nginx
minio:
image: minio/minio:${MINIO_VERSION}
container_name: minio
hostname: minio
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:
- ${PWD}/data/minio:/data
healthcheck:
test:
[
"CMD",
"curl",
"-f",
"http://localhost:${MINIO_SERVER_PORT}/minio/health/live",
]
interval: 5s
timeout: 30s
retries: 50
createbuckets:
image: minio/mc
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;
"