From 6dead2550815f88e358570cc4e575323f23daf82 Mon Sep 17 00:00:00 2001 From: Alex Date: Wed, 9 Sep 2026 11:26:16 +0100 Subject: [PATCH] build(frontend): keep a developer's .env.production.local across the UI build The script copied .env.development over frontend/.env.production.local and deleted it on exit, destroying a local override. An existing file is now set aside before the build and put back by the exit trap, whatever the build's outcome; without one, nothing is left behind. --- scripts/build_frontend.sh | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/scripts/build_frontend.sh b/scripts/build_frontend.sh index 294d2b11..95fc1dc9 100755 --- a/scripts/build_frontend.sh +++ b/scripts/build_frontend.sh @@ -19,8 +19,22 @@ fi # As in frontend/Dockerfile: the committed .env.development is the baseline # of the production build. The API rewrites VITE_API_HOST and VITE_BASE_URL # at runtime through /config.js, so those baked values never reach a browser. +# A developer's own .env.production.local is set aside for the build and put +# back afterwards, whatever happens in between. +saved_override="" +if [ -e .env.production.local ] || [ -L .env.production.local ]; then + saved_override="$(mktemp "${TMPDIR:-/tmp}/docsgpt-env-production-local.XXXXXX")" + cp -p .env.production.local "$saved_override" +fi +restore_override() { + if [ -n "$saved_override" ]; then + mv -f "$saved_override" .env.production.local + else + rm -f .env.production.local + fi +} +trap restore_override EXIT cp .env.development .env.production.local -trap 'rm -f .env.production.local' EXIT npm run build # Load the runtime config ahead of the bundle, as the nginx image does.