[feat] Add Docker examples for standalone output and export output #87069
+2,152
−0
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What?
Adds two new production-ready Docker examples demonstrating different Next.js deployment strategies, following best practices for containerizing a Next.js application:
with-docker-standalone-output- Demonstrates Next.js standalone mode deployment with Docker, featuring a comprehensive multi-stage Dockerfile following Docker best practices, BuildKit cache mounts for faster builds, Docker Compose configuration, and extensive documentation.with-docker-export-output- Demonstrates Next.js static export mode deployment with Docker, offering two serving options: Nginx (production-grade) and serve package (Node.js-based, simpler setup). Includes optimized Nginx configuration, BuildKit cache mounts, and comprehensive documentation explaining when to use each approach.Both examples include detailed documentation explaining Docker best practices, implementation decisions, and deployment guidance.
Why?
The existing
with-dockerexample provides basic Docker support but lacks:These new examples serve as comprehensive references for developers who want to understand:
How?
with-docker-standalone-outputexample:npm,yarn,pnpm) and Next.js build cachecompose.yml) for simplified local development.dockerignoreto minimize build context sizewith-docker-export-outputexample:Dockerfile- Nginx-based serving (~50MB final image) with optimized production configurationDockerfile.serve- Node.js serve package-based serving for simpler deploymentsnginx.conf) with gzip compression, caching headers, and security best practicescompose.yml) supporting both serving optionsDocumentation highlights (both examples):
Docker best practices implemented (both examples):
.dockerignorefilesBoth examples follow Docker best practices and Next.js output requirements, providing developers with reliable, production-ready references that demonstrate both the technical implementation and the reasoning behind each decision.
Note: After this PR is approved and merged, I plan to open a follow-up PR to: