version: '3.8'

services:
  frontend:
    # Use pre-built image from GitHub Container Registry
    # To build locally instead, uncomment the 'build' section and comment out 'image'
    image: ghcr.io/valknarxxx/sexy:latest

    # Uncomment to build locally:
    # build:
    #   context: .
    #   dockerfile: Dockerfile
    #   args:
    #     NODE_ENV: production
    container_name: sexy-pivoine-frontend
    restart: unless-stopped
    ports:
      - "3000:3000"
    environment:
      # Application settings
      NODE_ENV: production
      PORT: 3000
      HOST: 0.0.0.0

      # Public environment variables
      PUBLIC_API_URL: ${PUBLIC_API_URL:-http://localhost:8055}
      PUBLIC_URL: ${PUBLIC_URL:-http://localhost:3000}
      PUBLIC_UMAMI_ID: ${PUBLIC_UMAMI_ID:-}

      # Letterspace integration
      LETTERSPACE_API_URL: ${LETTERSPACE_API_URL:-}
      LETTERSPACE_API_KEY: ${LETTERSPACE_API_KEY:-}
      LETTERSPACE_LIST_ID: ${LETTERSPACE_LIST_ID:-}

    networks:
      - sexy-network

    healthcheck:
      test: ["CMD", "node", "-e", "require('http').get('http://localhost:3000/', (r) => {process.exit(r.statusCode === 200 ? 0 : 1)})"]
      interval: 30s
      timeout: 3s
      retries: 3
      start_period: 40s

    # Resource limits
    deploy:
      resources:
        limits:
          cpus: '2'
          memory: 2G
        reservations:
          cpus: '0.5'
          memory: 512M

    # Logging
    logging:
      driver: "json-file"
      options:
        max-size: "10m"
        max-file: "3"

networks:
  sexy-network:
    driver: bridge

# Example usage:
# 1. Create a .env file with your environment variables
# 2. Build: docker-compose -f docker-compose.production.yml build
# 3. Run: docker-compose -f docker-compose.production.yml up -d
# 4. Logs: docker-compose -f docker-compose.production.yml logs -f
# 5. Stop: docker-compose -f docker-compose.production.yml down
