-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdocker-compose.yaml
116 lines (111 loc) · 3.54 KB
/
docker-compose.yaml
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
services:
postgres:
image: postgres:16.3
restart: always
environment:
POSTGRES_DB: chatterboxdb
POSTGRES_USER: postgres
POSTGRES_PASSWORD_FILE: /run/secrets/chatterbox_backend/postgres_superuser_password.txt
POSTGRES_INITDB_ARGS: "--username=postgres --pwfile=/run/secrets/chatterbox_backend/postgres_superuser_password.txt"
volumes:
- postgres_data:/var/lib/postgresql/data
- ./secrets/chatterbox_backend/:/run/secrets/chatterbox_backend
- ./init-db.sh:/docker-entrypoint-initdb.d/init-db.sh
ports:
- "5432:5432"
healthcheck:
test: "pg_isready -U postgres -d chatterboxdb -h localhost -p 5432 > /tmp/pg_isready.log 2>&1 || (cat /tmp/pg_isready.log && exit 1)"
interval: 10s
timeout: 10s
retries: 5
test-postgres:
image: postgres:16.3
restart: always
environment:
POSTGRES_DB: chatterbox_testdb
POSTGRES_USER: postgres
POSTGRES_PASSWORD_FILE: /run/secrets/chatterbox_backend/test_postgres_superuser_password.txt
POSTGRES_INITDB_ARGS: "--username=postgres --pwfile=/run/secrets/chatterbox_backend/test_postgres_superuser_password.txt"
volumes:
- test_postgres_data:/var/lib/postgresql/data
- ./secrets/chatterbox_backend/:/run/secrets/chatterbox_backend
- ./init-test-db.sh:/docker-entrypoint-initdb.d/init-db.sh
ports:
- "5433:5432"
healthcheck:
test: "pg_isready -U postgres -d chatterboxdb -h localhost -p 5432 > /tmp/pg_isready.log 2>&1 || (cat /tmp/pg_isready.log && exit 1)"
interval: 30s
timeout: 10s
retries: 5
chatterbox_backend:
build:
context: .
dockerfile: Dockerfile-chatterbox-backend
command: >
uvicorn chatterbox_backend.__init__:app
--host 0.0.0.0
--port 8000
--ssl-keyfile /run/secrets/cert/key.pem
--ssl-certfile /run/secrets/cert/cert.pem
restart: "no"
environment:
ENVIRONMENT: prod
LOG_CFG: /app/chatterbox_backend/logging_config.yaml
LOCAL_TIMEZONE: America/New_York
CERT_PASSKEY: ${CERT_PASSKEY}
CERT_PATH: /run/secrets/certs/cert.pem
KEY_PATH: /run/secrets/certs/key.pem
DATABASE_PREFIX: postgresql+asyncpg://
DATABASE_NAME: chatterboxdb
DATABASE_USER_FILE: /run/secrets/chatterbox_backend/postgres_user.txt
DATABASE_USER_PASSWORD_FILE: /run/secrets/chatterbox_backend/postgres_password.txt
DB_SERVICE_NAME: postgres
DB_PORT: 5432
TEST_DB_NAME: chatterbox_testdb
TEST_DATABASE_USER_FILE: /run/secrets/chatterbox_backend/test_postgres_user.txt
TEST_DB_SERVICE_NAME: test-postgres
TEST_DB_PORT: 5433
REDIS_HOST: redis
REDIS_PORT: 6379
REDIS_DB_INDEX: 0
volumes:
- ./logs:/app/logs
ports:
- "8000:8000"
depends_on:
postgres:
condition: service_healthy
test-postgres:
condition: service_healthy
redis:
condition: service_healthy
test-redis:
condition: service_healthy
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8000/test"]
interval: 30s
timeout: 10s
retries: 3
redis:
image: redis:7.0
ports:
- "6379:6379"
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 30s
timeout: 10s
retries: 5
test-redis:
image: redis:7.0
ports:
- "63790:6379"
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 30s
timeout: 10s
retries: 5
volumes:
postgres_data:
driver: local
test_postgres_data:
driver: local