forked from mtusi2026/mtusi2026lab2
84 lines
1.9 KiB
YAML
84 lines
1.9 KiB
YAML
services:
|
|
postgres:
|
|
image: postgres:16.6-alpine
|
|
environment:
|
|
POSTGRES_DB: messenger
|
|
POSTGRES_USER: messenger
|
|
POSTGRES_PASSWORD_FILE: /run/secrets/database_password
|
|
secrets:
|
|
- database_password
|
|
volumes:
|
|
- postgres_data:/var/lib/postgresql/data
|
|
healthcheck:
|
|
test: ["CMD-SHELL", "pg_isready -U messenger -d messenger"]
|
|
interval: 3s
|
|
timeout: 3s
|
|
retries: 20
|
|
restart: unless-stopped
|
|
networks:
|
|
- backend
|
|
|
|
redis:
|
|
image: redis:7.4.2-alpine
|
|
command: ["redis-server", "--appendonly", "yes", "--appendfsync", "everysec"]
|
|
volumes:
|
|
- redis_data:/data
|
|
healthcheck:
|
|
test: ["CMD", "redis-cli", "ping"]
|
|
interval: 3s
|
|
timeout: 3s
|
|
retries: 20
|
|
restart: unless-stopped
|
|
networks:
|
|
- backend
|
|
|
|
api:
|
|
build:
|
|
context: .
|
|
dockerfile: Dockerfile
|
|
environment:
|
|
APP_HOST: 0.0.0.0
|
|
APP_PORT: 8080
|
|
SESSION_TTL_SECONDS: ${SESSION_TTL_SECONDS:-3600}
|
|
DB_HOST: postgres
|
|
DB_PORT: 5432
|
|
DB_NAME: messenger
|
|
DB_USER: messenger
|
|
DB_PASSWORD_FILE: /run/secrets/database_password
|
|
DB_POOL_MAX_SIZE: ${DB_POOL_MAX_SIZE:-10}
|
|
REDIS_URL: redis://redis:6379/0
|
|
secrets:
|
|
- database_password
|
|
depends_on:
|
|
postgres:
|
|
condition: service_healthy
|
|
redis:
|
|
condition: service_healthy
|
|
ports:
|
|
- "${APP_PORT:-8080}:8080"
|
|
healthcheck:
|
|
test:
|
|
- CMD
|
|
- python
|
|
- -c
|
|
- "import urllib.request; urllib.request.urlopen('http://127.0.0.1:8080/health/ready', timeout=2)"
|
|
interval: 5s
|
|
timeout: 3s
|
|
retries: 20
|
|
start_period: 10s
|
|
restart: unless-stopped
|
|
networks:
|
|
- backend
|
|
|
|
secrets:
|
|
database_password:
|
|
file: ./secrets/database_password
|
|
|
|
volumes:
|
|
postgres_data:
|
|
redis_data:
|
|
|
|
networks:
|
|
backend:
|
|
driver: bridge
|