You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was going through the docker-multienv example in the Next.js repo and noticed something curious in the Dockerfile for the development environment:
FROM base AS runner
WORKDIR /app
ENV NODE_ENV=production
Typically, setting NODE_ENV=production is meant for production builds. It enables optimizations like:
Disabling development warnings
Enabling production-specific behavior
Optimizing build outputs for deployment
However, seeing this configuration in the development Dockerfile feels counterintuitive. It seems like this setup might disable features typically useful during development, like detailed warnings or dev-only tooling.
Questions:
Is this intentional?
Perhaps the idea is to mimic a production-like setup during development for consistency and to catch potential issues early.
Or could this just be an oversight?
Is this the best approach?
Using NODE_ENV=production during development could make debugging harder or impact workflows like hot reloading.
On the other hand, running in a production-like mode might help test how the app behaves in real-world conditions.
Observations:
The .env.production file is also being used instead of .env.development. If this is intentional, it reinforces the idea of simulating production during local development.
If it’s not, should the Dockerfile be updated to use NODE_ENV=development and the .env.development file instead?
Would love to hear thoughts on whether this setup makes sense or if there’s a better way to handle development environments in Docker.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Summary
I was going through the docker-multienv example in the Next.js repo and noticed something curious in the Dockerfile for the development environment:
Typically, setting NODE_ENV=production is meant for production builds. It enables optimizations like:
However, seeing this configuration in the development Dockerfile feels counterintuitive. It seems like this setup might disable features typically useful during development, like detailed warnings or dev-only tooling.
Questions:
Is this intentional?
Is this the best approach?
Observations:
The .env.production file is also being used instead of .env.development. If this is intentional, it reinforces the idea of simulating production during local development.
If it’s not, should the Dockerfile be updated to use NODE_ENV=development and the .env.development file instead?
Would love to hear thoughts on whether this setup makes sense or if there’s a better way to handle development environments in Docker.
Additional information
No response
Example
No response
Beta Was this translation helpful? Give feedback.
All reactions