From fe9d9a450037acfb31cfaf7088483b656ff858fd Mon Sep 17 00:00:00 2001 From: hamed Date: Sun, 28 Sep 2025 14:30:00 +0330 Subject: [PATCH] refactor: update NODE_ENV handling in Dockerfile and docker-compose.yml for better environment configuration --- Dockerfile | 2 +- app/layout.js | 10 ++++++++-- docker-compose.yml | 5 +++-- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/Dockerfile b/Dockerfile index 5b94891..2f9804a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -25,7 +25,7 @@ FROM node:22-alpine AS runner WORKDIR /app # Set environment variables -ENV NODE_ENV production +ENV NODE_ENV $NODE_ENV ENV NEXT_TELEMETRY_DISABLED 1 # Add a non-root user for security diff --git a/app/layout.js b/app/layout.js index 18d0966..5ff8701 100644 --- a/app/layout.js +++ b/app/layout.js @@ -27,6 +27,8 @@ export async function generateMetadata() { } export default function RootLayout({ children }) { + + return ( @@ -36,14 +38,18 @@ export default function RootLayout({ children }) { /> - + {process.env.NODE_ENV !== 'development' && ( + + )} {children} - + {process.env.NODE_ENV !== 'development' && ( + + )} ); diff --git a/docker-compose.yml b/docker-compose.yml index d45d186..7b540a6 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -7,7 +7,7 @@ services: context: . dockerfile: Dockerfile args: - - NODE_ENV=production + - NODE_ENV=${NODE_ENV} - NEXT_TELEMETRY_DISABLED=1 - NEXT_PUBLIC_API_URL=${NEXT_PUBLIC_API_URL} - NEXT_PUBLIC_CLIENT_ID=${NEXT_PUBLIC_CLIENT_ID} @@ -21,4 +21,5 @@ services: - NEXT_PUBLIC_API_URL=${NEXT_PUBLIC_API_URL} - NEXT_PUBLIC_CLIENT_ID=${NEXT_PUBLIC_CLIENT_ID} - NEXT_PUBLIC_CLIENT_SECRET=${NEXT_PUBLIC_CLIENT_SECRET} - - APP_PORT=${APP_PORT} \ No newline at end of file + - APP_PORT=${APP_PORT} + - NODE_ENV=${NODE_ENV}