Skip to content

Commit f698582

Browse files
committed
feat: set NODE_ENV variable for production in Dockerfiles and update dotenv config for environment file selection
1 parent 45e174d commit f698582

File tree

3 files changed

+7
-1
lines changed

3 files changed

+7
-1
lines changed

Dockerfile.build.alpha

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ RUN npm install podverse-helpers@alpha
1212

1313
# Stage 2: Build the app
1414
FROM deps AS builder
15+
# required for pre-build scripts to use. within next.js app, NODE_ENV is controlled by next.js
16+
ENV NODE_ENV=production
1517
COPY . .
1618

1719
# Ensure the source env file actually exists!

Dockerfile.build.local

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ RUN npm install podverse-helpers@alpha
1212

1313
# Stage 2: Build the app
1414
FROM deps AS builder
15+
# required for pre-build scripts to use. within next.js app, NODE_ENV is controlled by next.js
16+
ENV NODE_ENV=production
1517
COPY . .
1618

1719
# Ensure the source env file actually exists!

scripts/build/external-services/firebase/generate-firebase-sw.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,10 @@
66
const fs = require('fs');
77
const path = require('path');
88

9+
// Choose .env file: use .env.production when running in production
10+
const envFileName = process.env.NODE_ENV === 'production' ? '.env.production' : '.env';
911
// Load .env file from project root
10-
require('dotenv').config({ path: path.join(__dirname, '..', '..', '..', '..', '.env') });
12+
require('dotenv').config({ path: path.join(__dirname, '..', '..', '..', '..', envFileName) });
1113

1214
const outPath = path.join(__dirname, '..', '..', '..', '..', 'public', 'firebase-messaging-sw.js');
1315
const templatePath = path.join(__dirname, 'firebase-messaging-sw.template.js');

0 commit comments

Comments
 (0)