Switch from Caddy templates to runtime envsubst for API and Keycloak URLs, adjust Dockerfile and entrypoint script
Build and Publish Docker Images / build-and-push (., backend/infrastructure/gateway/Dockerfile, api-gateway, api-gateway) (push) Successful in 8m31s
Build and Publish Docker Images / build-and-push (., backend/services/ping/Dockerfile, ping-service, ping-service) (push) Successful in 7m20s
Build and Publish Docker Images / build-and-push (., config/docker/caddy/web-app/Dockerfile, web-app, web-app) (push) Successful in 2m1s
Build and Publish Docker Images / build-and-push (., config/docker/keycloak/Dockerfile, keycloak, keycloak) (push) Successful in 1m39s
Build and Publish Docker Images / build-and-push (., backend/infrastructure/gateway/Dockerfile, api-gateway, api-gateway) (push) Successful in 8m31s
Build and Publish Docker Images / build-and-push (., backend/services/ping/Dockerfile, ping-service, ping-service) (push) Successful in 7m20s
Build and Publish Docker Images / build-and-push (., config/docker/caddy/web-app/Dockerfile, web-app, web-app) (push) Successful in 2m1s
Build and Publish Docker Images / build-and-push (., config/docker/keycloak/Dockerfile, keycloak, keycloak) (push) Successful in 1m39s
This commit is contained in:
@@ -14,13 +14,13 @@
|
||||
</div>
|
||||
|
||||
<!--
|
||||
Schritt 1: Caddy füllt dieses JSON-Template aus.
|
||||
Der Inhalt ist reines JSON, was Syntaxkonflikte mit JS vermeidet.
|
||||
Schritt 1: Der Container-Entrypoint ersetzt ${API_BASE_URL} und ${KEYCLOAK_URL}
|
||||
via envsubst beim Start. Caddy bekommt eine fertige statische Datei ohne Template-Parsing.
|
||||
-->
|
||||
<script id="app-config" type="application/json">
|
||||
{
|
||||
"apiBaseUrl": "{{.Env.API_BASE_URL}}",
|
||||
"keycloakUrl": "{{.Env.KEYCLOAK_URL}}"
|
||||
"apiBaseUrl": "${API_BASE_URL}",
|
||||
"keycloakUrl": "${KEYCLOAK_URL}"
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -33,20 +33,20 @@
|
||||
const config = JSON.parse(configJson);
|
||||
const params = new URLSearchParams(window.location.search);
|
||||
|
||||
const tmplPrefix = '{' + '{'; // Verhindert, dass Caddy '{{' als Template-Action interpretiert
|
||||
const notReplaced = '${'; // Fallback-Erkennung: envsubst hat den Wert NICHT ersetzt
|
||||
const apiFromCaddy = config.apiBaseUrl;
|
||||
const apiOverride = params.get('apiBaseUrl');
|
||||
globalThis.API_BASE_URL = apiOverride
|
||||
? apiOverride.replace(/\/$/, '')
|
||||
: (apiFromCaddy && !apiFromCaddy.startsWith(tmplPrefix)
|
||||
: (apiFromCaddy && !apiFromCaddy.startsWith(notReplaced)
|
||||
? apiFromCaddy.replace(/\/$/, '')
|
||||
: 'http://' + window.location.origin.replace(/\/$/, ''));
|
||||
: 'http://' + window.location.hostname + ':8081');
|
||||
|
||||
const kcFromCaddy = config.keycloakUrl;
|
||||
const kcOverride = params.get('keycloakUrl');
|
||||
globalThis.KEYCLOAK_URL = kcOverride
|
||||
? kcOverride.replace(/\/$/, '')
|
||||
: (kcFromCaddy && !kcFromCaddy.startsWith(tmplPrefix)
|
||||
: (kcFromCaddy && !kcFromCaddy.startsWith(notReplaced)
|
||||
? kcFromCaddy.replace(/\/$/, '')
|
||||
: 'http://' + window.location.hostname + ':8180');
|
||||
|
||||
|
||||
Reference in New Issue
Block a user