v2 Phase 1: ingestion + SQLite foundation

- Persistence via Node's built-in node:sqlite (zero native deps) on a Docker
  volume: response cache, source health, fixture↔provider id map, per-fixture
  enrichment, ingest log. Runtime bumped to node:24-slim + --experimental-sqlite.
- Resilient fetcher: DB cache + per-source rate-limit + jittered backoff +
  circuit-breaker (blocked sources trip + skip; UI reads DB, never breaks).
- ESPN hidden API as the PRIMARY rich source (works from the VPS where SofaScore
  403s): scoreboard (live scores w/ clock) + summary (venue, H2H, recent form,
  lineups, team stats). football-data / SofaScore are fallbacks.
- Scheduler: maps all 72 group fixtures to ESPN event ids, polls live on a
  dynamic cadence, enriches imminent fixtures into match_ext. /api/sources/health.
- Verified: DB populates (real H2H + form for opening matches), 22 tests pass,
  Docker image runs node:sqlite on the volume and persists across restart.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-06-11 15:21:01 +02:00
parent 9c7605391c
commit b6f62679c9
13 changed files with 697 additions and 88 deletions
+6 -5
View File
@@ -8,15 +8,16 @@ RUN bun run data:build # icons + fixtures.json + ratings.json → public/
RUN bun run build # tsc -b && vite build → /app/dist
RUN bun run build:server # esbuild → /app/server/dist/index.js
# --- runtime stage: small node image, non-root, serves dist + /ws + /api ---
FROM node:20-slim AS runtime
ENV NODE_ENV=production STATIC_DIR=/app/dist PORT=8787
# --- runtime stage: node 24 (built-in node:sqlite), non-root, serves dist + /ws + /api ---
FROM node:24-slim AS runtime
ENV NODE_ENV=production STATIC_DIR=/app/dist PORT=8787 DATA_DIR=/data
WORKDIR /app/server
COPY server/package.json ./
RUN npm install --omit=dev --no-audit --no-fund
COPY --from=build /app/server/dist ./dist
COPY --from=build /app/dist /app/dist
RUN chown -R node:node /app
# SQLite lives on a named volume; create it node-owned so a fresh mount is writable.
RUN mkdir -p /data && chown -R node:node /app /data
USER node
EXPOSE 8787
CMD ["node", "dist/index.js"]
CMD ["node", "--experimental-sqlite", "dist/index.js"]