diff --git a/frontend/Dockerfile b/frontend/Dockerfile new file mode 100644 index 0000000..ed96e67 --- /dev/null +++ b/frontend/Dockerfile @@ -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;"] diff --git a/frontend/docker-entrypoint.sh b/frontend/docker-entrypoint.sh new file mode 100644 index 0000000..2172cd5 --- /dev/null +++ b/frontend/docker-entrypoint.sh @@ -0,0 +1,16 @@ +#!/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 "$@" diff --git a/frontend/index.html b/frontend/index.html index c20fbd3..148989e 100644 --- a/frontend/index.html +++ b/frontend/index.html @@ -4,7 +4,9 @@ -