- Dockerfile: multistage build (node -> nginx) - docker-entrypoint.sh: injiziert BACKEND_HOST/PORT zur Laufzeit - nginx.conf: SPA-Routing, config.js no-cache - index.html: laedt /config.js vor dem React-Bundle Usage: docker run -e BACKEND_HOST=rmm.example.com -e BACKEND_PORT=8443 -p 80:80 rmm-frontend
17 lines
448 B
Bash
17 lines
448 B
Bash
#!/bin/sh
|
|
# Injiziert BACKEND_HOST/PORT zur Laufzeit in window.__RMM_CONFIG__
|
|
# So muss das Image nicht neu gebaut werden wenn sich der Backend-Host ändert
|
|
|
|
CONFIG_JS="/usr/share/nginx/html/config.js"
|
|
|
|
cat > "$CONFIG_JS" << EOF
|
|
// Injiziert durch Docker-Entrypoint
|
|
window.__RMM_CONFIG__ = {
|
|
backendHost: "${BACKEND_HOST}",
|
|
backendPort: "${BACKEND_PORT}"
|
|
};
|
|
EOF
|
|
|
|
echo "RMM Frontend: Backend = https://${BACKEND_HOST}:${BACKEND_PORT}"
|
|
exec "$@"
|