# Local synthetic stand for laboratory 2. # Copy .env.example to .env and change the local password before use. # The password is read from .env at Compose time and is never committed. name: mtusi-lab2 services: postgres: image: postgres:16.4-alpine restart: unless-stopped environment: POSTGRES_DB: ${POSTGRES_DB:-messenger} POSTGRES_USER: ${POSTGRES_USER:-messenger} POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:?set POSTGRES_PASSWORD in .env} volumes: - pgdata:/var/lib/postgresql/data healthcheck: test: ["CMD-SHELL", "pg_isready -U $${POSTGRES_USER} -d $${POSTGRES_DB}"] interval: 3s timeout: 3s retries: 20 networks: - backend redis: image: redis:7.4.0-alpine restart: unless-stopped # Sessions are the only Redis data. AOF + the named volume keep active # sessions across an API/Redis restart; TTL remains the expiry authority. command: - redis-server - --appendonly - "yes" - --appendfsync - everysec - --dir - /data volumes: - redisdata:/data healthcheck: test: ["CMD", "redis-cli", "ping"] interval: 3s timeout: 3s retries: 20 networks: - backend api: build: context: . dockerfile: Dockerfile restart: unless-stopped environment: APP_ENV: lab DATABASE_URL: ${DATABASE_URL:?set DATABASE_URL in .env} CACHE_URL: ${CACHE_URL:-redis://redis:6379/0} SESSION_TTL_SECONDS: ${SESSION_TTL_SECONDS:-3600} DB_POOL_MIN: ${DB_POOL_MIN:-1} DB_POOL_MAX: ${DB_POOL_MAX:-10} DB_POOL_ACQUIRE_TIMEOUT_SECONDS: ${DB_POOL_ACQUIRE_TIMEOUT_SECONDS:-3} DB_CONNECT_TIMEOUT_SECONDS: ${DB_CONNECT_TIMEOUT_SECONDS:-3} DB_STATEMENT_TIMEOUT_MS: ${DB_STATEMENT_TIMEOUT_MS:-5000} REDIS_CONNECT_TIMEOUT_SECONDS: ${REDIS_CONNECT_TIMEOUT_SECONDS:-2} REDIS_SOCKET_TIMEOUT_SECONDS: ${REDIS_SOCKET_TIMEOUT_SECONDS:-2} MAX_BODY_BYTES: ${MAX_BODY_BYTES:-1048576} ports: - "${API_PORT:-8080}:8080" depends_on: postgres: condition: service_healthy redis: condition: service_healthy networks: - backend volumes: pgdata: redisdata: networks: backend: driver: bridge