# Homepage Preview — port 9002
# Usage: docker compose -f docker-compose.preview.yml up --build
# Reuses the dev Dockerfile with source mounts for hot-reload

services:
  mawidi-preview:
    build:
      context: .
      dockerfile: Dockerfile.dev
    image: mawidi-site:preview
    container_name: mawidi-homepage-preview
    restart: unless-stopped
    ports:
      - "9002:9000"
    extra_hosts:
      - "host.docker.internal:host-gateway"
    env_file:
      - .env.docker
    environment:
      - NODE_ENV=development
      - PORT=9000
      - HOSTNAME=0.0.0.0
      - NEXT_TELEMETRY_DISABLED=1
      - WATCHPACK_POLLING=true
      - CHOKIDAR_USEPOLLING=true
      - FAST_REFRESH=true
      - NEXT_PUBLIC_API_URL=http://localhost:9002
      - NEXT_PUBLIC_APP_URL=http://localhost:9002
      - NEXT_PUBLIC_WHATSAPP_NUMBER=${NEXT_PUBLIC_WHATSAPP_NUMBER:-+447450018521}
      - NEXTAUTH_URL=http://localhost:9002
      - NEXTAUTH_SECRET=${NEXTAUTH_SECRET:-LhCil9AMN2Sf8+zkEEja0ZaK9USKkRFY5OcKCG3LN6o=}
      - REDIS_URL=redis://:${REDIS_PASSWORD:-changeme_local_dev_only}@mawidi-redis:6379
      - NEXT_PUBLIC_RECAPTCHA_SITE_KEY=${NEXT_PUBLIC_RECAPTCHA_SITE_KEY}
      - RECAPTCHA_SECRET_KEY=${RECAPTCHA_SECRET_KEY}
      - NEXT_PUBLIC_STRIPE_PUBLIC_KEY=${NEXT_PUBLIC_STRIPE_PUBLIC_KEY:-pk_test_placeholder}
      - STRIPE_SECRET_KEY=${STRIPE_SECRET_KEY}
      - STRIPE_WEBHOOK_SECRET=${STRIPE_WEBHOOK_SECRET}
      - ENCRYPTION_KEY=${ENCRYPTION_KEY:-2c62b9f5b4f3f53b3a3d671c5f4b7e1a2e0f533b5a62fce2d4b9f23a0e8c1f44}
      - ELEVENLABS_API_KEY=${ELEVENLABS_API_KEY}
      - NEXT_PUBLIC_ELEVENLABS_AGENT_ID=${NEXT_PUBLIC_ELEVENLABS_AGENT_ID}
      - SMTP_HOST=mawidi-mailhog
      - SMTP_PORT=1025
      - SMTP_SECURE=false
      - SMTP_USER=
      - SMTP_PASS=
      - SMTP_FROM=noreply@mawidi.local
      - EMAIL_QUEUE_ENABLED=false
      - GOOGLE_CLIENT_ID=${GOOGLE_CLIENT_ID}
      - GOOGLE_CLIENT_SECRET=${GOOGLE_CLIENT_SECRET}
      - GOOGLE_CLOUD_API_KEY=${GOOGLE_CLOUD_API_KEY}
    volumes:
      - ./app:/app/app
      - ./components:/app/components
      - ./lib:/app/lib
      - ./hooks:/app/hooks
      - ./types:/app/types
      - ./content:/app/content
      - ./public:/app/public
      - ./prisma:/app/prisma
      - ./scripts:/app/scripts
      - ./next.config.mjs:/app/next.config.mjs
      - ./tsconfig.json:/app/tsconfig.json
      - ./tailwind.config.ts:/app/tailwind.config.ts
      - ./postcss.config.mjs:/app/postcss.config.mjs
      - ./middleware.ts:/app/middleware.ts
      - preview_node_modules:/app/node_modules
      - preview_next_cache:/app/.next
      - ./data:/app/data
    networks:
      - mawidi-network
    healthcheck:
      test:
        [
          "CMD-SHELL",
          "wget -q -O /dev/null http://localhost:9000/api/health || exit 1",
        ]
      interval: 60s
      timeout: 30s
      retries: 3
      start_period: 120s
    deploy:
      resources:
        limits:
          cpus: "4"
          memory: 4G

volumes:
  preview_node_modules:
  preview_next_cache:

networks:
  mawidi-network:
    external: true
