use TurboVNC with xfce4 instead of Xvfb+X11vnc, 1.36GB -> 1.51GB total

This commit is contained in:
Ralf Vogler 2025-06-05 21:17:09 +02:00
parent c5f0c20322
commit 4cf2718077
2 changed files with 22 additions and 18 deletions

View file

@ -12,15 +12,21 @@ ARG DEBIAN_FRONTEND=noninteractive
RUN apt-get update \ RUN apt-get update \
&& apt-get install -y --no-install-recommends curl ca-certificates gnupg \ && apt-get install -y --no-install-recommends curl ca-certificates gnupg \
&& mkdir -p /etc/apt/keyrings \ && mkdir -p /etc/apt/keyrings \
# Node.js
&& curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg \ && curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg \
&& echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_20.x nodistro main" | tee /etc/apt/sources.list.d/nodesource.list \ && echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_20.x nodistro main" | tee /etc/apt/sources.list.d/nodesource.list \
# TurboVNC & VirtualGL instead of Xvfb+X11vnc
&& curl -fsSL https://packagecloud.io/dcommander/virtualgl/gpgkey | gpg --dearmor -o /etc/apt/trusted.gpg.d/VirtualGL.gpg \
&& curl -fsSL https://packagecloud.io/dcommander/turbovnc/gpgkey | gpg --dearmor -o /etc/apt/trusted.gpg.d/TurboVNC.gpg \
&& curl -fssl https://raw.githubusercontent.com/VirtualGL/repo/main/VirtualGL.list > /etc/apt/sources.list.d/VirtualGL.list \
&& curl -fssl https://raw.githubusercontent.com/TurboVNC/repo/main/TurboVNC.list > /etc/apt/sources.list.d/TurboVNC.list \
# update lists and install
&& apt-get update \ && apt-get update \
&& apt-get install --no-install-recommends -y \ && apt-get install --no-install-recommends -y \
nodejs \ virtualgl turbovnc xfce4 \
xvfb \
x11vnc \
tini \
novnc websockify \ novnc websockify \
tini \
nodejs \
dos2unix \ dos2unix \
python3-pip \ python3-pip \
# RUN npx patchright install-deps chromium # RUN npx patchright install-deps chromium
@ -38,6 +44,9 @@ RUN apt-get update \
libpango-1.0-0 \ libpango-1.0-0 \
libcairo2 \ libcairo2 \
libasound2 \ libasound2 \
# needed for TurboVNC if not installing xfce4:
# libxdamage1 \
# libxrandr2 \
&& apt-get autoremove -y \ && apt-get autoremove -y \
# https://www.perplexity.ai/search/what-files-do-i-need-to-remove-imjwdphNSUWK98WzsmQswA # https://www.perplexity.ai/search/what-files-do-i-need-to-remove-imjwdphNSUWK98WzsmQswA
&& apt-get clean \ && apt-get clean \

View file

@ -18,26 +18,21 @@ rm -f "/fgc/$BROWSER/SingletonLock"
# Maybe no longer needed after adding #478's -nolisten unix below # Maybe no longer needed after adding #478's -nolisten unix below
rm -f /tmp/.X1-lock rm -f /tmp/.X1-lock
# 6000+SERVERNUM is the TCP port Xvfb is listening on:
# SERVERNUM=$(echo "$DISPLAY" | sed 's/:\([0-9][0-9]*\).*/\1/')
# Options passed directly to the Xvfb server:
# -ac disables host-based access control mechanisms
# screen NUM WxHxD creates the screen and sets its width, height, and depth
# -nolisten unix tells the server not to use Unix domain sockets, thus avoiding the need to create /tmp/.X11-unix
export DISPLAY=:1 # need to export this, otherwise playwright complains with 'Looks like you launched a headed browser without having a XServer running.' export DISPLAY=:1 # need to export this, otherwise playwright complains with 'Looks like you launched a headed browser without having a XServer running.'
Xvfb $DISPLAY -ac -screen 0 "${WIDTH}x${HEIGHT}x${DEPTH}" -nolisten unix +extension GLX +extension RENDER &
echo "Xvfb display server created screen with resolution ${WIDTH}x${HEIGHT}"
if [ -z "$VNC_PASSWORD" ]; then if [ -z "$VNC_PASSWORD" ]; then
pw="-nopw" pw="-SecurityTypes None"
pwt="no password!" pwt="no password!"
else else
pw="-passwd $VNC_PASSWORD" # pw="-passwd $VNC_PASSWORD" # not supported anymore
pw="-rfbauth ~/.vnc/passwd"
mkdir ~/.vnc/
echo "$VNC_PASSWORD" | /opt/TurboVNC/bin/vncpasswd -f > ~/.vnc/passwd
pwt="with password" pwt="with password"
fi fi
x11vnc -display $DISPLAY -forever -shared -rfbport "$VNC_PORT" -bg "$pw" 2>/dev/null 1>&2 # TurboVNC server replaces Xvfb+x11vnc
echo "VNC is running on port $VNC_PORT ($pwt)" /opt/TurboVNC/bin/vncserver $DISPLAY -geometry "${WIDTH}x${HEIGHT}" -depth ${DEPTH} -rfbport ${VNC_PORT} $pw -vgl -log /fgc/data/TurboVNC.log -xstartup /usr/bin/startxfce4 2>/dev/null # -noxstartup -novnc /usr/share/novnc/
echo "TurboVNC is running on port $VNC_PORT ($pwt) with resolution ${WIDTH}x${HEIGHT}"
# TODO keep websockify just for custom NOVNC_PORT? https://www.perplexity.ai/search/how-to-specify-the-novnc-port-rfv96C9tTZufnyFPRye5xA#0
websockify -D --web "/usr/share/novnc/" "$NOVNC_PORT" "localhost:$VNC_PORT" 2>/dev/null 1>&2 & websockify -D --web "/usr/share/novnc/" "$NOVNC_PORT" "localhost:$VNC_PORT" 2>/dev/null 1>&2 &
echo "noVNC (VNC via browser) is running on http://localhost:$NOVNC_PORT" echo "noVNC (VNC via browser) is running on http://localhost:$NOVNC_PORT"
echo echo