Files
mtusi2026lab2-fork/compose.yaml

60 lines
1.4 KiB
YAML

x-app: &app
image: mtusi-messenger:lab2
env_file: .env
environment:
CURSOR_KEY_FILE: /run/secrets/cursor_key
SESSION_TTL_SECONDS: ${SESSION_TTL_SECONDS:-3600}
secrets: [database_url, cache_url, cursor_key]
services:
db:
image: postgres:17.5-alpine
environment:
POSTGRES_USER: messenger
POSTGRES_DB: messenger
POSTGRES_PASSWORD_FILE: /run/secrets/db_password
secrets: [db_password]
volumes: [pgdata:/var/lib/postgresql/data]
healthcheck:
test: ["CMD-SHELL", "pg_isready -U messenger -d messenger"]
interval: 2s
timeout: 2s
retries: 20
cache:
image: redis:7.4.3-alpine
command: ["redis-server", "--save", "", "--appendonly", "no", "--maxmemory", "32mb", "--maxmemory-policy", "allkeys-lru"]
migrate:
<<: *app
build: .
command: ["python", "src/migrate.py"]
healthcheck:
disable: true
depends_on:
db:
condition: service_healthy
api:
<<: *app
ports: ["127.0.0.1:${PUBLIC_PORT:-8080}:${APP_PORT:-8080}"]
depends_on:
migrate:
condition: service_completed_successfully
cache:
condition: service_started
stop_grace_period: 8s
secrets:
db_password:
file: ./secrets/db_password
database_url:
file: ./secrets/database_url
cache_url:
file: ./secrets/cache_url
cursor_key:
file: ./secrets/cursor_key
volumes:
pgdata: