---
# Production Deployment with Rolling Update
services:
  vitron-frontend-prod:
    build:
      context: .
      dockerfile: Dockerfile
      target: production
    container_name: vitron-frontend-prod
    environment:
      - NODE_ENV=production
      - VITE_API_BASE_URL=${VITE_API_BASE_URL:-https://api.prod.vitrown.com}
      - VITE_API_SOCKET_BASE_URL=${VITE_API_SOCKET_BASE_URL:-wss://api.prod.vitrown.com}
      - VITE_APP_VERSION_TYPE=${VITE_APP_VERSION_TYPE:-production}
      - VITE_API_URL=${VITE_API_URL:-https://api.prod.vitrown.com}
      - VITE_SITE_URL=${VITE_SITE_URL:-https://vitrown.com}
      - VITE_DOMAIN_URL=${VITE_DOMAIN_URL:-https://vitrown.com}
      - VITE_SUPPORT_PHONE=${VITE_SUPPORT_PHONE:-+989223740993}
      - REMIX_SECRET=${REMIX_SECRET:-prod-secret-key-please-change-in-production}
    networks:
      - proxy
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.frontprod.entrypoints=http"
      - "traefik.http.routers.frontprod.rule=Host(`vitrown.com`)"
      - "traefik.http.middlewares.frontprod-https-redirect.redirectscheme.scheme=https"
      - "traefik.http.routers.frontprod.middlewares=frontprod-https-redirect"
      - "traefik.http.routers.frontprod-secure.entrypoints=https"
      - "traefik.http.routers.frontprod-secure.rule=Host(`vitrown.com`)"
      - "traefik.http.routers.frontprod-secure.tls=true"
      - "traefik.http.routers.frontprod-secure.service=frontprod"
      - "traefik.http.services.frontprod.loadbalancer.server.port=3000"
      - "traefik.docker.network=proxy"
      # Security headers
      - "traefik.http.middlewares.frontprod-headers.headers.customrequestheaders.X-Forwarded-Proto=https"
      - "traefik.http.middlewares.frontprod-headers.headers.customresponseheaders.X-Robots-Tag=index,follow"
      - "traefik.http.middlewares.frontprod-headers.headers.customresponseheaders.X-Frame-Options=SAMEORIGIN"
      - "traefik.http.middlewares.frontprod-headers.headers.customresponseheaders.X-Content-Type-Options=nosniff"
      - "traefik.http.routers.frontprod-secure.middlewares=frontprod-headers"
    restart: unless-stopped
    deploy:
      resources:
        limits:
          memory: 512M
        reservations:
          memory: 256M
    healthcheck:
      test: ["CMD", "wget", "--no-verbose", "--tries=1", "--spider", "http://localhost:3000/"]
      interval: 30s
      timeout: 10s
      retries: 3
      start_period: 40s

networks:
  proxy:
    external: true
