version: "3.8"

services:
  queuenorth:
    build:
      context: .
      dockerfile: Dockerfile
      args:
        - VITE_RECAPTCHA_SITE_KEY=${VITE_RECAPTCHA_SITE_KEY:-}
    container_name: queuenorth-website
    ports:
      - "3001:3001"
    volumes:
      # Persist SQLite database between runs using named volume
      # This avoids host permission issues - Docker manages ownership automatically
      - queuenorth-db:/app/db:rw
      # Persist logs using named volume
      - queuenorth-logs:/app/logs:rw
    environment:
      - NODE_ENV=production
      - SERVER_PORT=3001
      - RATE_LIMIT_PER_MINUTE=5
      - CORS_ORIGIN=https://queuenorth.com
      - LOG_LEVEL=info
      - ZOHO_FORWARDING_MODE=${ZOHO_FORWARDING_MODE:-webtolead}
      - ZOHO_WEBTOLEAD_ENABLED=${ZOHO_WEBTOLEAD_ENABLED:-false}
      - ZOHO_WEBTOLEAD_URL=${ZOHO_WEBTOLEAD_URL:-https://crm.zoho.com/crm/WebToLeadForm}
      - ZOHO_WEBTOLEAD_XNQSJSDP=${ZOHO_WEBTOLEAD_XNQSJSDP:-}
      - ZOHO_WEBTOLEAD_XMIWTLD=${ZOHO_WEBTOLEAD_XMIWTLD:-}
      - ZOHO_WEBTOLEAD_ACTION_TYPE=${ZOHO_WEBTOLEAD_ACTION_TYPE:-TGVhZHM=}
      - ZOHO_WEBTOLEAD_RETURN_URL=${ZOHO_WEBTOLEAD_RETURN_URL:-null}
      - ZOHO_WEBTOLEAD_ZC_GAD=${ZOHO_WEBTOLEAD_ZC_GAD:-}
      - ZOHO_ENABLED=${ZOHO_ENABLED:-false}
      - ZOHO_API_DOMAIN=${ZOHO_API_DOMAIN:-https://www.zohoapis.com}
      - ZOHO_ACCOUNTS_DOMAIN=${ZOHO_ACCOUNTS_DOMAIN:-https://accounts.zoho.com}
      - ZOHO_CLIENT_ID=${ZOHO_CLIENT_ID:-}
      - ZOHO_CLIENT_SECRET=${ZOHO_CLIENT_SECRET:-}
      - ZOHO_REFRESH_TOKEN=${ZOHO_REFRESH_TOKEN:-}
      - ZOHO_CASES_ENABLED=${ZOHO_CASES_ENABLED:-false}
      - RECAPTCHA_ENABLED=${RECAPTCHA_ENABLED:-false}
      - RECAPTCHA_SECRET_KEY=${RECAPTCHA_SECRET_KEY:-}
      - RECAPTCHA_MIN_SCORE=${RECAPTCHA_MIN_SCORE:-0.5}
    restart: unless-stopped
    # Container runs as non-root user (UID 1001) for security

volumes:
  queuenorth-db:
  queuenorth-logs:
