Files
mtusi2026lab3/compose.yaml
2026-11-24 23:07:02 +03:00

65 lines
1.5 KiB
YAML

x-api: &api-common
build:
context: .
dockerfile: Dockerfile
depends_on:
postgres:
condition: service_healthy
migrate:
condition: service_completed_successfully
stop_grace_period: 15s
services:
postgres:
image: postgres:16-alpine
environment:
POSTGRES_USER: messenger
POSTGRES_PASSWORD: secret_password
POSTGRES_DB: messenger_db
volumes:
- postgres_data:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U messenger -d messenger_db"]
interval: 3s
timeout: 3s
retries: 5
migrate:
build: .
command: ["python", "-m", "api.migrate"]
environment:
DATABASE_URL: postgresql://messenger:secret_password@postgres:5432/messenger_db
depends_on:
postgres:
condition: service_healthy
healthcheck:
disable: true
api1:
<<: *api-common
environment:
DATABASE_URL: postgresql://messenger:secret_password@postgres:5432/messenger_db
SESSION_TTL_SECONDS: 3600
INSTANCE_ID: api1
api2:
<<: *api-common
environment:
DATABASE_URL: postgresql://messenger:secret_password@postgres:5432/messenger_db
SESSION_TTL_SECONDS: 3600
INSTANCE_ID: api2
nginx:
image: nginx:1.28-alpine
ports:
- "8080:8080"
volumes:
- ./infra/nginx.conf:/etc/nginx/nginx.conf:ro
depends_on:
api1:
condition: service_healthy
api2:
condition: service_healthy
volumes:
postgres_data: