forked from mtusi2026/mtusi2026lab2
70 lines
2.1 KiB
YAML
70 lines
2.1 KiB
YAML
services:
|
|
api:
|
|
build: .
|
|
restart: unless-stopped
|
|
environment:
|
|
APP_HOST: 0.0.0.0
|
|
APP_PORT: 8080
|
|
SESSION_TTL_SECONDS: ${SESSION_TTL_SECONDS:-3600}
|
|
DATABASE_URL: postgresql://${POSTGRES_USER:-messenger}:${POSTGRES_PASSWORD:?Set POSTGRES_PASSWORD in .env}@postgres:5432/${POSTGRES_DB:-messenger}
|
|
CACHE_URL: redis://valkey:6379/0
|
|
DB_POOL_MAX: ${DB_POOL_MAX:-10}
|
|
ports:
|
|
- "127.0.0.1:${APP_PORT:-8080}:8080"
|
|
depends_on:
|
|
postgres:
|
|
condition: service_healthy
|
|
valkey:
|
|
condition: service_healthy
|
|
healthcheck:
|
|
test: ["CMD", "python", "-c", "import urllib.request; urllib.request.urlopen('http://127.0.0.1:8080/health/ready', timeout=2)"]
|
|
interval: 10s
|
|
timeout: 3s
|
|
retries: 5
|
|
start_period: 20s
|
|
postgres:
|
|
image: postgres:16.4-bookworm
|
|
restart: unless-stopped
|
|
environment:
|
|
POSTGRES_USER: ${POSTGRES_USER:-messenger}
|
|
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:?Set POSTGRES_PASSWORD in .env}
|
|
POSTGRES_DB: ${POSTGRES_DB:-messenger}
|
|
volumes:
|
|
- postgres_data:/var/lib/postgresql/data
|
|
healthcheck:
|
|
test: ["CMD-SHELL", "pg_isready -U \"$$POSTGRES_USER\" -d \"$$POSTGRES_DB\""]
|
|
interval: 5s
|
|
timeout: 3s
|
|
retries: 10
|
|
start_period: 10s
|
|
postgres_restore:
|
|
image: postgres:16.4-bookworm
|
|
profiles: ["restore"]
|
|
restart: "no"
|
|
environment:
|
|
POSTGRES_USER: ${POSTGRES_USER:-messenger}
|
|
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:?Set POSTGRES_PASSWORD in .env}
|
|
POSTGRES_DB: ${POSTGRES_DB:-messenger}
|
|
volumes:
|
|
- restore_data:/var/lib/postgresql/data
|
|
healthcheck:
|
|
test: ["CMD-SHELL", "pg_isready -U \"$$POSTGRES_USER\" -d \"$$POSTGRES_DB\""]
|
|
interval: 5s
|
|
timeout: 3s
|
|
retries: 10
|
|
valkey:
|
|
image: valkey/valkey:8.0.1-alpine
|
|
restart: unless-stopped
|
|
command: ["valkey-server", "--appendonly", "yes", "--appendfsync", "everysec"]
|
|
volumes:
|
|
- valkey_data:/data
|
|
healthcheck:
|
|
test: ["CMD", "valkey-cli", "ping"]
|
|
interval: 5s
|
|
timeout: 3s
|
|
retries: 10
|
|
volumes:
|
|
postgres_data:
|
|
valkey_data:
|
|
restore_data:
|