Next.js & App Router (50 Qs)•Part 3: Advanced Internals, Scale & Production Architecture (Senior / Lead)
Self-Hosting Next.js on Docker & Kubernetes: `standalone` Output.
senior LevelMost AskedCode ExampleDocker & ContainersKubernetesSystem Design
In Simple Words:
By default, deploying Next.js requires the entire 500MB node_modules folder.
In next.config.js:
javascript
module.exports = { output: 'standalone' };
- Next.js traces all imported files and produces a minimal
.next/standalonefolder containing only the strict files needed for production. - Drops Docker image size from 1.2GB down to sub-80MB!