Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/with-docker-multi-env/docker/staging/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Dockerfile is 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.production instruction in the staging Dockerfile copies staging configuration to the production configuration file, causing staging environments to use production settings

How to reproduce:

# The issue exists in line 28 of:
examples/with-docker-multi-env/docker/staging/Dockerfile

Result: The staging environment uses production configuration because during Docker build time, .env.staging.sample is copied directly into .env.production, overwriting production settings with staging configuration

Expected: The staging environment should use its own configuration file (.env.staging) as specified in the Dockerfile's COPY instruction. Instead of:

COPY .env.staging.sample .env.production

it should be:

COPY .env.staging.sample .env.staging

This ensures that the staging environment uses the correct staging-specific configuration settings and production environments use their proper production configurations as intended.

Copy link
Member

Choose a reason for hiding this comment

The 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:

const mode = isTest ? 'test' : dev ? 'development' : 'production'

Copy link
Author

Choose a reason for hiding this comment

The 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
Expand Down
Loading