Use custom fork of noVNC

This commit is contained in:
Josh.5
2023-09-18 01:15:47 +12:00
parent 20c6b515ed
commit 22cf7e5980
5 changed files with 35 additions and 150 deletions

View File

@@ -340,55 +340,45 @@ RUN \
&& \ && \
echo echo
# TODO: Deprecate neko and noVNC for KasmVNC # TODO: Deprecate neko
# Install Neko server # Install Neko server
COPY --from=m1k1o/neko:base /usr/bin/neko /usr/bin/neko COPY --from=m1k1o/neko:base /usr/bin/neko /usr/bin/neko
COPY --from=m1k1o/neko:base /var/www /var/www COPY --from=m1k1o/neko:base /var/www /var/www
# Install noVNC # Install Web Frontend
ARG NOVNC_VERSION=1.2.0 ARG FRONTEND_VERSION=0a6ab20
RUN \ RUN \
echo "**** Fetch noVNC ****" \ echo "**** Fetch Web Frontend ****" \
&& cd /tmp \
&& wget -O /tmp/novnc.tar.gz https://github.com/novnc/noVNC/archive/v${NOVNC_VERSION}.tar.gz \
&& \
echo "**** Extract noVNC ****" \
&& cd /tmp \
&& tar -xvf /tmp/novnc.tar.gz \
&& \
echo "**** Configure noVNC ****" \
&& cd /tmp/noVNC-${NOVNC_VERSION} \
&& sed -i 's/credentials: { password: password } });/credentials: { password: password },\n wsProtocols: ["'"binary"'"] });/g' app/ui.js \
&& mkdir -p /opt \ && mkdir -p /opt \
&& rm -rf /opt/noVNC \
&& cd /opt \ && cd /opt \
&& mv -f /tmp/noVNC-${NOVNC_VERSION} /opt/noVNC \ && rm -rf /opt/frontend \
&& cd /opt/noVNC \ && git clone https://github.com/Steam-Headless/frontend.git --branch master /opt/frontend \
&& ln -s vnc.html index.html \ && cd /opt/frontend \
&& chmod -R 755 /opt/noVNC \ && git checkout ${FRONTEND_VERSION} 2> /dev/null \
&& git submodule init \
&& git submodule update --depth 1 --recursive \
&& rm -rf /opt/frontend/.git \
&& \ && \
echo "**** Modify noVNC title ****" \ echo "**** Configure Web Frontend ****" \
&& sed -i '/ document.title =/c\ document.title = "Steam Headless - noVNC";' \ && echo '<!DOCTYPE html>' > /opt/frontend/index.html \
/opt/noVNC/app/ui.js \ && echo '<html><head><meta http-equiv="refresh" content="0;url=./web/"></head><body><p>If you are not redirected, <a href="./web/">click here</a>.</p></body></html>' >> /opt/frontend/index.html \
&& chmod -R 755 /opt/frontend \
&& \ && \
echo
# Install Websockify
ARG WEBSOCKETIFY_VERSION=0.11.0
RUN \
echo "**** Update apt database ****" \ echo "**** Update apt database ****" \
&& apt-get update \ && apt-get update \
&& \ && \
echo "**** Install nginx support ****" \ echo "**** Install Websockify dependencies ****" \
&& apt-get install -y \ && apt-get install -y \
nginx \ python3-numpy \
python3-requests \
python3-jwcrypto \
python3-redis \
&& \ && \
echo "**** Section cleanup ****" \
&& apt-get clean autoclean -y \
&& apt-get autoremove -y \
&& rm -rf \
/var/lib/apt/lists/* \
/tmp/noVNC* \
/tmp/novnc.tar.gz
# Install Websockify
ARG WEBSOCKETIFY_VERSION=0.10.0
RUN \
echo "**** Fetch Websockify ****" \ echo "**** Fetch Websockify ****" \
&& cd /tmp \ && cd /tmp \
&& wget -O /tmp/websockify.tar.gz https://github.com/novnc/websockify/archive/v${WEBSOCKETIFY_VERSION}.tar.gz \ && wget -O /tmp/websockify.tar.gz https://github.com/novnc/websockify/archive/v${WEBSOCKETIFY_VERSION}.tar.gz \
@@ -397,16 +387,15 @@ RUN \
&& cd /tmp \ && cd /tmp \
&& tar -xvf /tmp/websockify.tar.gz \ && tar -xvf /tmp/websockify.tar.gz \
&& \ && \
echo "**** Install Websockify to main ****" \ echo "**** Install Websockify to Web Frontend path ****" \
&& cd /tmp/websockify-${WEBSOCKETIFY_VERSION} \
&& python3 ./setup.py install \
&& \
echo "**** Install Websockify to noVNC path ****" \
&& cd /tmp \ && cd /tmp \
&& mv -v /tmp/websockify-${WEBSOCKETIFY_VERSION} /opt/noVNC/utils/websockify \ && mv -v /tmp/websockify-${WEBSOCKETIFY_VERSION} /opt/frontend/utils/websockify \
&& \ && \
echo "**** Section cleanup ****" \ echo "**** Section cleanup ****" \
&& apt-get clean autoclean -y \
&& apt-get autoremove -y \
&& rm -rf \ && rm -rf \
/var/lib/apt/lists/* \
/tmp/websockify-* \ /tmp/websockify-* \
/tmp/websockify.tar.gz /tmp/websockify.tar.gz

View File

@@ -15,15 +15,9 @@ function get_next_unused_port() {
# Note: Ports 32035-32248 are unallocated port ranges. We should be able to find something in here that we can use # Note: Ports 32035-32248 are unallocated port ranges. We should be able to find something in here that we can use
# REF: https://www.iana.org/assignments/service-names-port-numbers/service-names-port-numbers.xhtml?&page=130 # REF: https://www.iana.org/assignments/service-names-port-numbers/service-names-port-numbers.xhtml?&page=130
DYNAMIC_PORT_VNC=$(get_next_unused_port 32035) DYNAMIC_PORT_VNC=$(get_next_unused_port 32035)
DYNAMIC_PORT_NOVNC_SERVICE=$(get_next_unused_port ${DYNAMIC_PORT_VNC})
DYNAMIC_PORT_AUDIO_WEBSOCKET=$(get_next_unused_port ${DYNAMIC_PORT_NOVNC_SERVICE})
DYNAMIC_PORT_AUDIO_STREAM=$(get_next_unused_port ${DYNAMIC_PORT_AUDIO_WEBSOCKET})
export PORT_VNC=${PORT_VNC:-$DYNAMIC_PORT_VNC} export PORT_VNC=${PORT_VNC:-$DYNAMIC_PORT_VNC}
echo "Configure VNC service port '${PORT_VNC}'" echo "Configure VNC service port '${PORT_VNC}'"
export PORT_NOVNC_SERVICE=${PORT_NOVNC_SERVICE:-$DYNAMIC_PORT_NOVNC_SERVICE} DYNAMIC_PORT_AUDIO_STREAM=$(get_next_unused_port ${DYNAMIC_PORT_VNC})
echo "Configure noVNC service port '${PORT_NOVNC_SERVICE}'"
export PORT_AUDIO_WEBSOCKET=${PORT_AUDIO_WEBSOCKET:-$DYNAMIC_PORT_AUDIO_WEBSOCKET}
echo "Configure audio websocket port '${PORT_AUDIO_WEBSOCKET}'"
export PORT_AUDIO_STREAM=${PORT_AUDIO_STREAM:-$DYNAMIC_PORT_AUDIO_STREAM} export PORT_AUDIO_STREAM=${PORT_AUDIO_STREAM:-$DYNAMIC_PORT_AUDIO_STREAM}
echo "Configure pulseaudio encoded stream port '${PORT_AUDIO_STREAM}'" echo "Configure pulseaudio encoded stream port '${PORT_AUDIO_STREAM}'"
@@ -32,38 +26,11 @@ if ([ "${MODE}" != "s" ] && [ "${MODE}" != "secondary" ]); then
if [ "${WEB_UI_MODE:-}" = "vnc" ]; then if [ "${WEB_UI_MODE:-}" = "vnc" ]; then
echo "Enable VNC server" echo "Enable VNC server"
sed -i 's|^autostart.*=.*$|autostart=true|' /etc/supervisor.d/vnc.ini sed -i 's|^autostart.*=.*$|autostart=true|' /etc/supervisor.d/vnc.ini
# Configure Nginx proxy for the websocket and VNC
cp -f /opt/noVNC/nginx.template.conf /opt/noVNC/nginx.conf
sed -i "s|<USER>|${USER}|" /opt/noVNC/nginx.conf
sed -i "s|<PORT_NOVNC_WEB>|${PORT_NOVNC_WEB}|" /opt/noVNC/nginx.conf
sed -i "s|<PORT_NOVNC_SERVICE>|${PORT_NOVNC_SERVICE}|" /opt/noVNC/nginx.conf
sed -i "s|<PORT_AUDIO_WEBSOCKET>|${PORT_AUDIO_WEBSOCKET}|" /opt/noVNC/nginx.conf
mkdir -p /var/log/vncproxy
chown -R ${USER} /var/log/vncproxy
# TODO: Remove this... Always enable VNC audio
if [[ "${ENABLE_VNC_AUDIO}" == "true" ]]; then if [[ "${ENABLE_VNC_AUDIO}" == "true" ]]; then
# Credits for this audio patch:
# - https://github.com/novnc/noVNC/issues/302
# - https://github.com/vexingcodes/dwarf-fortress-docker
# - https://github.com/calebj/noVNC
if [ -f /opt/noVNC/audio.patch ]; then
echo "Patching noVNC with audio websocket"
# Update port specification in patch file
sed -i "s|<PORT_AUDIO_WEBSOCKET>|${PORT_AUDIO_WEBSOCKET}|" /opt/noVNC/audio.patch
# Apply patch
pushd /opt/noVNC/ &> /dev/null
patch -p1 --input=/opt/noVNC/audio.patch --batch --quiet
popd &> /dev/null
rm /opt/noVNC/audio.patch
fi
# Enable supervisord script # Enable supervisord script
sed -i 's|^autostart.*=.*$|autostart=true|' /etc/supervisor.d/vnc-audio.ini sed -i 's|^autostart.*=.*$|autostart=true|' /etc/supervisor.d/vnc-audio.ini
# Remove x11vnc from applications menu
if ! grep -q 'Hidden=true' /usr/share/applications/x11vnc.desktop; then
echo 'Hidden=true' >> /usr/share/applications/x11vnc.desktop
fi
else else
echo "Disable audio stream" echo "Disable audio stream"
echo "Disable audio websock" echo "Disable audio websock"

View File

@@ -12,17 +12,3 @@ stdout_logfile_backups=7
stderr_logfile=/home/%(ENV_USER)s/.cache/log/audiostream.err.log stderr_logfile=/home/%(ENV_USER)s/.cache/log/audiostream.err.log
stderr_logfile_maxbytes=10MB stderr_logfile_maxbytes=10MB
stderr_logfile_backups=7 stderr_logfile_backups=7
[program:audiowebsock]
priority=40
autostart=false
autorestart=true
user=%(ENV_USER)s
command=websockify %(ENV_PORT_AUDIO_WEBSOCKET)s localhost:%(ENV_PORT_AUDIO_STREAM)s
stopsignal=INT
stdout_logfile=/home/%(ENV_USER)s/.cache/log/audiowebsock.log
stdout_logfile_maxbytes=10MB
stdout_logfile_backups=7
stderr_logfile=/home/%(ENV_USER)s/.cache/log/audiowebsock.err.log
stderr_logfile_maxbytes=10MB
stderr_logfile_backups=7

View File

@@ -14,12 +14,12 @@ stderr_logfile=/home/%(ENV_USER)s/.cache/log/x11vnc.err.log
stderr_logfile_maxbytes=10MB stderr_logfile_maxbytes=10MB
stderr_logfile_backups=7 stderr_logfile_backups=7
[program:novnc] [program:frontend]
priority=30 priority=30
autostart=false autostart=false
autorestart=true autorestart=true
user=%(ENV_USER)s user=root
command=/opt/noVNC/utils/launch.sh --vnc localhost:%(ENV_PORT_VNC)s --listen %(ENV_PORT_NOVNC_SERVICE)s command=/opt/frontend/utils/run.sh --web-port %(ENV_PORT_NOVNC_WEB)s --remote-host localhost --vnc-port %(ENV_PORT_VNC)s --audio-port %(ENV_PORT_AUDIO_STREAM)s
environment=HOME="/home/%(ENV_USER)s",USER="%(ENV_USER)s" environment=HOME="/home/%(ENV_USER)s",USER="%(ENV_USER)s"
stopsignal=INT stopsignal=INT
stdout_logfile=/home/%(ENV_USER)s/.cache/log/novnc.log stdout_logfile=/home/%(ENV_USER)s/.cache/log/novnc.log
@@ -28,20 +28,3 @@ stdout_logfile_backups=7
stderr_logfile=/home/%(ENV_USER)s/.cache/log/novnc.err.log stderr_logfile=/home/%(ENV_USER)s/.cache/log/novnc.err.log
stderr_logfile_maxbytes=10MB stderr_logfile_maxbytes=10MB
stderr_logfile_backups=7 stderr_logfile_backups=7
[program:vncproxy]
priority=30
autostart=false
autorestart=true
numprocs=1
startsecs=0
user=%(ENV_USER)s
command=/usr/sbin/nginx -c /opt/noVNC/nginx.conf
environment=HOME="/home/%(ENV_USER)s",USER="%(ENV_USER)s"
stopsignal=INT
stdout_logfile=/home/%(ENV_USER)s/.cache/log/vncproxy.log
stdout_logfile_maxbytes=10MB
stdout_logfile_backups=7
stderr_logfile=/home/%(ENV_USER)s/.cache/log/vncproxy.err.log
stderr_logfile_maxbytes=10MB
stderr_logfile_backups=7

View File

@@ -1,40 +0,0 @@
daemon off;
worker_processes auto;
pid /tmp/vncproxy.pid;
error_log /home/<USER>/.cache/log/vncproxy.err.log;
events {
}
http {
server {
listen <PORT_NOVNC_WEB> default_server;
access_log /home/<USER>/.cache/log/vncproxy.log;
client_body_temp_path /tmp/client_body;
fastcgi_temp_path /tmp/fastcgi_temp;
proxy_temp_path /tmp/proxy_temp;
scgi_temp_path /tmp/scgi_temp;
uwsgi_temp_path /tmp/uwsgi_temp;
location / {
proxy_pass http://127.0.0.1:<PORT_NOVNC_SERVICE>/;
}
location /websockify {
proxy_pass http://127.0.0.1:<PORT_NOVNC_SERVICE>/;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
proxy_set_header Host $host;
}
location /audiowebsock {
proxy_pass http://127.0.0.1:<PORT_AUDIO_WEBSOCKET>/;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
proxy_set_header Host $host;
}
}
}