# Backlog Aggregator - Multi-Project Real-time Task View with Gitea Integration
# Deploy at backlog.jeffemmett.com to see all project tasks in real-time
# Scans Gitea repos daily for backlog/ directories

services:
  backlog-aggregator:
    build:
      context: .
      dockerfile: Dockerfile.aggregator
    container_name: backlog-aggregator
    restart: unless-stopped
    healthcheck:
      test: ["CMD", "bun", "-e", "fetch('http://127.0.0.1:6420/').then(r => process.exit(r.ok ? 0 : 1)).catch(() => process.exit(1))"]
      interval: 30s
      timeout: 10s
      start_period: 300s
      retries: 3
    volumes:
      # Mount all project directories that contain backlog folders
      - /opt/websites:/projects/websites:rw
      - /opt/apps:/projects/apps:rw
      # Gitea-synced repos (auto-discovered and cloned)
      - /opt/gitea-repos:/projects/gitea:rw
      # SSH keys for git clone operations
      - /root/.ssh:/root/.ssh:ro
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.backlog.rule=Host(`backlog.jeffemmett.com`)"
      - "traefik.http.routers.backlog.entrypoints=web"
      - "traefik.http.services.backlog.loadbalancer.server.port=6420"
      - "traefik.docker.network=traefik-public"
    networks:
      - traefik-public
    environment:
      - PORT=6420
      - NODE_ENV=production
      - GITEA_URL=https://gitea.jeffemmett.com
      - GITEA_OWNER=jeffemmett
      - GITEA_OUTPUT_DIR=/projects/gitea
      - GITEA_SSH_KEY=/root/.ssh/gitea_ed25519

networks:
  traefik-public:
    external: true
