perf: ship a standalone slim Docker image (~590MB to ~283MB) (#841)

Enable Next `output: 'standalone'` and rewrite the Dockerfile to package only the traced standalone server + .next/static + public on node:20-slim (glibc, matching the runner), running `node server.js`. No in-image npm ci, no full source or dependency tree. Cuts the image ~52%, so docker push and the server pull get much faster.

Also fixes a latent entrypoint bug (${VAR:"none"} -> ${VAR:-"none"}) that busybox sh tolerated but Debian dash (node:20-slim /bin/sh) rejects, which would otherwise crash the container on boot.

Smoke-tested via isolated build + docker run: boots in 37ms, all routes 200, redirects still bundled (/slack-url -> 307), static + public assets served, DocSearch env-injection intact.
This commit is contained in:
Jack Carter
2026-07-09 16:51:17 +02:00
committed by GitHub
parent 76845ec77f
commit 44cab34f6f
4 changed files with 28 additions and 24 deletions
+3 -2
View File
@@ -7,8 +7,9 @@ LICENSE
README.md
AUTHORS
# Reinstalled inside the image (alpine-native — avoids a glibc/musl mismatch)
node_modules/
# Root deps aren't shipped — the image uses .next/standalone's traced
# node_modules. Root-anchored so the nested standalone node_modules is kept.
/node_modules/
# The built .next output is copied in (built on the CI runner, see
# build_n_push.yml); only the build cache is excluded — it is not served.