From a0faad6ddc982615b7fe0c16612e5d0505fd0c00 Mon Sep 17 00:00:00 2001 From: Michael Salim Date: Sat, 16 Aug 2025 22:10:13 +0100 Subject: [PATCH 1/2] Feat: Playwright NODE_ENV to prod --- e2e/playwright.config.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/e2e/playwright.config.ts b/e2e/playwright.config.ts index 928d369d..2680f61a 100644 --- a/e2e/playwright.config.ts +++ b/e2e/playwright.config.ts @@ -83,5 +83,8 @@ export default defineConfig({ command: "yarn server start", url: "http://localhost:5678", reuseExistingServer: !process.env.CI, + env: { + NODE_ENV: "production", + }, }, }); From 0572eda7c7bd5c9e478ded728b0f6e7efe458005 Mon Sep 17 00:00:00 2001 From: Michael Salim Date: Sat, 16 Aug 2025 22:18:34 +0100 Subject: [PATCH 2/2] Chore: Make process next env runable outside of docker --- .../server/scripts/process-public-next-env.sh | 25 +++++++++++++------ 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/backend/server/scripts/process-public-next-env.sh b/backend/server/scripts/process-public-next-env.sh index 497f2e93..26ad42d3 100644 --- a/backend/server/scripts/process-public-next-env.sh +++ b/backend/server/scripts/process-public-next-env.sh @@ -5,7 +5,16 @@ then if [ "$NODE_ENV" = "production" ] then echo "Preprocessing environment variables" - echo "This should only run on our docker build" + + # Determine the project root directory + # If running in Docker, use /app, otherwise use relative path from backend/server + if [ -d "/app" ]; then + PROJECT_ROOT="/app" + else + PROJECT_ROOT="$(cd "$(dirname "$0")/../../.." && pwd)" + fi + + echo "Using project root: $PROJECT_ROOT" # For each of the var in .env.production, replace with proper process env while read line; do @@ -14,8 +23,8 @@ then eval "ACTUAL_ENV=\$$ENV_NAME" - find /app/apps/homepage/.next -type f -name "*.js" -print0 | xargs -0 -P $(nproc) sed -i "s|$STRING_TO_REPLACE|$ACTUAL_ENV|g"; - done < /app/backend/server/.env.production + find "$PROJECT_ROOT/apps/homepage/.next" -type f -name "*.js" -print0 | xargs -0 -P $(nproc) sed -i "s|$STRING_TO_REPLACE|$ACTUAL_ENV|g"; + done < "$PROJECT_ROOT/backend/server/.env.production" while read line; do ENV_NAME=$(echo "$line" | cut -d "=" -f 1) @@ -23,16 +32,16 @@ then eval "ACTUAL_ENV=\$$ENV_NAME" - find /app/apps/remote/dist -type f -name "*.js" -print0 | xargs -0 -P $(nproc) sed -i "s|$STRING_TO_REPLACE|$ACTUAL_ENV|g"; - done < /app/apps/remote/.env.production - + find "$PROJECT_ROOT/apps/remote/dist" -type f -name "*.js" -print0 | xargs -0 -P $(nproc) sed -i "s|$STRING_TO_REPLACE|$ACTUAL_ENV|g"; + done < "$PROJECT_ROOT/apps/remote/.env.production" + while read line; do ENV_NAME=$(echo "$line" | cut -d "=" -f 1) STRING_TO_REPLACE=$(echo "$line" | cut -d "=" -f 2) eval "ACTUAL_ENV=\$$ENV_NAME" - find /app/apps/renderer/dist -type f -name "*.js" -print0 | xargs -0 -P $(nproc) sed -i "s|$STRING_TO_REPLACE|$ACTUAL_ENV|g"; - done < /app/apps/renderer/.env.production + find "$PROJECT_ROOT/apps/renderer/dist" -type f -name "*.js" -print0 | xargs -0 -P $(nproc) sed -i "s|$STRING_TO_REPLACE|$ACTUAL_ENV|g"; + done < "$PROJECT_ROOT/apps/renderer/.env.production" fi fi