Question presented to candidate: "Our Docker images for a Next.js app are over a gigabyte. What does output: 'standalone' do and how does it change the Dockerfile?"
What a strong answer should cover:
output: "standalone"makesnext buildproduce.next/standalonewith a minimalserver.jsand only the files the server needs.- It uses output file tracing to copy just the traced dependencies from node_modules, so no
npm installis needed in the runtime image. - Run it with
node server.js; configurePORTandHOSTNAMEthrough environment variables. .next/staticandpublicare not copied by default: copy them next to server.js or serve them from a CDN.- Use it for Docker and other self-hosted deployments; managed platforms do not need it.
Clarifying questions expected:
- "Are static assets served by a CDN?" β then you may not need to copy them into the image.
- "Do any packages load files at runtime that tracing might miss?" β they may need outputFileTracingIncludes.
Code / implementation expected: Yes β the config and the copy steps.