mirror of
https://github.com/netbirdio/docs.git
synced 2026-08-24 16:51:26 +02:00
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.
31 lines
1.0 KiB
Docker
31 lines
1.0 KiB
Docker
FROM node:20-slim
|
|
|
|
WORKDIR /usr/app
|
|
|
|
ENV NODE_ENV=production
|
|
# Next's standalone server binds to localhost by default; listen on all
|
|
# interfaces inside the container, and pin the port.
|
|
ENV HOSTNAME=0.0.0.0
|
|
ENV PORT=3000
|
|
|
|
# Next's standalone output (built on the CI runner, see build_n_push.yml)
|
|
# bundles a minimal, traced node_modules plus server.js — there is nothing to
|
|
# install here. The output is traced against the runner (Ubuntu/glibc), so this
|
|
# runtime image must also be glibc (node:20-slim, NOT alpine/musl) or the traced
|
|
# native binaries won't load.
|
|
COPY .next/standalone ./
|
|
# standalone does not include static assets or the public dir — copy them in.
|
|
COPY .next/static ./.next/static
|
|
COPY public ./public
|
|
|
|
COPY docker/entrypoint.sh ./entrypoint.sh
|
|
RUN chmod +x ./entrypoint.sh
|
|
|
|
EXPOSE 3000
|
|
|
|
# entrypoint.sh substitutes the APP_NEXT_PUBLIC_DOCSEARCH_* placeholders baked
|
|
# into .next with real values from the container env, then execs the CMD.
|
|
ENTRYPOINT ["/usr/app/entrypoint.sh"]
|
|
|
|
CMD ["node", "server.js"]
|