services:

  web-app:
    build: .
    ports:
      - "8001:8001"
    volumes:
      - ./data:/app/data
    environment:
      - PYTHONUNBUFFERED=1
      - ENVIRONMENT=production
      - SLMM_BASE_URL=http://host.docker.internal:8100
      - SFM_BASE_URL=http://sfm:8200
      # Display timezone for server logs + any text-rendered timestamps.
      # DB columns are stored UTC regardless; this only affects what
      # operators see.  Override here for non-US-East deployments.
      - TZ=America/New_York
    restart: unless-stopped
    depends_on:
      - slmm
      - sfm
    extra_hosts:
      - "host.docker.internal:host-gateway"
    healthcheck:
      test: ["CMD", "curl", "-f", "http://localhost:8001/health"]
      interval: 30s
      timeout: 10s
      retries: 3
      start_period: 40s

  # --- SLMM (Sound Level Meter Manager) ---
  slmm:
    build:
      context: ../slmm
      dockerfile: Dockerfile
    network_mode: host
    volumes:
      - ../slmm/data:/app/data
    environment:
      - PYTHONUNBUFFERED=1
      - PORT=8100
      - CORS_ORIGINS=*
      - TCP_IDLE_TTL=-1
      - TCP_MAX_AGE=-1
    restart: unless-stopped
    healthcheck:
      test: ["CMD", "curl", "-f", "http://localhost:8100/health"]
      interval: 30s
      timeout: 10s
      retries: 3
      start_period: 10s

  # --- SFM (Seismo Fleet Manager) ---
  sfm:
    build:
      context: ../seismo-relay
      dockerfile: Dockerfile
    ports:
      - "8200:8200"
    volumes:
      - ../seismo-relay/sfm/data:/app/sfm/data
      - ../seismo-relay/bridges/captures:/app/bridges/captures
      # The DB + waveform store inside bridges/captures are symlinks
      # pointing at the prod-snap directory.  Mount its host path at
      # the same absolute path inside the container so the symlinks
      # resolve.  Needed for SFM to query the events DB.
      - ../seismo-relay-prod-snap:/home/serversdown/seismo-relay-prod-snap
    environment:
      - PYTHONUNBUFFERED=1
      - PORT=8200
      # Display timezone — affects server log timestamps, the PDF
      # report renderer's UTC→local conversions, and matplotlib's
      # datetime axes.  DB columns (created_at etc.) are always UTC.
      - TZ=America/New_York
    restart: unless-stopped
    healthcheck:
      test: ["CMD", "curl", "-f", "http://localhost:8200/health"]
      interval: 30s
      timeout: 10s
      retries: 3
      start_period: 10s
volumes:
  data:
