diff --git a/config/frontends/desktop-app/Dockerfile b/config/frontends/desktop-app/Dockerfile index 6e180672..699b9147 100644 --- a/config/frontends/desktop-app/Dockerfile +++ b/config/frontends/desktop-app/Dockerfile @@ -32,20 +32,19 @@ RUN ./gradlew :frontend:shells:meldestelle-portal:dependencies --no-daemon RUN ./gradlew :frontend:shells:meldestelle-portal:createDistributable --no-daemon # =================================================================== -# 2. Runtime Stage - Ubuntu (Notwendig für GUI/X11 Libraries) +# Stage 2: Runtime Stage - Ubuntu mit VNC + noVNC # =================================================================== FROM ubuntu:22.04 ENV DEBIAN_FRONTEND=noninteractive -# Installiere X11, VNC, Window Manager und Libraries für Compose Multiplatform -# Compose braucht oft libgl1-mesa-glx, libgtk-3-0, libasound2 etc. +# Installiere System-Dependencies RUN apt-get update && apt-get install -y \ openjdk-21-jdk \ xvfb \ x11vnc \ - novnc \ - websockify \ + python3 \ + python3-numpy \ xfce4 \ xfce4-goodies \ curl \ @@ -53,11 +52,27 @@ RUN apt-get update && apt-get install -y \ unzip \ supervisor \ net-tools \ + git \ + # WICHTIG: GUI Libraries für Java/Compose libgl1-mesa-glx \ + libgl1-mesa-dri \ libgtk-3-0 \ libasound2 \ + libxcursor1 \ + libxi6 \ + libxtst6 \ + libxrandr2 \ + && apt-get remove -y xfce4-power-manager \ + && apt-get autoremove -y \ && rm -rf /var/lib/apt/lists/* +# Manuelle Installation von noVNC und Websockify +# Wir klonen Websockify an den Ort, wo noVNC es erwartet +RUN mkdir -p /usr/share/novnc \ + && git clone --depth 1 https://github.com/novnc/noVNC.git /usr/share/novnc \ + && git clone --depth 1 https://github.com/novnc/websockify /usr/share/novnc/utils/websockify \ + && ln -s /usr/share/novnc/vnc.html /usr/share/novnc/index.html + WORKDIR /app # Kopiere Build-Ergebnis diff --git a/config/frontends/desktop-app/entrypoint.sh b/config/frontends/desktop-app/entrypoint.sh index 8a1d1c37..b7bf99dc 100644 --- a/config/frontends/desktop-app/entrypoint.sh +++ b/config/frontends/desktop-app/entrypoint.sh @@ -1,137 +1,79 @@ #!/bin/bash -# =================================================================== -# Entrypoint-Script für Meldestelle Desktop-App (VNC) -# =================================================================== - set -e -# Logging-Funktion -log() { - echo "[$(date '+%Y-%m-%d %H:%M:%S')] $1" -} +log() { echo "[$(date '+%Y-%m-%d %H:%M:%S')] $1"; } -log "Starting Meldestelle Desktop-App VNC Container..." +log "Starting Meldestelle Desktop-App..." -# Environment-Variablen setzen export DISPLAY=${DISPLAY:-:99} export VNC_PORT=${VNC_PORT:-5901} export NOVNC_PORT=${NOVNC_PORT:-6080} -export API_BASE_URL=${API_BASE_URL:-http://api-gateway:8081} -# Standard-Passwort setzen, falls keines über ENV kommt export VNC_PW=${VNC_PW:-meldestelle} +export API_BASE_URL=${API_BASE_URL:-http://api-gateway:8081} +# Grafik-Optimierungen für Docker (Software Rendering erzwingen) +export SKIKO_RENDER_API="SOFTWARE" +export LIBGL_ALWAYS_SOFTWARE=1 +export MESA_GL_VERSION_OVERRIDE=3.3 -log "Environment:" -log " DISPLAY: $DISPLAY" -log " VNC_PORT: $VNC_PORT" -log " NOVNC_PORT: $NOVNC_PORT" -log " API_BASE_URL: $API_BASE_URL" - -# 0. VNC Passwort generieren -log "Generating VNC password..." +# 0. VNC Passwort Setup mkdir -p /home/vncuser/.vnc x11vnc -storepasswd "$VNC_PW" /home/vncuser/.vnc/passwd -# Erstelle .Xauthority wenn nicht vorhanden -touch /home/vncuser/.Xauthority - -# 1. Starte X11 Virtual Display (Xvfb) -log "Starting Xvfb on display $DISPLAY..." -# rm -f /tmp/.X99-lock # Aufräumen falls Container neu gestartet wurde (optional) +# 1. Start Xvfb +log "Starting Xvfb..." +rm -f /tmp/.X99-lock Xvfb $DISPLAY -screen 0 1280x1024x24 -ac +extension GLX +render -noreset & -XVFB_PID=$! +sleep 2 -# Warte bis X11 bereit ist -sleep 3 - -# 2. Starte Desktop Environment (XFCE4) -log "Starting XFCE4 desktop environment..." +# 2. Start Window Manager +log "Starting XFCE4..." startxfce4 & -XFCE_PID=$! +sleep 2 -# Warte bis Desktop bereit ist -sleep 5 - -# 3. Starte VNC Server -log "Starting VNC server on port $VNC_PORT..." -# WICHTIG: -rfbauth statt -usepw nutzen, um interaktive Abfrage zu vermeiden +# 3. Start VNC Server +log "Starting x11vnc on port $VNC_PORT..." x11vnc -display $DISPLAY -forever -rfbauth /home/vncuser/.vnc/passwd -create -rfbport $VNC_PORT -shared -bg -VNC_PID=$! -# 4. Start noVNC (Websockify) +# 4. Start noVNC (Fix für Websockify Pfad) log "Starting noVNC on port $NOVNC_PORT..." +# Wir nutzen das mitgelieferte Proxy-Script, das ist robuster als websockify direkt aufzurufen +/usr/share/novnc/utils/novnc_proxy --vnc localhost:$VNC_PORT --listen $NOVNC_PORT & +NOVNC_PID=$! -# Pfad-Korrektur für Ubuntu novnc -WEB_DIR="/usr/share/novnc" -if [ ! -d "$WEB_DIR" ]; then - log "WARNING: $WEB_DIR not found! Searching..." - WEB_DIR=$(find /usr/share -type d -name "novnc" | head -n 1) +# 5. Start Desktop App (Fix für Pfad-Probleme) +log "Searching for App binary..." + +# Wir suchen rekursiv nach der Datei "Meldestelle" im Ordner "bin", die ausführbar ist +# Screenshot zeigte: /app/desktop-app/Meldestelle/bin/Meldestelle +APP_PATH=$(find /app/desktop-app -type f -path "*/bin/Meldestelle" | head -n 1) + +if [ -z "$APP_PATH" ]; then + # Fallback: Suche irgendeine Datei im bin Ordner, die KEIN Shellscript/Bat ist und executable + APP_PATH=$(find /app/desktop-app -type f -path "*/bin/*" ! -name "*.sh" ! -name "*.bat" | head -n 1) fi -# Fix: Index File erstellen, falls es fehlt (Ubuntu hat oft nur vnc.html) -if [ -d "$WEB_DIR" ] && [ ! -f "$WEB_DIR/index.html" ]; then - log "Fixing missing index.html in noVNC..." - if [ -f "$WEB_DIR/vnc.html" ]; then - ln -s "$WEB_DIR/vnc.html" "$WEB_DIR/index.html" - elif [ -f "$WEB_DIR/vnc_lite.html" ]; then - ln -s "$WEB_DIR/vnc_lite.html" "$WEB_DIR/index.html" - fi -fi - -log "Serving noVNC from: $WEB_DIR" - -# Starte Websockify im Vordergrund, wenn es crasht, sehen wir es -websockify --web="$WEB_DIR" $NOVNC_PORT localhost:$VNC_PORT & - -# 5. Warte bis Services bereit sind -sleep 5 - -# 6. Starte Desktop-App -log "Starting Meldestelle Desktop-App..." -cd /app/desktop-app -export API_BASE_URL=$API_BASE_URL - -# Finde die ausführbare Datei -if [ -f "client/bin/client" ]; then - DESKTOP_APP="client/bin/client" -elif [ -f "bin/client" ]; then - DESKTOP_APP="bin/client" -elif [ -f "client" ]; then - DESKTOP_APP="client" -else - log "ERROR: Desktop-App executable not found!" - log "Contents of /app/desktop-app:" - ls -R /app/desktop-app/ - # Wir beenden hier NICHT, damit man debuggen kann (VNC bleibt offen) - log "Keeping VNC open for debugging..." -fi - -if [ -n "$DESKTOP_APP" ]; then - log "Found desktop app: $DESKTOP_APP" - chmod +x "$DESKTOP_APP" - # Starte Desktop-App - ./"$DESKTOP_APP" & +if [ -f "$APP_PATH" ]; then + log "🚀 Launching App from: $APP_PATH" + chmod +x "$APP_PATH" + "$APP_PATH" & APP_PID=$! +else + log "❌ CRITICAL ERROR: App binary not found!" + log "Files in /app/desktop-app:" + ls -R /app/desktop-app fi -log "All services started successfully!" -log "VNC: vnc://localhost:$VNC_PORT (Password: $VNC_PW)" -log "noVNC: http://localhost:$NOVNC_PORT/vnc.html" +log "Ready! Access: http://localhost:6080/vnc.html" -# Cleanup-Funktion +# Cleanup bei Stop cleanup() { - log "Shutting down services..." + log "Stopping..." if [ -n "$APP_PID" ]; then kill $APP_PID 2>/dev/null || true; fi kill $NOVNC_PID 2>/dev/null || true - # x11vnc läuft im Background (-bg), PID ist schwerer zu greifen, killall hilft: pkill x11vnc || true - kill $XFCE_PID 2>/dev/null || true - kill $XVFB_PID 2>/dev/null || true exit 0 } - -# Signal-Handler trap cleanup SIGTERM SIGINT -# Warten auf Prozesse (unendlich, damit Container nicht stirbt wenn App crasht) -# wait $APP_PID +# Loggt Websockify Output in die Konsole tail -f /dev/null diff --git a/docker-compose.yaml b/docker-compose.yaml index 231bb9d8..79433f63 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -358,7 +358,7 @@ services: aliases: - "web-app" - # --- DESKTOP-APP --- + # --- DESKTOP-APP (optional) --- desktop-app: build: context: .