services:
  pediatric-scribe:
    build: .
    image: ped-ai-local:latest
    ports:
      - "127.0.0.1:3552:3000"
    env_file:
      - .env
    environment:
      CLINICAL_ASSISTANT_MCP_URL: http://mcp:8000/mcp
      REDIS_URL: redis://ped-ai-redis:6379
    volumes:
      - scribe-logs:/app/data/logs
      - clinical-assistant-mcp-data:/app/mcp-data:ro
    depends_on:
      postgres:
        condition: service_healthy
      redis:
        condition: service_healthy
    restart: unless-stopped
    container_name: pediatric-ai-scribe
    networks:
      - default
      - mcp-server_default
    healthcheck:
      test: ["CMD", "wget", "--spider", "-q", "http://localhost:3000/api/health"]
      interval: 30s
      timeout: 10s
      retries: 5
      start_period: 20s

  postgres:
    # Tag-pinned. If a newer pg16 image ships a different ICU library, the
    # startup drift check in src/db/database.js auto-REINDEXes and
    # refreshes the collation version. For stricter control, pin by digest.
    image: pgvector/pgvector:pg16
    environment:
      POSTGRES_DB: pedscribe
      POSTGRES_USER: pedscribe
      POSTGRES_PASSWORD: ${DB_PASSWORD:-zy9LK958SAcfUM7SJTkdthSYyYy6}
    volumes:
      - pgdata:/var/lib/postgresql/data
    restart: unless-stopped
    container_name: pedscribe-db
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U pedscribe"]
      interval: 10s
      timeout: 5s
      retries: 5
      start_period: 10s

  redis:
    image: redis:8-alpine
    command: redis-server --appendonly yes
    restart: unless-stopped
    container_name: ped-ai-redis
    volumes:
      - redis-data:/data
    healthcheck:
      test: ["CMD", "redis-cli", "ping"]
      interval: 10s
      timeout: 5s
      retries: 5
    networks:
      - default
      - mcp-server_default

volumes:
  pgdata:
  scribe-logs:
  redis-data:
  clinical-assistant-mcp-data:
    external: true
    name: mcp-server_mcp-data

networks:
  mcp-server_default:
    external: true
