version: '3.8'

services:
  app:
    build: .
    restart: unless-stopped
    environment:
      - DATABASE_URL=${DATABASE_URL}
      - GEMINI_API_KEY=${GEMINI_API_KEY}
      - LEMONSQUEEZY_API_KEY=${LEMONSQUEEZY_API_KEY}
      - LEMONSQUEEZY_WEBHOOK_SECRET=${LEMONSQUEEZY_WEBHOOK_SECRET}
      - LEMONSQUEEZY_STORE_ID=${LEMONSQUEEZY_STORE_ID}
      - AUTH0_SECRET=${AUTH0_SECRET}
      - AUTH0_BASE_URL=${AUTH0_BASE_URL}
      - AUTH0_ISSUER_BASE_URL=${AUTH0_ISSUER_BASE_URL}
      - AUTH0_CLIENT_ID=${AUTH0_CLIENT_ID}
      - AUTH0_CLIENT_SECRET=${AUTH0_CLIENT_SECRET}
      - NEXT_PUBLIC_APP_URL=${NEXT_PUBLIC_APP_URL}
      - NODE_ENV=production
    networks:
      - dokploy-network
    labels:
      - "traefik.enable=true"
      # HTTPS router
      - "traefik.http.routers.ngotoolkit.rule=Host(`ngotoolkit.quikcue.com`) || Host(`ngotoolkitlab.com`) || Host(`www.ngotoolkitlab.com`)"
      - "traefik.http.routers.ngotoolkit.entrypoints=websecure"
      - "traefik.http.routers.ngotoolkit.tls=true"
      - "traefik.http.routers.ngotoolkit.tls.certresolver=letsencrypt"
      - "traefik.http.routers.ngotoolkit.tls.domains[0].main=ngotoolkitlab.com"
      - "traefik.http.routers.ngotoolkit.tls.domains[0].sans=www.ngotoolkitlab.com,ngotoolkit.quikcue.com"
      - "traefik.http.services.ngotoolkit.loadbalancer.server.port=3000"
      # HTTP router — redirect to HTTPS
      - "traefik.http.routers.ngotoolkit-http.rule=Host(`ngotoolkit.quikcue.com`) || Host(`ngotoolkitlab.com`) || Host(`www.ngotoolkitlab.com`)"
      - "traefik.http.routers.ngotoolkit-http.entrypoints=web"
      - "traefik.http.routers.ngotoolkit-http.middlewares=ngotoolkit-https-redirect"
      - "traefik.http.middlewares.ngotoolkit-https-redirect.redirectscheme.scheme=https"
      - "traefik.http.middlewares.ngotoolkit-https-redirect.redirectscheme.permanent=true"

networks:
  dokploy-network:
    external: true
