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