From a2d34c97edcdc34f14b4b99a1bca6c1b43e80006 Mon Sep 17 00:00:00 2001 From: Ibrahim <93064150+IbrahimCSAE@users.noreply.github.com> Date: Fri, 10 Jan 2025 12:01:15 -0500 Subject: [PATCH] fix(docker): run compression regardless of APP_CONFIG being present ( in cases such as volume mount) (#4673) --- .docker/Viewer-v3.x/entrypoint.sh | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/.docker/Viewer-v3.x/entrypoint.sh b/.docker/Viewer-v3.x/entrypoint.sh index 75e27a8cb..c0801a0dd 100644 --- a/.docker/Viewer-v3.x/entrypoint.sh +++ b/.docker/Viewer-v3.x/entrypoint.sh @@ -7,20 +7,30 @@ if [ -n "$SSL_PORT" ] envsubst '${PORT}' < /usr/src/default.conf.template > /etc/nginx/conf.d/default.conf fi -if [ -n "$APP_CONFIG" ] ; then + +if [ -n "$APP_CONFIG" ]; then echo "$APP_CONFIG" > /usr/share/nginx/html${PUBLIC_URL}app-config.js - # Removes the old compressed app-config file, then compresses the replacement - # and finally creates a new empty file so that gunzip works correctly. - # This code is correct despite the AI warning otherwise about order of create/delete - rm /usr/share/nginx/html${PUBLIC_URL}app-config.js.gz - gzip /usr/share/nginx/html${PUBLIC_URL}app-config.js - touch /usr/share/nginx/html${PUBLIC_URL}app-config.js + echo "Using custom APP_CONFIG environment variable" +else + echo "Not using custom APP_CONFIG" fi -if [ ! -n "$APP_CONFIG" ] - then - echo "Not using custom app config" + +if [ -f /usr/share/nginx/html${PUBLIC_URL}app-config.js ]; then + if [ -s /usr/share/nginx/html${PUBLIC_URL}app-config.js ]; then + echo "Detected non-empty app-config.js. Ensuring .gz file is updated..." + rm -f /usr/share/nginx/html${PUBLIC_URL}app-config.js.gz + gzip /usr/share/nginx/html${PUBLIC_URL}app-config.js + touch /usr/share/nginx/html${PUBLIC_URL}app-config.js + echo "Compressed app-config.js to app-config.js.gz" + else + echo "app-config.js is empty. Skipping compression." + fi +else + echo "No app-config.js file found. Skipping compression." fi + + if [ -n "$CLIENT_ID" ] || [ -n "$HEALTHCARE_API_ENDPOINT" ] then # If CLIENT_ID is specified, use the google.js configuration with the modified ID