From 0d78759bee830823916c2d74d9fec6a158430747 Mon Sep 17 00:00:00 2001 From: Francesc Leveque Date: Sun, 17 May 2026 00:32:42 +0200 Subject: [PATCH] Add librsvg to runtime image for fast SVG rasterization MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Wikimedia logos come back as SVG. libvips can rasterize SVG via librsvg, but the Alpine `vips` package doesn't pull librsvg in by default — when it's missing, libvips falls back to a much slower SVG path. Each call to ProcessAll resizes the source to 5 sizes sequentially, so the delta is roughly: with librsvg: ~100ms total per logo without librsvg: ~30s total per logo The 30s case was hitting kamal-proxy's request timeout, causing the user-visible 504s observed today on the first REP.MC request after the wikidata layer landed: cache miss → wikidata Q174747 (1.3s) → processing... → [504] One-line apk install fix. ~3MB of additional image size. Co-Authored-By: Claude Opus 4.7 (1M context) --- Dockerfile | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index cf05e97..b5878ac 100644 --- a/Dockerfile +++ b/Dockerfile @@ -37,12 +37,16 @@ FROM alpine:3.21 # Install only the runtime libraries (not dev headers). # vips: image processing runtime (libvips) +# librsvg: SVG rasterization backend for libvips — without it, libvips falls +# back to a much slower SVG path. Resizing a single Wikimedia logo to +# all five sizes takes ~30s without librsvg vs ~100ms with it, which +# was tripping kamal-proxy's request timeout. # ca-certificates: for HTTPS calls to GitHub API and LLM providers # tzdata: timezone data for proper timestamps # sqlite: CLI for ad-hoc inspection / cache cleanup via `kamal app exec` # (the binary uses go-sqlite3, which doesn't need the CLI to run — # this is purely for operator convenience) -RUN apk add --no-cache vips ca-certificates tzdata sqlite +RUN apk add --no-cache vips librsvg ca-certificates tzdata sqlite # Run as non-root user for security — same pattern as the dividend-portfolio Dockerfile. RUN addgroup -S app && adduser -S -G app app