-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
73 lines (68 loc) · 1.79 KB
/
docker-compose.yml
File metadata and controls
73 lines (68 loc) · 1.79 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
networks:
chat_network:
driver: bridge
services:
db:
image: postgres:${POSTGRES_VERSION}
volumes:
- postgres_data:/var/lib/postgresql/data
- ./chat_service/init.sql:/docker-entrypoint-initdb.d/init.sql
environment:
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
- POSTGRES_DB=${DB_NAME}
ports:
- "${DB_PORT}:5432"
networks:
- chat_network
healthcheck:
test: [ "CMD-SHELL", "pg_isready -U postgres -d ${DB_NAME}" ]
interval: 5s
timeout: 5s
retries: 5
chat_service:
build:
context: chat_service
args:
PYTHON_VERSION: ${PYTHON_VERSION}
volumes:
- ./chat_service:/app
ports:
- "${APP_PORT}:${APP_PORT}"
environment:
- DATABASE_URL=postgresql+asyncpg://postgres:${POSTGRES_PASSWORD}@db:${DB_PORT}/${DB_NAME}
- SECRET_KEY=${SECRET_KEY}
- REFRESH_SECRET_KEY=${REFRESH_SECRET_KEY}
- REDIS_HOST=${REDIS_HOST}
- REDIS_PORT=${REDIS_PORT}
depends_on:
db:
condition: service_healthy
redis:
condition: service_healthy
networks:
- chat_network
command: >
sh -c "
until pg_isready -h db -p 5432 -U postgres; do echo 'Waiting for database...'; sleep 2; done;
psql -U postgres -h db -d ${DB_NAME} -f /app/init.sql;
uvicorn app.main:app --host 0.0.0.0 --port 8000 --reload
"
redis:
image: redis:${REDIS_VERSION}
restart: always
healthcheck:
test: [ "CMD-SHELL", "redis-cli ping | grep PONG" ]
interval: 1s
timeout: 3s
retries: 5
command: redis-server
ports:
- "${REDIS_PORT}:6379"
volumes:
- redis_data:/data
networks:
- chat_network
volumes:
postgres_data:
redis_data: