# Docker Compose for Coolify deployment
# Use this for "Docker Compose" deployment type in Coolify

services:
  enchun-cms:
    image: pukpuklouis/website-enchun-cms:latest
    container_name: enchun-cms
    restart: unless-stopped

    environment:
      - NODE_ENV=production
      - PORT=3000 # Explicitly set to match EXPOSE
      - DATABASE_URI=${DATABASE_URI}
      - PAYLOAD_SECRET=${PAYLOAD_SECRET}
      - NEXT_PUBLIC_SERVER_URL=${NEXT_PUBLIC_SERVER_URL:-https://enchun-admin.anlstudio.cc}

    # Expose port 3000 (matches Next.js default)
    expose:
      - "3000"

    # Health check
    healthcheck:
      test:
        [
          "CMD",
          "node",
          "-e",
          "require('http').get('http://localhost:3000/', (r) => process.exit(r.statusCode < 500 ? 0 : 1)).on('error', () => process.exit(1))",
        ]
      interval: 30s
      timeout: 10s
      retries: 3
      start_period: 30s

    # Traefik labels for routing
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.enchun-cms.rule=Host(`enchun-admin.anlstudio.cc`)"
      - "traefik.http.routers.enchun-cms.entrypoints=http"
      - "traefik.http.services.enchun-cms.loadbalancer.server.port=3000"
      - "traefik.http.middlewares.enchun-gzip.compress=true"
      - "traefik.http.routers.enchun-cms.middlewares=enchun-gzip"

    networks:
      - coolify

networks:
  coolify:
    external: true
