diff --git a/backend/server/scripts/process-public-next-env.sh b/backend/server/scripts/process-public-next-env.sh index 497f2e934..26ad42d33 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 diff --git a/e2e/playwright.config.ts b/e2e/playwright.config.ts index 928d369d4..2680f61a0 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", + }, }, });