services: postgres: image: postgres:16.4-alpine environment: POSTGRES_DB: ${POSTGRES_DB:-messenger} POSTGRES_USER: ${POSTGRES_USER:-messenger} POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:?set POSTGRES_PASSWORD in .env} volumes: - postgres-data:/var/lib/postgresql/data healthcheck: test: ["CMD-SHELL", "pg_isready -U $${POSTGRES_USER} -d $${POSTGRES_DB}"] interval: 5s timeout: 3s retries: 20 redis: image: redis:7.4.2-alpine command: ["redis-server", "--appendonly", "yes", "--appendfsync", "everysec"] volumes: - redis-data:/data healthcheck: test: ["CMD", "redis-cli", "ping"] interval: 5s timeout: 3s retries: 20 migrate: build: context: . dockerfile: Dockerfile image: mtusi-messenger:lab3 command: ["node", "dist/database/migration.runner.js"] env_file: [.env] depends_on: postgres: { condition: service_healthy } redis: { condition: service_healthy } restart: "no" api: build: context: . dockerfile: Dockerfile image: mtusi-messenger:lab3 ports: - "${APP_PUBLIC_PORT:-8080}:${APP_PORT:-8080}" env_file: [.env] environment: CACHE_MODE: ${CACHE_MODE:-protected} CACHE_MISS_DELAY_MS: ${CACHE_MISS_DELAY_MS:-0} SESSION_TTL_SECONDS: ${SESSION_TTL_SECONDS:-3600} depends_on: migrate: { condition: service_completed_successfully } postgres: { condition: service_healthy } redis: { condition: service_healthy } healthcheck: test: ["CMD", "node", "-e", "fetch('http://127.0.0.1:'+ (process.env.APP_PORT||8080) + '/health/ready').then(r=>{if(!r.ok)process.exit(1)}).catch(()=>process.exit(1))"] interval: 5s timeout: 3s retries: 20 volumes: postgres-data: redis-data: