services:
  next:
    build:
      context: .
      dockerfile: Dockerfile
    image: my-next:latest
    container_name: nextjs
    restart: unless-stopped
    environment:
      - NODE_ENV=production
      - TZ=Europe/Ljubljana
      # add any Next.js runtime env vars you need, e.g.:
      # - NEXTAUTH_URL=https://example.com
      # - NEXT_PUBLIC_API_BASE=https://api.example.com
    networks:
      - proxy
    labels:
      - "traefik.enable=true"
      # tell Traefik which network to use to reach the container
      - "traefik.docker.network=proxy"

      # Router (replace example.com)
      - "traefik.http.routers.next.rule=Host(`${DOMAIN}`)"
      - "traefik.http.routers.next.entrypoints=websecure"
      - "traefik.http.routers.next.tls=true"
      # use your existing certresolver name from your Traefik config
      - "traefik.http.routers.next.tls.certresolver=letsencrypt"

      # Service (container listens on 3000)
      - "traefik.http.services.next.loadbalancer.server.port=3000"

networks:
  proxy:
    external: true
