Make omsorgapp's backend URL runtime-configurable, use dedicated API subdomain
Docker-Images bauen und veröffentlichen / build (, omsorgCore/Dockerfile, omsorgcore) (push) Successful in 3s
Docker-Images bauen und veröffentlichen / build (, omsorgWeb/Dockerfile, omsorgweb) (push) Successful in 3s
Docker-Images bauen und veröffentlichen / build (, omsorgapp/Dockerfile, omsorgapp) (push) Successful in 3s
Docker-Images bauen und veröffentlichen / build (, omsorgCore/Dockerfile, omsorgcore) (push) Successful in 3s
Docker-Images bauen und veröffentlichen / build (, omsorgWeb/Dockerfile, omsorgweb) (push) Successful in 3s
Docker-Images bauen und veröffentlichen / build (, omsorgapp/Dockerfile, omsorgapp) (push) Successful in 3s
- omsorgapp now reads the omsorgCore URL from a runtime env-config.js generated by the container entrypoint from OMSORG_CORE_URL, instead of only baking it in at image build time - docker-compose.yml pulls pre-built images from the registry, so a build-time-only value couldn't be changed without a rebuild. - docker-compose.yml: omsorgCore gets its own subdomain (core.omsorg-pflegedienste.de) rather than being proxied under the frontend's domain - omsorgWeb never needs browser-side access to it anyway (server-side cURL only), and a dedicated API host is more future-proof without being any less secure (backend still only bound to 127.0.0.1). Includes the nginx server-block snippet needed for the new subdomain. - Drop the now-unused OMSORG_CORE_PUBLIC_URL build-arg wiring from the Gitea Actions workflow. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 5
parent
2a05c791f5
commit
dcc8ea1510
@@ -13,9 +13,10 @@ RUN npm ci
|
||||
|
||||
COPY omsorgapp/ .
|
||||
|
||||
# Vite bäckt import.meta.env.VITE_OMSORG_CORE_URL (src/api/config.js) zur Build-Zeit ein - kein
|
||||
# Runtime-Wert. Default passt zum docker-compose.yml-Setup, für einen echten Deploy überschreibt
|
||||
# CI das per --build-arg mit der öffentlich erreichbaren omsorgCore-URL.
|
||||
# Fallback für lokale/CI-Builds ohne Container (npm run dev/build) - im Container selbst
|
||||
# entscheidet ausschließlich die Laufzeit-Env-Var OMSORG_CORE_URL (siehe docker-entrypoint.sh),
|
||||
# da dieses Image aus der Registry gezogen und per docker-compose.yml konfiguriert wird, nicht
|
||||
# pro Zielumgebung neu gebaut (siehe src/api/config.js).
|
||||
ARG VITE_OMSORG_CORE_URL=http://localhost:8080
|
||||
ENV VITE_OMSORG_CORE_URL=$VITE_OMSORG_CORE_URL
|
||||
RUN npm run build
|
||||
@@ -23,4 +24,7 @@ RUN npm run build
|
||||
FROM nginx:1.27-alpine AS runtime
|
||||
COPY --from=build /app/dist /usr/share/nginx/html
|
||||
COPY omsorgapp/nginx.conf /etc/nginx/conf.d/default.conf
|
||||
COPY omsorgapp/docker-entrypoint.sh /docker-entrypoint.sh
|
||||
RUN chmod +x /docker-entrypoint.sh
|
||||
EXPOSE 80
|
||||
ENTRYPOINT ["/docker-entrypoint.sh"]
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
|
||||
# Schreibt die Laufzeit-Backend-Adresse in env-config.js, bevor nginx startet - siehe
|
||||
# src/api/config.js. OMSORG_CORE_URL kommt aus docker-compose.yml, muss vom BROWSER erreichbar
|
||||
# sein (nicht der interne Compose-Servicename), z.B. https://core.omsorg-pflegedienste.de.
|
||||
cat > /usr/share/nginx/html/env-config.js <<EOF
|
||||
window.__OMSORG_ENV__ = { OMSORG_CORE_URL: "${OMSORG_CORE_URL:-}" };
|
||||
EOF
|
||||
|
||||
exec nginx -g "daemon off;"
|
||||
@@ -1 +1 @@
|
||||
<!doctype html><html lang="de"><head><meta charset="UTF-8"/><meta name="viewport" content="width=device-width, initial-scale=1.0"/><title>Omsorg Business Controls Pro</title></head><body><div id="root"></div><script type="module" src="/src/main.jsx"></script></body></html>
|
||||
<!doctype html><html lang="de"><head><meta charset="UTF-8"/><meta name="viewport" content="width=device-width, initial-scale=1.0"/><title>Omsorg Business Controls Pro</title></head><body><div id="root"></div><script src="/env-config.js"></script><script type="module" src="/src/main.jsx"></script></body></html>
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
// Dev-Default (Vite serviert alles unter public/ unverändert unter /) - im Docker-Image wird
|
||||
// diese Datei vom Entrypoint (docker-entrypoint.sh) aus der OMSORG_CORE_URL-Env-Var überschrieben,
|
||||
// siehe src/api/config.js.
|
||||
window.__OMSORG_ENV__ = {};
|
||||
@@ -1,4 +1,8 @@
|
||||
// Einzige Stelle im Projekt, die die Adresse von omsorgCore kennt.
|
||||
// Default passt zum lokalen `dotnet run --project src/OmsorgCore.Api` (http-Profil, Port 5245),
|
||||
// überschreibbar per Vite-Env-Variable (VITE_OMSORG_CORE_URL) für andere Umgebungen.
|
||||
export const API_BASE = import.meta.env.VITE_OMSORG_CORE_URL || "http://localhost:5245";
|
||||
// Reihenfolge: 1) Laufzeit-Konfiguration (window.__OMSORG_ENV__, aus env-config.js - vom
|
||||
// nginx-Entrypoint im Container aus der OMSORG_CORE_URL-Env-Var generiert, siehe
|
||||
// omsorgapp/docker-entrypoint.sh) - so lässt sich die Backend-Adresse rein über
|
||||
// docker-compose.yml setzen, ohne das Image neu zu bauen. 2) Vite-Build-Zeit-Env
|
||||
// (VITE_OMSORG_CORE_URL, für `npm run dev`/lokale Builds ohne Container). 3) localhost-Default.
|
||||
export const API_BASE =
|
||||
window.__OMSORG_ENV__?.OMSORG_CORE_URL || import.meta.env.VITE_OMSORG_CORE_URL || "http://localhost:5245";
|
||||
|
||||
Reference in New Issue
Block a user