Docker: Runtime-Config via window.__RMM_CONFIG__ (kein Rebuild bei Backend-Wechsel)

- 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
This commit is contained in:
cynfo3000
2026-03-10 17:43:53 +01:00
parent 54ddc0b902
commit 582eb5c8c1
4 changed files with 63 additions and 1 deletions
+23
View File
@@ -0,0 +1,23 @@
# Stage 1: Build
FROM node:22-alpine AS builder
WORKDIR /app
COPY package.json package-lock.json ./
RUN npm ci
COPY . .
RUN npm run build
# Stage 2: Serve
FROM nginx:alpine
COPY --from=builder /app/dist /usr/share/nginx/html
COPY nginx.conf /etc/nginx/conf.d/default.conf
COPY docker-entrypoint.sh /docker-entrypoint.sh
RUN chmod +x /docker-entrypoint.sh
# Runtime-Konfiguration via Umgebungsvariablen
# BACKEND_HOST, BACKEND_PORT werden in window.__RMM_CONFIG__ injiziert
ENV BACKEND_HOST=localhost
ENV BACKEND_PORT=8443
EXPOSE 80
ENTRYPOINT ["/docker-entrypoint.sh"]
CMD ["nginx", "-g", "daemon off;"]