feat: fertige Docker Images via Gitea Actions + Runtime-Konfiguration
Docker Images bauen und pushen / build-and-push (push) Has been cancelled
Docker Images bauen und pushen / build-and-push (push) Has been cancelled
CI/CD: - .gitea/workflows/docker-publish.yml: baut + pusht bei Push auf release und Tags - Images: git.cynfo.net/christian/rmm2/backend:latest + frontend:latest - Gitea Secrets: REGISTRY_USER + REGISTRY_PASSWORD gesetzt Runtime-Konfiguration (kein Rebuild bei IP-Aenderung): - frontend/docker-entrypoint.sh: generiert runtime-config.js aus ENV-Vars beim Start - frontend/src/config.js: window.__RMM_CONFIG__ (Docker) vor Vite-ENV (in .gitignore, nicht im release-Commit) - frontend/public/runtime-config.js: leerer Fallback fuer lokale Entwicklung - frontend/index.html: laedt /runtime-config.js vor dem App-Bundle docker-compose: - Nutzt fertige Images aus der Gitea Registry - docker-compose.build.yml: Override fuer lokalen Build - Alle Frontend-Werte via ENV zur Laufzeit
This commit is contained in:
+8
-11
@@ -5,16 +5,6 @@ COPY package*.json ./
|
||||
RUN npm ci
|
||||
|
||||
COPY . .
|
||||
|
||||
# Backend-URL wird zur Build-Zeit via ARG gesetzt
|
||||
ARG VITE_BACKEND_HOST=localhost
|
||||
ARG VITE_BACKEND_PORT=8443
|
||||
ARG VITE_API_KEY=""
|
||||
|
||||
ENV VITE_BACKEND_HOST=$VITE_BACKEND_HOST \
|
||||
VITE_BACKEND_PORT=$VITE_BACKEND_PORT \
|
||||
VITE_API_KEY=$VITE_API_KEY
|
||||
|
||||
RUN npm run build
|
||||
|
||||
# ---
|
||||
@@ -23,7 +13,14 @@ 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
|
||||
|
||||
EXPOSE 80
|
||||
|
||||
CMD ["nginx", "-g", "daemon off;"]
|
||||
# Konfiguration via ENV zur Laufzeit (kein Rebuild bei IP-Aenderung noetig)
|
||||
ENV BACKEND_HOST=localhost \
|
||||
BACKEND_PORT=8443 \
|
||||
API_KEY=""
|
||||
|
||||
ENTRYPOINT ["/docker-entrypoint.sh"]
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
#!/bin/sh
|
||||
# Generiert /usr/share/nginx/html/runtime-config.js aus ENV-Variablen
|
||||
# Wird beim Container-Start ausgefuehrt
|
||||
|
||||
cat > /usr/share/nginx/html/runtime-config.js << EOF
|
||||
window.__RMM_CONFIG__ = {
|
||||
backendHost: "${BACKEND_HOST:-localhost}",
|
||||
backendPort: "${BACKEND_PORT:-8443}",
|
||||
apiKey: "${API_KEY:-}"
|
||||
};
|
||||
EOF
|
||||
|
||||
exec nginx -g "daemon off;"
|
||||
@@ -1,6 +1,8 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<!-- Runtime-Konfiguration (Docker): wird von nginx aus ENV-Vars generiert -->
|
||||
<script src="/runtime-config.js" onerror="window.__RMM_CONFIG__={}"></script>
|
||||
<meta charset="UTF-8" />
|
||||
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
// Lokaler Entwicklungs-Fallback — in Docker wird diese Datei durch
|
||||
// docker-entrypoint.sh mit echten Werten ueberschrieben
|
||||
window.__RMM_CONFIG__ = {};
|
||||
Reference in New Issue
Block a user