-
Notifications
You must be signed in to change notification settings - Fork 29.9k
fix(example): staging Dockerfile using production env #85310
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: canary
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
|
|
@@ -25,7 +25,7 @@ WORKDIR /app | |||
| COPY --from=deps /app/node_modules ./node_modules | ||||
| COPY . . | ||||
| # This will do the trick, use the corresponding env file for each environment. | ||||
| COPY .env.staging.sample .env.production | ||||
| COPY .env.staging.sample .env.staging | ||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Staging is not a env config filename Next.js loads automatically so this file will not be used x-ref: next.js/packages/next-env/index.ts Line 137 in 5312936
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @ijjk thanks for the clarification |
||||
| RUN npm run build | ||||
|
|
||||
| # 3. Production image, copy all the files and run next | ||||
|
|
||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
Dockerfileis incorrectly copying the staging environment file to the production environment, causing staging environments to use production configurations.View Details
Analysis
What fails: The
COPY .env.staging.sample .env.productioninstruction in the staging Dockerfile copies staging configuration to the production configuration file, causing staging environments to use production settingsHow to reproduce:
Result: The staging environment uses production configuration because during Docker build time,
.env.staging.sampleis copied directly into.env.production, overwriting production settings with staging configurationExpected: The staging environment should use its own configuration file (
.env.staging) as specified in the Dockerfile's COPY instruction. Instead of:it should be:
This ensures that the staging environment uses the correct staging-specific configuration settings and production environments use their proper production configurations as intended.