# Reproducible local stack for lab2 (level 3): API + PostgreSQL, named volume. # Copy .env.example to .env and set synthetic local credentials before `docker compose up`. services: db: image: postgres:16-alpine restart: unless-stopped environment: POSTGRES_USER: ${POSTGRES_USER:-messenger} POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:?set a synthetic local password in .env} POSTGRES_DB: ${POSTGRES_DB:-messenger} volumes: - pgdata:/var/lib/postgresql/data ports: - "127.0.0.1:5432:5432" healthcheck: test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER:-messenger} -d ${POSTGRES_DB:-messenger}"] interval: 3s timeout: 3s retries: 20 api: build: . restart: unless-stopped environment: APP_HOST: 0.0.0.0 APP_PORT: 8080 APP_ENV: lab DATABASE_URL: ${DATABASE_URL:?set DATABASE_URL in .env} SESSION_TTL_SECONDS: ${SESSION_TTL_SECONDS:-3600} ports: - "8080:8080" depends_on: db: condition: service_healthy healthcheck: test: ["CMD", "python", "-c", "import os,urllib.request; urllib.request.urlopen('http://127.0.0.1:%s/health/ready' % os.environ.get('APP_PORT','8080'), timeout=2)"] interval: 5s timeout: 3s retries: 20 volumes: pgdata: