#!/bin/sh # Injects runtime env vars into /usr/share/nginx/html/env.js # which is loaded by index.html before the React bundle. # Values come from Docker env vars (set via env_file in docker-compose.yml). set -e ENV_JS="/usr/share/nginx/html/env.js" # Escapes a value for safe embedding in a double-quoted JS string literal # (backslashes, double quotes; newlines collapsed to spaces). js_escape() { printf '%s' "$1" | tr '\n' ' ' | sed 's/\\/\\\\/g; s/"/\\"/g' } SITE_NAME=$(js_escape "${APP_SITE_NAME:-Faunosteo}") BRAND_NAME=$(js_escape "${APP_BRAND_NAME:-Faunosteo}") FOOTER_NAME=$(js_escape "${APP_FOOTER_NAME:-Faunosteo}") TAGLINE=$(js_escape "${APP_TAGLINE:-Outils pour ostéopathes animaliers}") cat > "$ENV_JS" < /tmp/nginx_default.conf cp /tmp/nginx_default.conf /etc/nginx/conf.d/default.conf exec nginx -g "daemon off;"