feat: add multi-encoding compression with lazy caching and pre-compressed assets

- Build-time: pre-compress static assets (.gz, .br, .zst) via compress-assets.ts
- Runtime: serve pre-compressed embedded assets with Accept-Encoding negotiation
- ISR cache: lazy per-encoding compression (compress on first request, cache result)
- tower-http: enable runtime compression for API/SSR responses (respects Content-Encoding)
This commit is contained in:
2026-01-15 15:50:55 -06:00
parent 846f559ff5
commit 5e0029c98b
12 changed files with 799 additions and 19 deletions
+6
View File
@@ -34,6 +34,9 @@ RUN cargo build --release
FROM oven/bun:1 AS frontend
WORKDIR /build
# Install system zstd for pre-compression
RUN apt-get update && apt-get install -y zstd && rm -rf /var/lib/apt/lists/*
# Install dependencies (cached until package.json/bun.lock change)
COPY web/package.json web/bun.lock ./
RUN bun install --frozen-lockfile
@@ -43,6 +46,9 @@ COPY web/ ./
ARG VITE_OG_R2_BASE_URL
RUN bun run build
# Pre-compress static assets (gzip, brotli, zstd)
RUN bun run scripts/compress-assets.ts
# ========== Stage 5: Final Rust Build (with embedded assets) ==========
FROM chef AS final-builder