version: '3.8'

services:
  tagneticai-email:
    build:
      context: .
      dockerfile: Dockerfile
      args:
        NODE_ENV: production
    container_name: tagneticai-email-client
    ports:
      - "3000:3000"
    environment:
      NODE_ENV: production
      PORT: 3000
      # Email Configuration
      EMAIL_HOST: ${EMAIL_HOST:?Please set EMAIL_HOST in .env}
      EMAIL_IMAP_PORT: ${EMAIL_IMAP_PORT:-993}
      EMAIL_SMTP_PORT: ${EMAIL_SMTP_PORT:-465}
      EMAIL_USER: ${EMAIL_USER:?Please set EMAIL_USER in .env}
      EMAIL_PASSWORD: ${EMAIL_PASSWORD:?Please set EMAIL_PASSWORD in .env}
      EMAIL_FROM_NAME: ${EMAIL_FROM_NAME:-TagneticAI}
      # Next.js specific
      NEXT_PUBLIC_API_URL: ${NEXT_PUBLIC_API_URL:-http://localhost:3000}
    restart: unless-stopped
    healthcheck:
      test: ["CMD", "wget", "--quiet", "--tries=1", "--spider", "http://localhost:3000"]
      interval: 30s
      timeout: 10s
      retries: 3
      start_period: 10s
    logging:
      driver: "json-file"
      options:
        max-size: "10m"
        max-file: "3"
    healthcheck:
      test: ["CMD", "wget", "--quiet", "--tries=1", "--spider", "http://localhost:3000"]
      interval: 30s
      timeout: 10s
      retries: 3
      start_period: 5s
    networks:
      - tagneticai-network
    # Uncomment for local development with volume mounting
    # volumes:
    #   - ./app:/app/app
    #   - ./components:/app/components

networks:
  tagneticai-network:
    driver: bridge
