From 331600410a4d412616a1fda754c71e0f70d45248 Mon Sep 17 00:00:00 2001 From: vajonam <152501+vajonam@users.noreply.github.com> Date: Wed, 3 Apr 2024 08:38:36 -0400 Subject: [PATCH 01/56] feat:add virutalgl for hardware accelrated opengl --- Dockerfile | 72 +++++++++++++++++++++++++++--------------------- supervisord.conf | 21 +++++--------- 2 files changed, 48 insertions(+), 45 deletions(-) diff --git a/Dockerfile b/Dockerfile index 9d9bdf1..71efbb1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,36 +1,41 @@ -# Get and install Easy noVNC. -FROM golang:1.14-buster AS easy-novnc-build -WORKDIR /src -RUN go mod init build && \ - go get github.com/geek1011/easy-novnc@v1.1.0 && \ - go build -o /bin/easy-novnc github.com/geek1011/easy-novnc +ARG UBUNTU_VERSION=22.04 -# Get TigerVNC and Supervisor for isolating the container. -FROM debian:buster -RUN apt-get update -y && \ - apt-get install -y --no-install-recommends openbox tigervnc-standalone-server supervisor gosu && \ - rm -rf /var/lib/apt/lists && \ +FROM nvidia/opengl:1.2-glvnd-runtime-ubuntu${UBUNTU_VERSION} +LABEL authors="Joshua J. Damanik" + +ARG VIRTUALGL_VERSION=3.1 +ARG TURBOVNC_VERSION=3.1 +ENV DEBIAN_FRONTEND noninteractive + +# Install some basic dependencies +RUN apt-get update && apt-get install -y --no-install-recommends \ + wget \ + xorg \ + xauth \ + gosu supervisor x11-xserver-utils \ + libegl1-mesa \ + libgl1-mesa-glx \ + openbox \ + locales-all \ + xterm \ + novnc \ + lxde gtk2-engines-murrine gnome-themes-standard gtk2-engines-pixbuf gtk2-engines-murrine arc-theme \ + freeglut3 libgtk2.0-dev libwxgtk3.0-gtk3-dev libwx-perl libxmu-dev libgl1-mesa-glx libgl1-mesa-dri \ + xdg-utils locales locales-all pcmanfm jq curl git bzip2 firefox \ + && rm -rf /var/lib/apt/lists/*a \ mkdir -p /usr/share/desktop-directories -# Get all of the remaining dependencies for the OS, VNC, and Prusaslicer. -RUN apt-get update -y && \ - apt-get install -y --no-install-recommends lxterminal nano wget openssh-client rsync ca-certificates xdg-utils htop tar xzip gzip bzip2 zip unzip && \ - rm -rf /var/lib/apt/lists -RUN apt update && apt install -y --no-install-recommends --allow-unauthenticated \ - lxde gtk2-engines-murrine gnome-themes-standard gtk2-engines-pixbuf gtk2-engines-murrine arc-theme \ - freeglut3 libgtk2.0-dev libwxgtk3.0-gtk3-dev libwx-perl libxmu-dev libgl1-mesa-glx libgl1-mesa-dri \ - xdg-utils locales locales-all pcmanfm jq curl git firefox-esr \ - && apt autoclean -y \ - && apt autoremove -y \ - && rm -rf /var/lib/apt/lists/* +# Install virtualgl and turbovnc +RUN wget -qO /tmp/virtualgl_${VIRTUALGL_VERSION}_amd64.deb https://sourceforge.net/projects/virtualgl/files/${VIRTUALGL_VERSION}/virtualgl_${VIRTUALGL_VERSION}_amd64.deb/download \ + && wget -qO /tmp/turbovnc_${TURBOVNC_VERSION}_amd64.deb https://sourceforge.net/projects/turbovnc/files/${TURBOVNC_VERSION}/turbovnc_${TURBOVNC_VERSION}_amd64.deb/download \ + && dpkg -i /tmp/virtualgl_${VIRTUALGL_VERSION}_amd64.deb \ + && dpkg -i /tmp/turbovnc_${TURBOVNC_VERSION}_amd64.deb \ + && rm -rf /tmp/*.deb +# Install prusaslicer -# Install Prusaslicer -# Many of the commands below were derived and pulled from previous work by dmagyar on GitHub. -# Here's their Dockerfile for reference https://github.com/dmagyar/prusaslicer-vnc-docker/blob/main/Dockerfile.amd64 WORKDIR /slic3r ADD get_latest_prusaslicer_release.sh /slic3r - RUN chmod +x /slic3r/get_latest_prusaslicer_release.sh \ && latestSlic3r=$(/slic3r/get_latest_prusaslicer_release.sh url) \ && slic3rReleaseName=$(/slic3r/get_latest_prusaslicer_release.sh name) \ @@ -52,12 +57,16 @@ RUN chmod +x /slic3r/get_latest_prusaslicer_release.sh \ && mkdir -p /configs/.config/ \ && ln -s /configs/.config/ /home/slic3r/ \ && mkdir -p /home/slic3r/.config/ \ - # We can now set the Download directory for Firefox and other browsers. - # We can also add /prints/ to the file explorer bookmarks for easy access. && echo "XDG_DOWNLOAD_DIR=\"/prints/\"" >> /home/slic3r/.config/user-dirs.dirs \ && echo "file:///prints prints" >> /home/slic3r/.gtk-bookmarks -COPY --from=easy-novnc-build /bin/easy-novnc /usr/local/bin/ + +# Generate key for novnc +RUN openssl req -x509 -nodes -newkey rsa:2048 -keyout /etc/novnc.pem -out /etc/novnc.pem -days 365 -subj "/C=US/ST=Denial/L=Springfield/O=Dis/CN=localhost" + +ENV PATH ${PATH}:/opt/VirtualGL/bin:/opt/TurboVNC/bin + +COPY entrypoint.sh /entrypoint.sh COPY menu.xml /etc/xdg/openbox/ COPY supervisord.conf /etc/ @@ -70,5 +79,6 @@ EXPOSE 5900 VOLUME /configs/ VOLUME /prints/ -# It's time! Let's get to work! We use /configs/ as a bindable volume for Prusaslicers configurations. We use /prints/ to provide a location for STLs and GCODE files. -CMD ["bash", "-c", "chown -R slic3r:slic3r /home/slic3r/ /configs/ /prints/ /dev/stdout && exec gosu slic3r supervisord"] \ No newline at end of file +ENTRYPOINT ["/entrypoint.sh"] +CMD ["bash", "-c", "chown -R slic3r:slic3r /home/slic3r/ /configs/ /prints/ /dev/stdout && exec gosu slic3r supervisord"] +# CMD ["/bin/bash"] diff --git a/supervisord.conf b/supervisord.conf index 5aa188c..a4fba64 100644 --- a/supervisord.conf +++ b/supervisord.conf @@ -2,28 +2,21 @@ nodaemon=true pidfile=/tmp/supervisord.pid -[program:x11] +[program:vnc] priority=0 -command=/usr/bin/Xtigervnc -desktop "Prusaslicer" -rfbport 5900 -SecurityTypes None -AlwaysShared -AcceptKeyEvents -AcceptPointerEvents -AcceptSetDesktopSize -SendCutText -AcceptCutText :0 +command=/opt/TurboVNC/bin/vncserver :1 -fg -securitytypes TLSNone,X509None,None -depth 24 -geometry 1920x1080 autorestart=true redirect_stderr=true -[program:easy-novnc] +[program:novnc] priority=0 -command=/usr/local/bin/easy-novnc --addr :8080 --host localhost --port 5900 --no-url-password --novnc-params "resize=remote" -autorestart=true -redirect_stderr=true - -[program:openbox] -priority=1 -command=/usr/bin/openbox -environment=DISPLAY=:0 +command=websockify --web=/usr/share/novnc/ 8080 localhost:5901 autorestart=true redirect_stderr=true [program:prusaslicer] priority=1 -environment=DISPLAY=:0 -command=/bin/bash -c '/slic3r/slic3r-dist/prusa-slicer --datadir /configs/.config/PrusaSlicer/' +environment=DISPLAY=:1 +command=/bin/bash -c 'vglrun /slic3r/slic3r-dist/prusa-slicer --datadir /configs/.config/PrusaSlicer/' autorestart=true -redirect_stderr=true \ No newline at end of file +redirect_stderr=true From 7601bf2e51325b5faf864400a068e05124ced98f Mon Sep 17 00:00:00 2001 From: vajonam <152501+vajonam@users.noreply.github.com> Date: Wed, 3 Apr 2024 08:59:41 -0400 Subject: [PATCH 02/56] fix: typo and add docker-compose Signed-off-by: vajonam <152501+vajonam@users.noreply.github.com> --- Dockerfile | 5 +++-- docker-compose.yml | 11 ++++++----- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/Dockerfile b/Dockerfile index 71efbb1..d957950 100644 --- a/Dockerfile +++ b/Dockerfile @@ -22,7 +22,9 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ lxde gtk2-engines-murrine gnome-themes-standard gtk2-engines-pixbuf gtk2-engines-murrine arc-theme \ freeglut3 libgtk2.0-dev libwxgtk3.0-gtk3-dev libwx-perl libxmu-dev libgl1-mesa-glx libgl1-mesa-dri \ xdg-utils locales locales-all pcmanfm jq curl git bzip2 firefox \ - && rm -rf /var/lib/apt/lists/*a \ + && apt autoclean -y \ + && apt autoremove -y \ + && rm -rf /var/lib/apt/lists/* \ mkdir -p /usr/share/desktop-directories @@ -81,4 +83,3 @@ VOLUME /prints/ ENTRYPOINT ["/entrypoint.sh"] CMD ["bash", "-c", "chown -R slic3r:slic3r /home/slic3r/ /configs/ /prints/ /dev/stdout && exec gosu slic3r supervisord"] -# CMD ["/bin/bash"] diff --git a/docker-compose.yml b/docker-compose.yml index 01c14ca..e15e191 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -5,12 +5,13 @@ services: image: mikeah/prusaslicer-novnc container_name: prusaslicer-novnc environment: - - SSL_CERT_FILE="/etc/ssl/certs/ca-certificates.crt" - #- NVIDIA_DRIVER_CAPABILITIES="all" - #- NVIDIA_VISIBLE_DEVICES="all" + - SSL_CERT_FILE=/etc/ssl/certs/ca-certificates.crt + - NVIDIA_VISIBLE_DEVICES=0 + - NVIDIA_DRIVER_CAPABILITIES=all + - DISPLAY=:1 + - VNC_RESOLUTION=1900x1080 volumes: - ./prints:/prints/ - ./data:/configs/ - ports: - - 8080:8080 + network_mode: host restart: unless-stopped From 34dc5d38189981c491e5f4621c724a89189823b7 Mon Sep 17 00:00:00 2001 From: vajonam <152501+vajonam@users.noreply.github.com> Date: Wed, 3 Apr 2024 09:12:07 -0400 Subject: [PATCH 03/56] fix: more typos Signed-off-by: vajonam <152501+vajonam@users.noreply.github.com> --- Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index d957950..0712d11 100644 --- a/Dockerfile +++ b/Dockerfile @@ -21,11 +21,11 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ novnc \ lxde gtk2-engines-murrine gnome-themes-standard gtk2-engines-pixbuf gtk2-engines-murrine arc-theme \ freeglut3 libgtk2.0-dev libwxgtk3.0-gtk3-dev libwx-perl libxmu-dev libgl1-mesa-glx libgl1-mesa-dri \ - xdg-utils locales locales-all pcmanfm jq curl git bzip2 firefox \ + xdg-utils locales locales-all pcmanfm jq curl git bzip2 \ && apt autoclean -y \ && apt autoremove -y \ && rm -rf /var/lib/apt/lists/* \ - mkdir -p /usr/share/desktop-directories + && mkdir -p /usr/share/desktop-directories # Install virtualgl and turbovnc From e462e22c62079400321f0b3492abfefc4aef4e46 Mon Sep 17 00:00:00 2001 From: vajonam <152501+vajonam@users.noreply.github.com> Date: Wed, 3 Apr 2024 09:27:07 -0400 Subject: [PATCH 04/56] fix: convert all environment variables to supervosord Signed-off-by: vajonam <152501+vajonam@users.noreply.github.com> --- entrypoint.sh | 20 ++++++++++++++++++++ supervisord.conf | 6 +++--- 2 files changed, 23 insertions(+), 3 deletions(-) create mode 100755 entrypoint.sh diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100755 index 0000000..a505961 --- /dev/null +++ b/entrypoint.sh @@ -0,0 +1,20 @@ +#!/bin/bash -x +set -e +rm -f /tmp/.X*-lock +rm -f /tmp/.X11-unix/X* +DISPLAY=${DISPLAY:-:10} +DISPLAY_NUMBER=$(echo $DISPLAY | cut -d: -f2) +export NOVNC_PORT=${NOVNC_PORT:-8080} +VNC_RESOLUTION=${VNC_RESOLUTION:-1280x800} +if [ -n "$VNC_PASSWORD" ]; then + mkdir -p /root/.vnc + echo "$VNC_PASSWORD" | vncpasswd -f > /root/.vnc/passwd + chmod 0600 /root/.vnc/passwd +fi +# vncserver "$DISPLAY" -securitytypes TLSNone,X509None,None -depth 24 -geometry "$VNC_RESOLUTION" +# websockify -D --web=/usr/share/novnc/ "$NOVNC_PORT" localhost:$((5900 + DISPLAY_NUMBER)) +# echo "NoVNC server started on port $NOVNC_PORT" +# EXEC=$@ +# exec "$@" +export VGLRUN=vglrun +chown -R slic3r:slic3r /home/slic3r/ /configs/ /prints/ /dev/stdout && exec gosu slic3r supervisord # -e TRACE diff --git a/supervisord.conf b/supervisord.conf index a4fba64..b5ac496 100644 --- a/supervisord.conf +++ b/supervisord.conf @@ -4,19 +4,19 @@ pidfile=/tmp/supervisord.pid [program:vnc] priority=0 -command=/opt/TurboVNC/bin/vncserver :1 -fg -securitytypes TLSNone,X509None,None -depth 24 -geometry 1920x1080 +command=/opt/TurboVNC/bin/vncserver %(ENV_DISPLAY)s -fg -securitytypes TLSNone,X509None,None -depth 24 -geometry %(ENV_VNC_RESOLUTION)s autorestart=true redirect_stderr=true [program:novnc] priority=0 -command=websockify --web=/usr/share/novnc/ 8080 localhost:5901 +command=websockify --web=/usr/share/novnc/ %(ENV_NOVNC_PORT)s localhost:5901 autorestart=true redirect_stderr=true [program:prusaslicer] priority=1 environment=DISPLAY=:1 -command=/bin/bash -c 'vglrun /slic3r/slic3r-dist/prusa-slicer --datadir /configs/.config/PrusaSlicer/' +command=/bin/bash -c '%(ENV_VGLRUN)s /slic3r/slic3r-dist/prusa-slicer --datadir /configs/.config/PrusaSlicer/' autorestart=true redirect_stderr=true From e0cf9a48184b561640b66cc774fb4269e1e77378 Mon Sep 17 00:00:00 2001 From: vajonam <152501+vajonam@users.noreply.github.com> Date: Wed, 3 Apr 2024 09:28:21 -0400 Subject: [PATCH 05/56] fix: last remaining poperty Signed-off-by: vajonam <152501+vajonam@users.noreply.github.com> --- supervisord.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/supervisord.conf b/supervisord.conf index b5ac496..498fbd5 100644 --- a/supervisord.conf +++ b/supervisord.conf @@ -16,7 +16,7 @@ redirect_stderr=true [program:prusaslicer] priority=1 -environment=DISPLAY=:1 +environment=DISPLAY=%(ENV_DISPLAY)s command=/bin/bash -c '%(ENV_VGLRUN)s /slic3r/slic3r-dist/prusa-slicer --datadir /configs/.config/PrusaSlicer/' autorestart=true redirect_stderr=true From 6653680cd7f6e70c94cecad48a7f089a482c3144 Mon Sep 17 00:00:00 2001 From: vajonam <152501+vajonam@users.noreply.github.com> Date: Wed, 3 Apr 2024 09:30:59 -0400 Subject: [PATCH 06/56] fix: few more vars Signed-off-by: vajonam <152501+vajonam@users.noreply.github.com> --- entrypoint.sh | 1 + supervisord.conf | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/entrypoint.sh b/entrypoint.sh index a505961..4c70052 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -16,5 +16,6 @@ fi # echo "NoVNC server started on port $NOVNC_PORT" # EXEC=$@ # exec "$@" +export LOCALFBPORT=$((5900 + DISPLAY_NUMBER)) export VGLRUN=vglrun chown -R slic3r:slic3r /home/slic3r/ /configs/ /prints/ /dev/stdout && exec gosu slic3r supervisord # -e TRACE diff --git a/supervisord.conf b/supervisord.conf index 498fbd5..1695d56 100644 --- a/supervisord.conf +++ b/supervisord.conf @@ -10,7 +10,7 @@ redirect_stderr=true [program:novnc] priority=0 -command=websockify --web=/usr/share/novnc/ %(ENV_NOVNC_PORT)s localhost:5901 +command=websockify --web=/usr/share/novnc/ %(ENV_NOVNC_PORT)s localhost:%(ENV_LOCALFBPORT)s autorestart=true redirect_stderr=true From 7fde29ba73653d875b97779b806d5bbdc6746eb7 Mon Sep 17 00:00:00 2001 From: vajonam <152501+vajonam@users.noreply.github.com> Date: Wed, 3 Apr 2024 09:36:34 -0400 Subject: [PATCH 07/56] fix: add support for no security and full password sec. Signed-off-by: vajonam <152501+vajonam@users.noreply.github.com> --- entrypoint.sh | 8 +++----- supervisord.conf | 2 +- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/entrypoint.sh b/entrypoint.sh index 4c70052..1625315 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -10,12 +10,10 @@ if [ -n "$VNC_PASSWORD" ]; then mkdir -p /root/.vnc echo "$VNC_PASSWORD" | vncpasswd -f > /root/.vnc/passwd chmod 0600 /root/.vnc/passwd + export VNC_SEC= +else + export VNC_SEC="-securitytypes TLSNone,X509None,None" fi -# vncserver "$DISPLAY" -securitytypes TLSNone,X509None,None -depth 24 -geometry "$VNC_RESOLUTION" -# websockify -D --web=/usr/share/novnc/ "$NOVNC_PORT" localhost:$((5900 + DISPLAY_NUMBER)) -# echo "NoVNC server started on port $NOVNC_PORT" -# EXEC=$@ -# exec "$@" export LOCALFBPORT=$((5900 + DISPLAY_NUMBER)) export VGLRUN=vglrun chown -R slic3r:slic3r /home/slic3r/ /configs/ /prints/ /dev/stdout && exec gosu slic3r supervisord # -e TRACE diff --git a/supervisord.conf b/supervisord.conf index 1695d56..1193783 100644 --- a/supervisord.conf +++ b/supervisord.conf @@ -4,7 +4,7 @@ pidfile=/tmp/supervisord.pid [program:vnc] priority=0 -command=/opt/TurboVNC/bin/vncserver %(ENV_DISPLAY)s -fg -securitytypes TLSNone,X509None,None -depth 24 -geometry %(ENV_VNC_RESOLUTION)s +command=/opt/TurboVNC/bin/vncserver %(ENV_DISPLAY)s -fg %(ENV_VNC_SEC)s -depth 24 -geometry %(ENV_VNC_RESOLUTION)s autorestart=true redirect_stderr=true From f1011cba681c4e0f96cad2b1f18eacea20fcfae3 Mon Sep 17 00:00:00 2001 From: vajonam <152501+vajonam@users.noreply.github.com> Date: Wed, 3 Apr 2024 09:39:49 -0400 Subject: [PATCH 08/56] fix: remove ports an some comments. Signed-off-by: vajonam <152501+vajonam@users.noreply.github.com> --- Dockerfile | 11 ++++++----- entrypoint.sh | 4 +++- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/Dockerfile b/Dockerfile index 0712d11..b60b698 100644 --- a/Dockerfile +++ b/Dockerfile @@ -72,14 +72,15 @@ COPY entrypoint.sh /entrypoint.sh COPY menu.xml /etc/xdg/openbox/ COPY supervisord.conf /etc/ -# HTTP Port -EXPOSE 8080 -# VNC Port -EXPOSE 5900 +# Needs to be ran with HOST networking so this are no longer needed. +# # HTTP Port +# EXPOSE 8080 + +# # VNC Port +# EXPOSE 5900 VOLUME /configs/ VOLUME /prints/ ENTRYPOINT ["/entrypoint.sh"] -CMD ["bash", "-c", "chown -R slic3r:slic3r /home/slic3r/ /configs/ /prints/ /dev/stdout && exec gosu slic3r supervisord"] diff --git a/entrypoint.sh b/entrypoint.sh index 1625315..9d38154 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -15,5 +15,7 @@ else export VNC_SEC="-securitytypes TLSNone,X509None,None" fi export LOCALFBPORT=$((5900 + DISPLAY_NUMBER)) -export VGLRUN=vglrun +export VGLRUN=/usr/bin/vglrun + +# fix perms and launch supervisor with the above environment variables chown -R slic3r:slic3r /home/slic3r/ /configs/ /prints/ /dev/stdout && exec gosu slic3r supervisord # -e TRACE From c9162328b6c2f3a0210343192413f13fef959705 Mon Sep 17 00:00:00 2001 From: vajonam <152501+vajonam@users.noreply.github.com> Date: Wed, 3 Apr 2024 09:47:44 -0400 Subject: [PATCH 09/56] fix: forgot menu to be launched with vglrun Signed-off-by: vajonam <152501+vajonam@users.noreply.github.com> --- menu.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/menu.xml b/menu.xml index 644d9d2..4f30f66 100644 --- a/menu.xml +++ b/menu.xml @@ -3,7 +3,7 @@