#!/bin/sh # Inject tag into index.html when BASE_PATH is set. # This allows the SPA to be served from a subpath (e.g., /server/). # Default: / (standalone mode, no tag needed). BASE_PATH="${BASE_PATH:-/}" if [ "$BASE_PATH" != "/" ]; then # Ensure BASE_PATH starts and ends with / BASE_PATH=$(echo "$BASE_PATH" | sed 's#/*$#/#; s#^/*#/#') INDEX="/usr/share/nginx/html/index.html" # Inject tag after and rewrite absolute asset paths sed -i "s|||" "$INDEX" sed -i "s|href=\"/|href=\"${BASE_PATH}|g; s|src=\"/|src=\"${BASE_PATH}|g" "$INDEX" echo "BASE_PATH set to ${BASE_PATH} — rewrote index.html" fi # Delegate to the default nginx entrypoint (handles envsubst for nginx templates) exec /docker-entrypoint.sh "$@"