Files
mtusi2026lab3/compose.yaml
T

60 lines
1.4 KiB
YAML

name: messenger-lab3
x-api: &api
build: .
environment: &environment
LAB_NUMBER: "3"
DATABASE_URL: postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@postgres:5432/${POSTGRES_DB}
SESSION_TTL_SECONDS: ${SESSION_TTL_SECONDS:-3600}
depends_on:
migrate:
condition: service_completed_successfully
healthcheck:
test: ["CMD", "python", "-c", "import urllib.request; urllib.request.urlopen('http://localhost:8000/health/ready', timeout=3)"]
interval: 3s
timeout: 5s
retries: 5
stop_grace_period: 10s
mem_limit: 512m
cpus: 1.0
services:
postgres:
image: postgres:16.8-alpine
environment:
POSTGRES_DB: ${POSTGRES_DB}
POSTGRES_USER: ${POSTGRES_USER}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
volumes:
- postgres_data:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U $$POSTGRES_USER -d $$POSTGRES_DB"]
interval: 2s
timeout: 3s
retries: 30
migrate:
build: .
environment: *environment
command: ["python", "-m", "app.migrate"]
depends_on:
postgres:
condition: service_healthy
api1:
<<: *api
api2:
<<: *api
lb:
image: haproxy:3.0.10-alpine
ports:
- "127.0.0.1:${PUBLIC_PORT}:8080"
volumes:
- ./infra/haproxy.cfg:/usr/local/etc/haproxy/haproxy.cfg:ro
depends_on:
api1:
condition: service_healthy
api2:
condition: service_healthy
volumes:
postgres_data: