feat(browse): add SingleFile browse-page snapshot cache via MinIO

- New MinIO bucket 'libnovel-browse' (MINIO_BUCKET_BROWSE env) for storing
  self-contained HTML snapshots of novelfire browse pages
- Store interface gains SaveBrowsePage / GetBrowsePage / BrowsePageKey methods
- handleBrowse is now cache-first: serves from MinIO snapshot when available,
  then fires a background triggerBrowseSnapshot goroutine to populate cache
  on live-fetch (de-duplicated, 90s timeout)
- New 'save-browse' CLI subcommand to bulk-capture pages via SingleFile CLI
- Dockerfile: downloads pinned single-file-x86_64-linux binary (v2.0.83),
  adds gcompat + libstdc++ to Alpine runtime for glibc compatibility
- docker-compose: adds libnovel-browse bucket init and SINGLEFILE_PATH env
- .gitignore: exclude scraper/scraper build artifact
This commit is contained in:
Admin
2026-03-04 10:42:26 +05:00
parent c2d6ce1c5b
commit 555973c053
9 changed files with 365 additions and 16 deletions

View File

@@ -12,15 +12,30 @@ COPY . .
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 \
go build -ldflags="-s -w" -o /scraper ./cmd/scraper
# ── single-file binary stage ───────────────────────────────────────────────────
# Download the official pre-compiled single-file-cli binary (Deno-compiled,
# statically linked for Linux x86_64 glibc). We pin to a specific version so
# image builds are reproducible; bump this ARG to upgrade.
FROM alpine:3.20 AS singlefile-downloader
ARG SINGLEFILE_VERSION=2.0.83
RUN apk add --no-cache wget ca-certificates && \
wget -q -O /single-file \
"https://github.com/gildas-lormeau/single-file-cli/releases/download/v${SINGLEFILE_VERSION}/single-file-x86_64-linux" && \
chmod +x /single-file
# ── Runtime stage ──────────────────────────────────────────────────────────────
FROM alpine:3.20
# ca-certificates is required for HTTPS requests to novelfire.net.
RUN apk add --no-cache ca-certificates tzdata
# ca-certificates: HTTPS to novelfire.net
# gcompat: glibc compatibility shim so the glibc-linked single-file binary
# runs on musl/Alpine without needing a full glibc image.
# libstdc++: required by the Deno runtime embedded in single-file
RUN apk add --no-cache ca-certificates tzdata gcompat libstdc++
WORKDIR /app
COPY --from=builder /scraper /app/scraper
COPY --from=singlefile-downloader /single-file /usr/local/bin/single-file
# Create the default static output directory.
RUN mkdir -p /app/static/books
@@ -36,6 +51,7 @@ ENV BROWSERLESS_STRATEGY=content
ENV SCRAPER_WORKERS=0
ENV SCRAPER_STATIC_ROOT=/app/static/books
ENV SCRAPER_HTTP_ADDR=:8080
ENV SINGLEFILE_PATH=/usr/local/bin/single-file
EXPOSE 8080