The standalone output
Set output: 'standalone' in next.config.ts and next build traces only the files needed at runtime, plus a minimal server.js. The result is a self-contained directory you can ship in a tiny container (typically < 100MB).
Multi-stage Dockerfile
Three stages: deps installs node_modules, builder runs next build, runner copies just the standalone output. Each stage starts from a clean image so the final layer carries only what runs.
Don't forget the static assets
Standalone bundles application code; you still copy .next/static and public/ manually into the runner stage.