30 lines
846 B
Bash
Executable File
30 lines
846 B
Bash
Executable File
#!/bin/sh
|
|
# Load runtime configuration from secrets and generate config.js
|
|
# This script is called at container startup before nginx starts
|
|
|
|
set -e
|
|
|
|
SECRETS_DIR="${SECRETS_DIR:-/run/secrets}"
|
|
CONFIG_FILE="/usr/share/nginx/html/config.js"
|
|
GOOGLE_MAPS_API_KEY=""
|
|
|
|
# Try to read Google Maps API key from secret file
|
|
if [ -f "$SECRETS_DIR/google-maps-api-key" ]; then
|
|
GOOGLE_MAPS_API_KEY=$(cat "$SECRETS_DIR/google-maps-api-key")
|
|
echo "[Config] Loaded Google Maps API key from $SECRETS_DIR/google-maps-api-key"
|
|
else
|
|
echo "[Config] Warning: Google Maps API key not found at $SECRETS_DIR/google-maps-api-key"
|
|
GOOGLE_MAPS_API_KEY=""
|
|
fi
|
|
|
|
# Generate config.js
|
|
cat > "$CONFIG_FILE" <<EOF
|
|
window.CONFIG = {
|
|
googleMapsApiKey: '$GOOGLE_MAPS_API_KEY'
|
|
};
|
|
EOF
|
|
|
|
echo "[Config] Generated $CONFIG_FILE"
|
|
echo "[Config] Config contents:"
|
|
cat "$CONFIG_FILE"
|