services:
  backlog:
    image: localhost:3000/jeffemmett/backlog-md:${IMAGE_TAG:-latest}
    build:
      context: .
      dockerfile: Dockerfile.aggregator
    container_name: backlog-aggregator
    restart: unless-stopped
    volumes:
      - /opt/websites:/projects/websites
      - /opt/apps:/projects/apps
      - /opt/gitea-repos:/projects/gitea
      - /opt/infisical/entrypoint-wrapper.sh:/infisical-entrypoint.sh:ro
    entrypoint: ["/infisical-entrypoint.sh"]
    command: ["/app/entrypoint.sh"]
    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"
    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
      retries: 3
      start_period: 300s
    networks:
      - traefik-public
    env_file:
      - .env
    environment:
      - PORT=6420
      - INFISICAL_CLIENT_ID=${INFISICAL_CLIENT_ID}
      - INFISICAL_CLIENT_SECRET=${INFISICAL_CLIENT_SECRET}
      - INFISICAL_PROJECT_SLUG=backlog-md
      - INFISICAL_URL=http://infisical:8080
      - NODE_ENV=production
      - GITEA_URL=https://gitea.jeffemmett.com
      - GITEA_OUTPUT_DIR=/projects/gitea
      - GITEA_OWNER=jeffemmett

networks:
  traefik-public:
    external: true
