Prechádzať zdrojové kódy

[MAJOR] Integrate WebRTC HTML5 interface and include other large updates

Collaboration with @danisla
ehfd 4 rokov pred
rodič
commit
952ff0c8ca

+ 49 - 0
.github/workflows/container-publish.yml

@@ -0,0 +1,49 @@
+on:
+  push:
+    branches: [ main ]
+  pull_request:
+    branches: [ main ]
+env:
+  REGISTRY: ghcr.io
+  IMAGE_NAME: ehfd/nvidia-glx-desktop
+jobs:
+  build:
+    runs-on: ubuntu-latest
+    permissions:
+      contents: read
+      packages: write
+    steps:
+    - name: Checkout repository
+      uses: actions/checkout@v2
+    - name: Log into registry ${{ env.REGISTRY }}
+      if: github.event_name != 'pull_request'
+      uses: docker/login-action@v1
+      with:
+        registry: ${{ env.REGISTRY }}
+        username: ${{ github.actor }}
+        password: ${{ secrets.GITHUB_TOKEN }}
+    - name: Extract Docker metadata
+      id: meta
+      uses: docker/metadata-action@v3
+      with:
+        images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
+    - name: Build and push Ubuntu 20.04 Docker image
+      uses: docker/build-push-action@v2
+      with:
+        build-args:
+        - UBUNTU_RELEASE=20.04
+        context: .
+        push: ${{ github.event_name != 'pull_request' }}
+        tags:
+        - ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
+        - ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:20.04
+        labels: ${{ steps.meta.outputs.labels }}
+    - name: Build and push Ubuntu 18.04 Docker image
+      uses: docker/build-push-action@v2
+      with:
+        build-args:
+        - UBUNTU_RELEASE=18.04
+        context: .
+        push: ${{ github.event_name != 'pull_request' }}
+        tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:18.04
+        labels: ${{ steps.meta.outputs.labels }}

+ 0 - 37
.github/workflows/docker-publish.yml

@@ -1,37 +0,0 @@
-name: Docker
-on:
-  push:
-    branches: [ main ]
-  pull_request:
-    branches: [ main ]
-env:
-  REGISTRY: ghcr.io
-  IMAGE_NAME: ehfd/nvidia-glx-desktop
-jobs:
-  build:
-    runs-on: ubuntu-latest
-    permissions:
-      contents: read
-      packages: write
-    steps:
-      - name: Checkout repository
-        uses: actions/checkout@v2
-      - name: Log into registry ${{ env.REGISTRY }}
-        if: github.event_name != 'pull_request'
-        uses: docker/login-action@28218f9b04b4f3f62068d7b6ce6ca5b26e35336c
-        with:
-          registry: ${{ env.REGISTRY }}
-          username: ${{ github.actor }}
-          password: ${{ secrets.GITHUB_TOKEN }}
-      - name: Extract Docker metadata
-        id: meta
-        uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
-        with:
-          images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
-      - name: Build and push Docker image
-        uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
-        with:
-          context: .
-          push: ${{ github.event_name != 'pull_request' }}
-          tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
-          labels: ${{ steps.meta.outputs.labels }}

+ 107 - 67
Dockerfile

@@ -1,36 +1,44 @@
-FROM nvidia/opengl:1.2-glvnd-runtime-ubuntu20.04
-# Comment the line above and uncomment the line below for Ubuntu 18.04
-#FROM nvidia/opengl:1.2-glvnd-runtime-ubuntu18.04
+# Ubuntu release versions 18.04 and 20.04 are supported
+ARG UBUNTU_RELEASE=20.04
+FROM nvcr.io/nvidia/cudagl:11.0.3-runtime-ubuntu${UBUNTU_RELEASE}
 
-LABEL maintainer "https://github.com/ehfd"
+LABEL maintainer "https://github.com/ehfd,https://github.com/danisla"
 
+ARG UBUNTU_RELEASE
 # Make all NVIDIA GPUs visible, but we want to manually install drivers
 ARG NVIDIA_VISIBLE_DEVICES=all
 # Supress interactive menu while installing keyboard-configuration
 ARG DEBIAN_FRONTEND=noninteractive
 ENV NVIDIA_DRIVER_CAPABILITIES all
+ENV PULSE_SERVER 127.0.0.1:4713
 
-# Default options (password is "mypasswd")
+# Default environment variables (password is "mypasswd")
 ENV TZ UTC
-ENV PASSWD mypasswd
 ENV SIZEW 1920
 ENV SIZEH 1080
+ENV REFRESH 60
+ENV DPI 96
 ENV CDEPTH 24
 ENV VIDEO_PORT DFP
+ENV PASSWD mypasswd
+ENV NOVNC_ENABLE false
+ENV WEBRTC_ENCODER nvh264enc
+ENV WEBRTC_ENABLE_RESIZE false
+ENV ENABLE_AUDIO true
+ENV ENABLE_BASIC_AUTH true
 
 # Install locales to prevent errors
 RUN apt-get clean && \
-    apt-get update && \
-    apt-get install -y --no-install-recommends locales && \
+    apt-get update && apt-get install --no-install-recommends -y locales && \
     rm -rf /var/lib/apt/lists/* && \
     locale-gen en_US.UTF-8
 ENV LANG en_US.UTF-8
 ENV LANGUAGE en_US:en
 ENV LC_ALL en_US.UTF-8
 
-# Install Xorg, MATE desktop, and others
+# Install Xorg, MATE Desktop, and others
 RUN dpkg --add-architecture i386 && \
-    apt-get update && apt-get install -y \
+    apt-get update && apt-get install --no-install-recommends -y \
         software-properties-common \
         apt-utils \
         build-essential \
@@ -63,6 +71,7 @@ RUN dpkg --add-architecture i386 && \
         libglvnd-dev \
         pkg-config \
         mesa-utils \
+        mesa-utils-extra \
         libglu1 \
         libglu1:i386 \
         libsm6 \
@@ -80,95 +89,126 @@ RUN dpkg --add-architecture i386 && \
         xfonts-base \
         xkb-data \
         libxrandr-dev \
-        xorg-dev \
-        ubuntu-mate-desktop && \
-    if [ "$(grep VERSION_CODENAME= /etc/os-release | cut -d= -f2)" = "bionic" ]; then apt-get install -y --no-install-recommends vulkan-utils; else apt-get install -y --no-install-recommends vulkan-tools; fi && \
+        xorg-dev && \
+    apt-get install -y ubuntu-mate-desktop && \
+    if [ "${UBUNTU_RELEASE}" = "18.04" ]; then apt-get install --no-install-recommends -y vulkan-utils; else apt-get install --no-install-recommends -y vulkan-tools; fi && \
     # Remove Bluetooth packages that throw errors
-    apt-get autoremove --purge -y blueman bluez bluez-cups pulseaudio-module-bluetooth && \
+    apt-get autoremove --purge -y \
+        blueman \
+        pulseaudio-module-bluetooth && \
     rm -rf /var/lib/apt/lists/*
 
-# Wine and Winetricks, comment out the below lines to disable
-ARG WINE_BRANCH=stable
-RUN if [ "$(grep VERSION_CODENAME= /etc/os-release | cut -d= -f2)" = "bionic" ]; then add-apt-repository ppa:cybermax-dexter/sdl2-backport; fi && \
+# Wine, Winetricks, and PlayOnLinux, comment out the below lines to disable
+ARG WINE_BRANCH=devel
+RUN if [ "${UBUNTU_RELEASE}" = "18.04" ]; then add-apt-repository ppa:cybermax-dexter/sdl2-backport; fi && \
     curl -fsSL https://dl.winehq.org/wine-builds/winehq.key | APT_KEY_DONT_WARN_ON_DANGEROUS_USAGE=1 apt-key add - && \
     apt-add-repository "deb https://dl.winehq.org/wine-builds/ubuntu/ $(grep VERSION_CODENAME= /etc/os-release | cut -d= -f2) main" && \
-    apt-get update && apt-get install -y --install-recommends winehq-${WINE_BRANCH} && \
+    apt-get update && apt-get install -y \
+        winehq-${WINE_BRANCH} \
+        q4wine \
+        playonlinux && \
     rm -rf /var/lib/apt/lists/* && \
     curl -fsSL -o /usr/bin/winetricks https://raw.githubusercontent.com/Winetricks/winetricks/master/src/winetricks && \
     chmod 755 /usr/bin/winetricks && \
     curl -fsSL -o /usr/share/bash-completion/completions/winetricks https://raw.githubusercontent.com/Winetricks/winetricks/master/src/winetricks.bash-completion
 
-# Apache Guacamole and x11vnc
-ENV TOMCAT_VERSION 9.0.50
-RUN apt-get update && apt-get install -y --no-install-recommends \
-    libcairo2-dev \
-    libjpeg-turbo8-dev \
-    libpng-dev \
-    libtool-bin \
-    libossp-uuid-dev \
-    libavcodec-dev \
-    libavformat-dev \
-    libavutil-dev \
-    libswscale-dev \
-    freerdp2-dev \
-    libpango1.0-dev \
-    libssh2-1-dev \
-    libtelnet-dev \
-    libvncserver-dev \
-    libwebsockets-dev \
-    libpulse-dev \
-    libssl-dev \
-    libvorbis-dev \
-    libwebp-dev \
-    autoconf \
-    automake \
-    autotools-dev \
-    pulseaudio \
-    pavucontrol \
-    openssh-server \
-    openssh-sftp-server \
-    default-jdk \
-    maven \
-    libxdamage-dev \
-    libxinerama-dev \
-    libxrandr-dev \
-    libxss-dev \
-    libxtst-dev \
-    libv4l-dev \
-    libavahi-client-dev \
-    chrpath \
-    debhelper && \
+# Install latest selkies-gstreamer (https://github.com/selkies-project/selkies-gstreamer) build, Python application, and web application
+RUN apt-get update && apt-get install --no-install-recommends -y \
+        build-essential \
+        python3-pip \
+        python3-dev \
+        python3-gi \
+        python3-setuptools \
+        python3-wheel \
+        tzdata \
+        sudo \
+        udev \
+        xclip \
+        x11-utils \
+        xdotool \
+        wmctrl \
+        jq \
+        gdebi-core \
+        x11-xserver-utils \
+        xserver-xorg-core \
+        libopus0 \
+        libgdk-pixbuf2.0-0 \
+        libsrtp2-1 \
+        libxdamage1 \
+        libxml2-dev \
+        libwebrtc-audio-processing1 \
+        libcairo-gobject2 \
+        pulseaudio \
+        libpulse0 \
+        libpangocairo-1.0-0 \
+        libgirepository1.0-dev && \
+    rm -rf /var/lib/apt/lists/* && \
+    cd /opt && \
+    SELKIES_VERSION=$(curl -fsSL "https://api.github.com/repos/selkies-project/selkies-gstreamer/releases/latest" | jq -r '.tag_name' | sed 's/[^0-9\.\-]*//g') && \
+    curl -fsSL "https://github.com/selkies-project/selkies-gstreamer/releases/download/v${SELKIES_VERSION}/selkies-gstreamer-v${SELKIES_VERSION}-ubuntu${UBUNTU_RELEASE}.tgz" | tar -zxf - && \
+    curl -O -fsSL "https://github.com/selkies-project/selkies-gstreamer/releases/download/v${SELKIES_VERSION}/selkies_gstreamer-${SELKIES_VERSION}-py3-none-any.whl" && pip3 install "selkies_gstreamer-${SELKIES_VERSION}-py3-none-any.whl" && rm -f "selkies_gstreamer-${SELKIES_VERSION}-py3-none-any.whl" && \
+    curl -fsSL "https://github.com/selkies-project/selkies-gstreamer/releases/download/v${SELKIES_VERSION}/selkies-gstreamer-web-v${SELKIES_VERSION}.tgz" | tar -zxf - && \
+    cd /usr/local/cuda/lib64 && sudo find . -maxdepth 1 -type l -name "*libnvrtc.so.*" -exec sh -c 'ln -sf $(basename {}) libnvrtc.so' \;
+
+# Install latest noVNC web interface for fallback
+RUN apt-get update && apt-get install --no-install-recommends -y \
+        autoconf \
+        automake \
+        autotools-dev \
+        chrpath \
+        debhelper \
+        jq \
+        python \
+        python-numpy \
+        python3 \
+        python3-numpy \
+        libc6-dev \
+        libcairo2-dev \
+        libjpeg-turbo8-dev \
+        libssl-dev \
+        libv4l-dev \
+        libvncserver-dev \
+        libtool-bin \
+        libxdamage-dev \
+        libxinerama-dev \
+        libxrandr-dev \
+        libxss-dev \
+        libxtst-dev \
+        libavahi-client-dev && \
     rm -rf /var/lib/apt/lists/* && \
     git clone https://github.com/LibVNC/x11vnc.git /tmp/x11vnc && \
     cd /tmp/x11vnc && autoreconf -fi && ./configure && make install && cd / && rm -rf /tmp/* && \
-    curl -fsSL https://archive.apache.org/dist/tomcat/tomcat-$(echo $TOMCAT_VERSION | cut -d "." -f 1)/v${TOMCAT_VERSION}/bin/apache-tomcat-${TOMCAT_VERSION}.tar.gz | tar -xzf - -C /opt && \
-    mv /opt/apache-tomcat-$TOMCAT_VERSION /opt/tomcat && \
-    git clone https://github.com/apache/guacamole-server.git /tmp/guacamole-server && \
-    cd /tmp/guacamole-server && autoreconf -fi && ./configure --with-init-dir=/etc/init.d && make install && ldconfig && cd / && rm -rf /tmp/* && \
-    git clone https://github.com/apache/guacamole-client.git /tmp/guacamole-client && \
-    cd /tmp/guacamole-client && JAVA_HOME=/usr/lib/jvm/default-java mvn package && rm -rf /opt/tomcat/webapps/* && mv guacamole/target/guacamole*.war /opt/tomcat/webapps/ROOT.war && chmod +x /opt/tomcat/webapps/ROOT.war && cd / && rm -rf /tmp/* && \
-    echo "load-module module-native-protocol-tcp auth-ip-acl=127.0.0.0/8 auth-anonymous=1" >> /etc/pulse/default.pa
+    NOVNC_VERSION=$(curl -fsSL "https://api.github.com/repos/noVNC/noVNC/releases/latest" | jq -r '.tag_name' | sed 's/[^0-9\.\-]*//g') && \
+    curl -fsSL https://github.com/novnc/noVNC/archive/v${NOVNC_VERSION}.tar.gz | tar -xzf - -C /opt && \
+    mv /opt/noVNC-${NOVNC_VERSION} /opt/noVNC && \
+    ln -s /opt/noVNC/vnc.html /opt/noVNC/index.html && \
+    git clone https://github.com/novnc/websockify /opt/noVNC/utils/websockify
+
+# Add custom packages below this comment
 
 # Create user with password ${PASSWD}
-RUN apt-get update && apt-get install -y --no-install-recommends \
+RUN apt-get update && apt-get install --no-install-recommends -y \
         sudo && \
     rm -rf /var/lib/apt/lists/* && \
     groupadd -g 1000 user && \
     useradd -ms /bin/bash user -u 1000 -g 1000 && \
     usermod -a -G adm,audio,cdrom,dialout,dip,fax,floppy,input,lp,lpadmin,netdev,plugdev,scanner,ssh,sudo,tape,tty,video,voice user && \
     echo "user ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers && \
-    chown -R user:user /home/user /opt/tomcat && \
+    chown -R user:user /home/user && \
     echo "user:${PASSWD}" | chpasswd && \
     ln -snf "/usr/share/zoneinfo/$TZ" /etc/localtime && echo "$TZ" > /etc/timezone
 
 COPY entrypoint.sh /etc/entrypoint.sh
 RUN chmod 755 /etc/entrypoint.sh
+COPY selkies-gstreamer-entrypoint.sh /etc/selkies-gstreamer-entrypoint.sh
+RUN chmod 755 /etc/selkies-gstreamer-entrypoint.sh
 COPY supervisord.conf /etc/supervisord.conf
 RUN chmod 755 /etc/supervisord.conf
 
 EXPOSE 8080
 
 USER user
+ENV USER=user
 WORKDIR /home/user
 
 ENTRYPOINT ["/usr/bin/supervisord"]

+ 118 - 12
README.md

@@ -1,29 +1,135 @@
 # docker-nvidia-glx-desktop
 
-MATE Desktop container supporting GLX/Vulkan for NVIDIA GPUs by spawning its own X Server and Guacamole interface instead of using the host X server. Does not require `/tmp/.X11-unix` host sockets or host configuration. Designed for Kubernetes, also supporting audio forwarding.
+MATE Desktop container designed for Kubernetes supporting OpenGL GLX and Vulkan for NVIDIA GPUs with WebRTC and HTML5, providing an open source remote cloud graphics or game streaming platform. Spawns its own fully isolated X Server instead of using the host X server, therefore not requiring `/tmp/.X11-unix` host sockets or host configuration.
 
-Use [docker-nvidia-egl-desktop](https://github.com/ehfd/docker-nvidia-egl-desktop) for a MATE Desktop container that directly accesses NVIDIA GPUs without using an X11 Server (but without Vulkan support unlike this container).
+Use [docker-nvidia-egl-desktop](https://github.com/ehfd/docker-nvidia-egl-desktop) for a MATE Desktop container which directly accesses NVIDIA GPUs without using an X11 Server and supports automatically falling back to software acceleration in the absence of GPUs (but without Vulkan support unlike this container).
 
-Requires reasonably recent NVIDIA GPU drivers and corresponding container toolkits to be set up on the host for allocating GPUs. GPUs should have one or more DVI-D/HDMI/DisplayPort digital video ports instead of having only analog video ports (but this only excludes very ancient GPUs). However, the ports to be used are recommended NOT to be connected with an actual monitor, unless the user wants the remote desktop screen to be shown in the monitor. If you need to connect a real monitor to the X server session spawned by the container, connect the monitor and set **VIDEO_PORT** to the the video port identifier that is connected to the monitor. Manually specify a video port identifier that is not connected to a monitor in **VIDEO_PORT** if you do not want this. **VIDEO_PORT** identifiers and their connection states can be obtained by typing `xrandr -q` when the `$DISPLAY` environment variable is set to the spawned X server display number (for example :0). **Do not start two or more X servers for a single GPU. Use a separate GPU (or use Xvfb/Xdummy/XVnc without hardware acceleration to not use any at all) if you need a host X server, and do not make the GPU available to the containers.**
+### Usage
 
-Since this container fakes the driver to simulate being plugged in to a monitor while it actually does not, make sure the resolutions specified with the environment variables **SIZEW** and **SIZEH** are within the maximum size supported by the GPU. The environment variable **VIDEO_PORT** can override which video port is used (defaults to DFP, the first port detected in the driver). Therefore, overriding **VIDEO_PORT** to an unplugged DisplayPort (for example numbered like DP-0, DP-1, and so on) is recommended for resolutions above 1920 x 1200 at 60 hz, because some driver restrictions are applied when the default is set to an unplugged DVI-D or HDMI port. The maximum size that should work in all cases is 1920 x 1200 at 60 hz, mainly for when the default **VIDEO_PORT** identifier DFP is not set to DisplayPort. The screen sizes between 1920 x 1200 at 60 hz and the maximum supported display size for each port supported by GPU specifications will be possible if the port is set to DisplayPort (connected or disconnected), or when a real monitor or dummy plug to any other type of display ports (including DVI-D and HDMI) has been connected. If all GPUs in the cluster have at least one DisplayPort and they are not connected to any monitors, simply setting **VIDEO_PORT** to DP-0 is recommended (but this is not set as default because of legacy GPU compatibility reasons).
+Container startup could take some time at first launch as it automatically installs NVIDIA drivers compatible with the host.
 
-The Quadro M4000 (Maxwell) was the earliest non-datacenter GPU with physical video ports to be tested. GPUs of generations at least Maxwell or after are likely confirmed to work, perhaps even earlier ones as long as a supported driver is installed.
+Wine, Winetricks, and PlayOnLinux are bundled by default. Comment out the section where it is installed within `Dockerfile` if the user wants to remove them from the container.
 
-Datacenter GPUs (Tesla) seem to only support resolutions of up to around 2560 x 1600 at 60 hz (**VIDEO_PORT** has to be kept to DFP instead of changing to DP-0 or other DisplayPorts). The K40 (Kepler) GPU did not support RandR (required for some graphical applications using SDL). Other Kepler generation Datacenter GPUs (maybe except the GRID K1 and K2 GPUs with vGPU capabilities) are also unlikely to support RandR, while the remote desktop itself is otherwise functional. RandR support probably starts from Maxwell Datacenter GPUs. Other tested Datacenter GPUs (V100, T4, A40, A100) likely support all graphical applications that consumer GPUs support. However, the performances were not better than consumer GPUs that usually cost a fraction of Datacenter GPUs, and the maximum supported resolutions were even lower.
+There are two web interfaces that can be chosen in this container, the first being the default [selkies-gstreamer](https://github.com/selkies-project/selkies-gstreamer) WebRTC HTML5 interface, and the second being the fallback [noVNC](https://github.com/novnc/noVNC) WebSocket HTML5 interface. The noVNC interface can be enabled by setting `NOVNC_ENABLE` to `true`. While the noVNC interface does not support audio forwarding, it can be useful for troubleshooting the selkies-gstreamer WebRTC interface or using this container with low bandwidth environments. When using the noVNC interface, all environment variables related to the selkies-gstreamer WebRTC interface are ignored, with the exception of `BASIC_AUTH_PASSWORD`. As with the selkies-gstreamer WebRTC interface, the noVNC interface password will be set to `BASIC_AUTH_PASSWORD`, and use `PASSWD` by default if not set.
 
-Container startup could take some time at first launch as it automatically installs NVIDIA drivers with the same version as the host.
+The container requires host NVIDIA GPU driver versions of at least **450.80.02**, with the corresponding container toolkit runtime to be also configured on the host for allocating GPUs. All Maxwell or later generation GPUs in the consumer, professional, or datacenter lineups will not have significant issues running this container, although the selkies-gstreamer high performance NVENC backend may not be available (see the next paragraph). Kepler GPUs are untested and likely does not support the NVENC backend, but can be mostly functional using the software acceleration fallback.
 
-Connect to the spawned Apache Guacamole instance with a web browser in port 8080 (the username is "user" and the default password is "mypasswd"). No VNC client installation is required. Press Ctrl+Alt+Shift to toggle the configuration option in Guacamole. Click the fullscreen button in your web browser settings or press F11 after pressing Ctrl+Alt+Shift to bring up fullscreen.
+The high performance NVENC backend for the selkies-gstreamer WebRTC interface is only supported in GPUs that is listed as supporting `H.264 (AVCHD)` under the `NVENC - Encoding` section of NVIDIA's [Video Encode and Decode GPU Support Matrix](https://developer.nvidia.com/video-encode-and-decode-gpu-support-matrix-new). If your GPU is not listed as supporting `H.264 (AVCHD)`, add the environment variable `WEBRTC_ENCODER` with the value `x264enc` in your container configuration for falling back to software acceleration, which also has a very good performance depending on your CPU.
 
-Wine and Winetricks are bundled by default, comment out the installation section in **Dockerfile** if the user wants to remove them from the container.
+The username is `user` in both the container user account and the web authentication prompt. The environment variable `PASSWD` is the password of the container user account, and `BASIC_AUTH_PASSWORD` is the password for the HTML5 interface authentication prompt. If `ENABLE_BASIC_AUTH` is set to `true` for selkies-gstreamer (not required for noVNC) but `BASIC_AUTH_PASSWORD` is unspecified, the HTML5 interface password will default to `PASSWD`.
+> NOTES: Only one web browser can be connected at a time with the selkies-gstreamer WebRTC interface. If the signaling connection works, but the WebRTC connection fails, read the [Using a TURN Server](#using-a-turn-server) section.
 
-For building Ubuntu 18.04 containers, in **Dockerfile** change `FROM nvidia/opengl:1.2-glvnd-runtime-ubuntu20.04` to `FROM nvidia/opengl:1.2-glvnd-runtime-ubuntu18.04`.
+#### Running with Docker
 
-For Docker this will be sufficient (the container must only be used in unprivileged mode, use `--tmpfs /dev/shm:rw` for a slight performance improvement):
+1. Run the container with Docker (or other similar container CLIs like Podman):
 
 ```
-docker run --gpus 1 -it -e TZ=UTC -e SIZEW=1920 -e SIZEH=1080 -e CDEPTH=24 -e PASSWD=mypasswd -e VIDEO_PORT=DFP -p 8080:8080 ghcr.io/ehfd/nvidia-glx-desktop:latest
+docker run --gpus 1 -it -e TZ=UTC -e SIZEW=1920 -e SIZEH=1080 -e REFRESH=60 -e DPI=96 -e CDEPTH=24 -e VIDEO_PORT=DFP -e PASSWD=mypasswd -e WEBRTC_ENCODER=nvh264enc -e BASIC_AUTH_PASSWORD=mypasswd -p 8080:8080 ghcr.io/ehfd/nvidia-glx-desktop:latest
 ```
+> NOTES: The container tags available are `latest` and `20.04` for Ubuntu 20.04 and `18.04` for Ubuntu 18.04. Replace all instances of `mypasswd` with your desired password. `BASIC_AUTH_PASSWORD` will default to `PASSWD` if unspecified. The container must not be run in privileged mode. Use the option `--tmpfs /dev/shm:rw` for a slight performance improvement.
+
+Change `WEBRTC_ENCODER` to `x264enc` when using the selkies-gstreamer interface if your GPU doesn't support `H.264 (AVCHD)` under the `NVENC - Encoding` section in NVIDIA's [Video Encode and Decode GPU Support Matrix](https://developer.nvidia.com/video-encode-and-decode-gpu-support-matrix-new).
+
+2. Connect to the web server with a browser on port 8080. You may also separately configure a reverse proxy to this port for external connectivity.
+> NOTES: Additional configurations and environment variables for the selkies-gstreamer WebRTC HTML5 interface are listed in lines that start with `parser.add_argument` within the [selkies-gstreamer main script](https://github.com/selkies-project/selkies-gstreamer/blob/master/src/selkies_gstreamer/__main__.py).
+
+#### Running with Kubernetes
+
+1. Create the Kubernetes Secret with your authentication password:
+
+```bash
+kubectl create secret generic my-pass --from-literal=my-pass=YOUR_PASSWORD
+```
+> NOTES: Replace `YOUR_PASSWORD` with your desired password, and change the name `my-pass` to your preferred name of the Kubernetes secret with the `xgl.yml` file changed accordingly as well. It is possible to skip the first step and directly provide the password with `value:` in `xgl.yml`, but this exposes the password in plain text.
+
+2. Create the pod after editing the `xgl.yml` file to your needs:
+
+```bash
+kubectl create -f xgl.yml
+```
+> NOTES: The container tags available are `latest` and `20.04` for Ubuntu 20.04 and `18.04` for Ubuntu 18.04. `BASIC_AUTH_PASSWORD` will default to `PASSWD` if unspecified.
+
+Change `WEBRTC_ENCODER` to `x264enc` when using the selkies-gstreamer WebRTC interface if your GPU doesn't support `H.264 (AVCHD)` under the `NVENC - Encoding` section in NVIDIA's [Video Encode and Decode GPU Support Matrix](https://developer.nvidia.com/video-encode-and-decode-gpu-support-matrix-new).
+
+3. Connect to the web server spawned at port 8080. You may configure the ingress endpoint or reverse proxy that your Kubernetes cluster provides to this port for external connectivity.
+> NOTES: Additional configurations and environment variables for the selkies-gstreamer WebRTC HTML5 interface are listed in lines that start with `parser.add_argument` within the [selkies-gstreamer main script](https://github.com/selkies-project/selkies-gstreamer/blob/master/src/selkies_gstreamer/__main__.py).
+
+#### Using a TURN Server
+
+Note that this section is only applicable for the selkies-gstreamer WebRTC HTML5 interface. In most cases when either of your server or client has a permissive firewall, the default Google STUN server configuration will work without additional configuration. However, when connecting from networks that cannot be traversed with STUN, a TURN server is required. Provide the TURN server address, port, and shared secret in order to take advantage of the TURN relay capabilities and improve connection success.
+
+An open source TURN server that can be used is [coTURN](https://github.com/coturn/coturn), and an [example container implementation](https://github.com/selkies-project/selkies-gstreamer/tree/master/addons/coturn) `ghcr.io/selkies-project/selkies-gstreamer/coturn:latest` is available. For dynamic IP addresses, [dynamic-coturn](https://github.com/mreichardt95/dynamic-coturn) is a container implementation which restarts the TURN server whenever the public IP address gets changed. [Pion TURN](https://github.com/pion/turn) is another TURN server implementation compatible with all major operating systems, and [restund](https://openwrt.org/packages/pkgdata/restund) is a TURN server implementation for OpenWRT.
+
+The [Numb STUN/TURN Server](https://numb.viagenie.ca) is a free TURN server instance that may be used for personal purposes upon registration, but may not be optimal for production usage.
+
+With Docker, use the `-e` option to add the `TURN_HOST`, `TURN_PORT` environment variables. You also require to provide either just `TURN_SHARED_SECRET` for time-limited shared secret TURN authentication, or both `TURN_USERNAME` and `TURN_PASSWORD` for legacy long term TURN authentication, depending on your TURN server configuration. Provide just one of these authentication methods, not both.
+
+##### Configuring With Kubernetes
+
+Your TURN server will use only one out of two ways to authenticate the client, so only provide one type of authentication method. The time-limited shared secret TURN authentication requires to only provide the Base64 encoded `TURN_SHARED_SECRET`. The legacy long term TURN authentication requires to provide both `TURN_USERNAME` and `TURN_PASSWORD` credentials.
+
+###### Time-Limited Shared Secret Authentication
+
+1. Create a secret containing the TURN shared secret:
+
+```bash
+kubectl create secret generic turn-shared-secret --from-literal=turn-shared-secret=MY_TURN_SHARED_SECRET
+```
+> NOTES: Replace `MY_TURN_SHARED_SECRET` with the shared secret of the TURN server, then changing the name `turn-shared-secret` to your preferred name of the Kubernetes secret, with the `xgl.yml` file also being changed accordingly.
+
+2. Uncomment the lines in the `xgl.yml` file related to TURN server usage, updating the `TURN_HOST` and `TURN_PORT` environment variable as needed:
+
+```yaml
+- name: TURN_HOST
+  value: "turn.example.com"
+- name: TURN_PORT
+  value: "3478"
+- name: TURN_SHARED_SECRET
+  valueFrom:
+    secretKeyRef:
+      name: turn-shared-secret
+      key: turn-shared-secret
+```
+> NOTES: It is possible to skip the first step and directly provide the shared secret with `value:`, but this exposes the shared secret in plain text.
+
+###### Legacy Long Term Authentication
+
+1. Create a secret containing the TURN password:
+
+```bash
+kubectl create secret generic turn-password --from-literal=turn-password=MY_TURN_PASSWORD
+```
+> NOTES: Replace `MY_TURN_PASSWORD` with the password of the TURN server, then changing the name `turn-password` to your preferred name of the Kubernetes secret, with the `xgl.yml` file also being changed accordingly.
+
+2. Uncomment the lines in the `xgl.yml` file related to TURN server usage, updating the `TURN_HOST`, `TURN_PORT`, and `TURN_USERNAME` environment variable as needed:
+
+```yaml
+- name: TURN_HOST
+  value: "turn.example.com"
+- name: TURN_PORT
+  value: "3478"
+- name: TURN_USERNAME
+  value: "username"
+- name: TURN_PASSWORD
+  valueFrom:
+    secretKeyRef:
+      name: turn-password
+      key: turn-password
+```
+> NOTES: It is possible to skip the first step and directly provide the TURN password with `value:`, but this exposes the TURN password in plain text.
+
+### Troubleshooting
+
+The container simulates the GPU being virtually plugged into a physical DVI-D/HDMI/DisplayPort digital video interface in consumer and professional GPUs. The container uses virtualized DVI-D ports for this purpose in Datacenter (Tesla) GPUs. The ports to be used should be connected with an actual monitor only when the user wants the remote desktop screen to be shown on that monitor. If you want to show the remote desktop screen spawned by the container in a physical monitor, connect the monitor and set `VIDEO_PORT` to the the video interface identifier that is connected to the monitor. Manually specify a video interface identifier that is not connected to a monitor in `VIDEO_PORT` if you have a physical monitor connected and want to do the opposite. `VIDEO_PORT` identifiers and their connection states can be obtained by typing `xrandr -q` when the `DISPLAY` environment variable is set to the number of the spawned X server display (for example `:0`).
+> NOTES: Do not start two or more X servers for a single GPU. Use a separate GPU (or use Xvfb/Xdummy/XVnc without hardware acceleration to use no GPUs) if you need a host X server unaffiliated with containers, and do not make the GPU available to the container runtime.
+
+Since this container simulates the GPU being virtually plugged into a physical monitor while it actually does not, make sure the resolutions specified with the environment variables `SIZEW` and `SIZEH` are within the maximum size supported by the GPU. The environment variable `VIDEO_PORT` can override which video port is used (defaults to `DFP`, the first interface detected in the driver). Therefore, specifying `VIDEO_PORT` to an unplugged DisplayPort (for example numbered like `DP-0`, `DP-1`, and so on) is recommended for resolutions above 1920 x 1200 at 60 hz, because some driver restrictions are applied when the default is set to an unplugged physical DVI-D or HDMI port. The maximum size that should work in all cases is 1920 x 1200 at 60 hz, mainly for when the default `VIDEO_PORT` identifier `DFP` is not set to DisplayPort. The screen sizes over 1920 x 1200 at 60 hz but under the maximum supported display size specified for each port (supported by GPU specifications) will be possible if the port is set to DisplayPort (both physically connected or disconnected), or when a physical monitor or dummy plug to any other type of display ports (including DVI-D and HDMI) has been physically connected. If all GPUs in the cluster have at least one DisplayPort and they are not physically connected to any monitors, simply setting `VIDEO_PORT` to `DP-0` is recommended (but this is not set as default because of legacy GPU compatibility reasons).
+
+Datacenter (Tesla) GPUs seem to only support resolutions of up to around 2560 x 1600 at 60 hz (`VIDEO_PORT` must be kept to `DFP` instead of changing to `DP-0` or other DisplayPort identifiers). The K40 (Kepler) GPU did not support RandR (required for some graphical applications using SDL and other graphical frameworks). Other Kepler generation Datacenter GPUs (maybe except the GRID K1 and K2 GPUs with vGPU capabilities) are also unlikely to support RandR, thus Datacenter GPU RandR support probably starts from Maxwell. Other tested Datacenter GPUs (V100, T4, A40, A100) support all graphical applications that consumer GPUs support. However, the performances were not better than consumer GPUs that usually cost a fraction of Datacenter GPUs, and the maximum supported resolutions were even lower.
+
+---
+**Please post issues relevant to the selkies-gstreamer WebRTC HTML5 interface to the [selkies-gstreamer](https://github.com/selkies-project/selkies-gstreamer) repository.**
+
+This project involved a collaboration effort with [Dan Isla](https://github.com/danisla) of the [Selkies Project](https://github.com/selkies-project), incorporating the [selkies-gstreamer](https://github.com/selkies-project/selkies-gstreamer) WebRTC remote desktop streaming application.
 
 This work was supported in part by NSF awards CNS-1730158, ACI-1540112, ACI-1541349, OAC-1826967, the University of California Office of the President, and the University of California San Diego’s California Institute for Telecommunications and Information Technology/Qualcomm Institute. Thanks to CENIC for the 100Gbps networks.

+ 22 - 49
entrypoint.sh

@@ -1,26 +1,24 @@
-#!/bin/bash
-set -e
+#!/bin/bash -e
 
 trap "echo TRAPed signal" HUP INT QUIT KILL TERM
 
-sudo chown -R user:user /home/user /opt/tomcat
+sudo chown -R user:user /home/user
 echo "user:$PASSWD" | sudo chpasswd
+sudo rm -rf /tmp/.X*
 sudo ln -snf "/usr/share/zoneinfo/$TZ" /etc/localtime && echo "$TZ" | sudo tee /etc/timezone > /dev/null
-export PATH="${PATH}:/opt/tomcat/bin"
 
 sudo ln -snf /dev/ptmx /dev/tty7
-sudo /etc/init.d/ssh start
 sudo /etc/init.d/dbus start
-pulseaudio --start
 
 # Install NVIDIA drivers, including X graphic drivers by omitting --x-{prefix,module-path,library-path,sysconfig-path}
 if ! command -v nvidia-xconfig &> /dev/null; then
   export DRIVER_VERSION=$(head -n1 </proc/driver/nvidia/version | awk '{print $8}')
-  BASE_URL=https://download.nvidia.com/XFree86/Linux-x86_64
   cd /tmp
-  curl -fsSL -O $BASE_URL/$DRIVER_VERSION/NVIDIA-Linux-x86_64-$DRIVER_VERSION.run
-  sudo sh NVIDIA-Linux-x86_64-$DRIVER_VERSION.run -x
-  cd NVIDIA-Linux-x86_64-$DRIVER_VERSION
+  if [ ! -f "/tmp/NVIDIA-Linux-x86_64-$DRIVER_VERSION.run" ]; then
+    curl -fsL -O "https://us.download.nvidia.com/XFree86/Linux-x86_64/$DRIVER_VERSION/NVIDIA-Linux-x86_64-$DRIVER_VERSION.run" || curl -fsL -O "https://us.download.nvidia.com/tesla/$DRIVER_VERSION/NVIDIA-Linux-x86_64-$DRIVER_VERSION.run" || { echo "Failed NVIDIA GPU driver download. Exiting."; exit 1; }
+  fi
+  sudo sh "NVIDIA-Linux-x86_64-$DRIVER_VERSION.run" -x
+  cd "NVIDIA-Linux-x86_64-$DRIVER_VERSION"
   sudo ./nvidia-installer --silent \
                     --no-kernel-module \
                     --install-compat32-libs \
@@ -31,8 +29,7 @@ if ! command -v nvidia-xconfig &> /dev/null; then
                     --no-check-for-alternate-installs \
                     --no-libglx-indirect \
                     --no-install-libglvnd
-  sudo rm -rf /tmp/NVIDIA*
-  cd ~
+  sudo rm -rf /tmp/NVIDIA* && cd ~
 fi
 
 if grep -Fxq "allowed_users=console" /etc/X11/Xwrapper.config; then
@@ -63,50 +60,26 @@ HEX_ID=$(sudo nvidia-smi --query-gpu=pci.bus_id --id="$GPU_SELECT" --format=csv
 IFS=":." ARR_ID=($HEX_ID)
 unset IFS
 BUS_ID=PCI:$((16#${ARR_ID[1]})):$((16#${ARR_ID[2]})):$((16#${ARR_ID[3]}))
-export MODELINE=$(cvt -r ${SIZEW} ${SIZEH} | sed -n 2p)
-sudo nvidia-xconfig --virtual="${SIZEW}x${SIZEH}" --depth="$CDEPTH" --mode=$(echo $MODELINE | awk '{print $2}' | tr -d '"') --allow-empty-initial-configuration --no-probe-all-gpus --busid="$BUS_ID" --only-one-x-screen --connected-monitor="$VIDEO_PORT"
+export MODELINE=$(cvt -r "${SIZEW}" "${SIZEH}" "${REFRESH}" | sed -n 2p)
+sudo nvidia-xconfig --virtual="${SIZEW}x${SIZEH}" --depth="$CDEPTH" --mode=$(echo "$MODELINE" | awk '{print $2}' | tr -d '"') --allow-empty-initial-configuration --no-probe-all-gpus --busid="$BUS_ID" --only-one-x-screen --connected-monitor="$VIDEO_PORT"
 sudo sed -i '/Driver\s\+"nvidia"/a\    Option         "ModeValidation" "NoMaxPClkCheck, NoEdidMaxPClkCheck, NoMaxSizeCheck, NoHorizSyncCheck, NoVertRefreshCheck, NoVirtualSizeCheck, NoExtendedGpuCapabilitiesCheck, NoTotalSizeCheck, NoDualLinkDVICheck, NoDisplayPortBandwidthCheck, AllowNon3DVisionModes, AllowNonHDMI3DModes, AllowNonEdidModes, NoEdidHDMI2Check, AllowDpInterlaced"' /etc/X11/xorg.conf
 sudo sed -i '/Section\s\+"Monitor"/a\    '"$MODELINE" /etc/X11/xorg.conf
 
+export DISPLAY=:0
 export __GL_SYNC_TO_VBLANK=0
-Xorg vt7 -novtswitch -sharevts -dpi 96 +extension "MIT-SHM" :0 &
-sleep 1
-
-sudo x11vnc -display ":0" -passwd "$PASSWD" -shared -forever -repeat -xkb -xrandr "resize" -rfbport 5900 &
+Xorg vt7 -novtswitch -sharevts -dpi "${DPI}" +extension "MIT-SHM" "${DISPLAY}" &
 
-mkdir -p ~/.guacamole
-echo "<user-mapping>
-    <authorize username=\"user\" password=\"$PASSWD\">
-        <connection name=\"VNC\">
-            <protocol>vnc</protocol>
-            <param name=\"hostname\">localhost</param>
-            <param name=\"port\">5900</param>
-            <param name=\"autoretry\">10</param>
-            <param name=\"password\">$PASSWD</param>
-            <param name=\"enable-sftp\">true</param>
-            <param name=\"sftp-hostname\">localhost</param>
-            <param name=\"sftp-username\">user</param>
-            <param name=\"sftp-password\">$PASSWD</param>
-            <param name=\"sftp-directory\">/home/user</param>
-            <param name=\"enable-audio\">true</param>
-            <param name=\"audio-servername\">localhost</param>
-        </connection>
-        <connection name=\"SSH\">
-            <protocol>ssh</protocol>
-            <param name=\"hostname\">localhost</param>
-            <param name=\"username\">user</param>
-            <param name=\"password\">$PASSWD</param>
-            <param name=\"enable-sftp\">true</param>
-        </connection>
-    </authorize>
-</user-mapping>
-" > ~/.guacamole/user-mapping.xml
-chmod 0600 ~/.guacamole/user-mapping.xml
+# Wait for X11 to start
+echo "Waiting for X socket"
+until [ -S "/tmp/.X11-unix/X${DISPLAY/:/}" ]; do sleep 1; done
+echo "X socket is ready"
 
-/opt/tomcat/bin/catalina.sh run &
-guacd -b 0.0.0.0 -f &
+if [ "$NOVNC_ENABLE" = "true" ]; then
+  sudo x11vnc -display ":0" -passwd "${BASIC_AUTH_PASSWORD:-$PASSWD}" -shared -forever -repeat -xkb -xrandr "resize" -rfbport 5900 &
+  /opt/noVNC/utils/novnc_proxy --vnc localhost:5900 --listen 8080 --heartbeat 10 &
+fi
 
-export DISPLAY=:0
+# Add custom processes below this section or within `supervisord.conf`
 mate-session &
 
 echo "Session Running. Press [Return] to exit."

+ 52 - 0
selkies-gstreamer-entrypoint.sh

@@ -0,0 +1,52 @@
+#!/bin/bash -e
+
+# Update env for gstreamer
+source /opt/gstreamer/gst-env
+export LD_LIBRARY_PATH="/usr/local/cuda/lib64:${LD_LIBRARY_PATH}"
+export DISPLAY=":0"
+export GST_DEBUG="${GST_DEBUG:-*:2}"
+if [ -n "$ENABLE_BASIC_AUTH" ] && [ -z "$BASIC_AUTH_PASSWORD" ]; then export BASIC_AUTH_PASSWORD="$PASSWD"; fi
+
+# Wait for X11 to start
+echo "Waiting for X socket"
+until [ -S "/tmp/.X11-unix/X${DISPLAY/:/}" ]; do sleep 1; done
+echo "X socket is ready"
+
+# Write Progressive Web App (PWA) config.
+export PWA_APP_NAME="Selkies WebRTC"
+export PWA_APP_SHORT_NAME="selkies"
+export PWA_START_URL="/index.html"
+sed -i \
+    -e "s|PWA_APP_NAME|${PWA_APP_NAME}|g" \
+    -e "s|PWA_APP_SHORT_NAME|${PWA_APP_SHORT_NAME}|g" \
+    -e "s|PWA_START_URL|${PWA_START_URL}|g" \
+/opt/gst-web/manifest.json && \
+sed -i \
+    -e "s|PWA_CACHE|${PWA_APP_SHORT_NAME}-webrtc-pwa|g" \
+/opt/gst-web/sw.js
+
+# Write default user config.
+export SELKIES_USER_CONFIG_FILE="${HOME}/.config/selkies/selkies-gstreamer-conf.json"
+mkdir -p $(dirname "$SELKIES_USER_CONFIG_FILE")
+if [ ! -f "${SELKIES_USER_CONFIG_FILE}" ]; then
+    cat - > "${SELKIES_USER_CONFIG_FILE}" <<EOF
+{
+    "framerate": 60,
+    "video_bitrate": 4000,
+    "audio_bitrate": 64000,
+    "enable_audio": "${ENABLE_AUDIO:-true}",
+    "enable_resize": "${WEBRTC_ENABLE_RESIZE:-true}",
+    "encoder": "nvh264enc"
+}
+EOF
+fi
+
+# Clear the cache registry to force the cuda elements to refresh
+rm -f "${HOME}/.cache/gstreamer-1.0/registry.x86_64.bin"
+
+# Start the selkies webrtc gstreamer app
+selkies-gstreamer \
+    --json_config="${SELKIES_USER_CONFIG_FILE}" \
+    --addr="0.0.0.0" \
+    --port="8080" \
+    $@

+ 23 - 0
supervisord.conf

@@ -14,3 +14,26 @@ autostart=true
 autorestart=true
 redirect_stderr=true
 priority=1
+
+[program:pulseaudio]
+user=user
+command=bash -c "sudo kill $(pidof pulseaudio) >/dev/null 2>&1 || sudo /usr/bin/pulseaudio --system --verbose --log-target=stderr --realtime=true --disallow-exit -L \"module-native-protocol-tcp auth-ip-acl=127.0.0.0/8 port=4713 auth-anonymous=1\""
+environment=DISPLAY=":0"
+logfile=/tmp/pulseaudio.log
+pidfile=/tmp/pulseaudio.pid
+stopsignal=INT
+autostart=true
+autorestart=true
+redirect_stderr=true
+priority=10
+
+[program:selkies-gstreamer]
+user=user
+command=bash -c "if [ %(ENV_NOVNC_ENABLE)s != true ]; then /etc/selkies-gstreamer-entrypoint.sh; fi; sleep infinity"
+logfile=/tmp/selkies-gstreamer-entrypoint.log
+pidfile=/tmp/selkies-gstreamer-entrypoint.pid
+stopsignal=INT
+autostart=true
+autorestart=true
+redirect_stderr=true
+priority=20

+ 0 - 67
xgl.yaml

@@ -1,67 +0,0 @@
-apiVersion: apps/v1
-kind: Deployment
-metadata:
-  name: xgl
-spec:
-  replicas: 1
-  selector:
-    matchLabels:
-      app: xgl
-  template:
-    metadata:
-      labels:
-        app: xgl
-    spec:
-      hostname: xgl
-      containers:
-      - name: xgl
-        image: ghcr.io/ehfd/nvidia-glx-desktop:latest
-        env:
-        - name: TZ
-          value: "UTC"
-        - name: SIZEW
-          value: "1920"
-        - name: SIZEH
-          value: "1080"
-        - name: CDEPTH
-          value: "24"
-        - name: PASSWD
-          value: "mypasswd"
-#          valueFrom:
-#            secretKeyRef:
-#              name: xgl-pass
-#              key: xgl-pass
-        - name: VIDEO_PORT
-          value: "DFP"
-        stdin: true
-        tty: true
-        ports:
-        - containerPort: 8080
-          protocol: TCP
-        resources:
-          limits:
-            memory: 64Gi
-            cpu: "16"
-            nvidia.com/gpu: 1
-          requests:
-            memory: 100Mi
-            cpu: 100m
-        volumeMounts:
-        - mountPath: /dev/shm
-          name: dshm
-        - mountPath: /cache
-          name: xgl-cache-vol
-        - mountPath: /home/user
-          name: xgl-root-vol
-      volumes:
-      - name: dshm
-        emptyDir:
-          medium: Memory
-      - name: xgl-cache-vol
-        emptyDir: {}
-#        persistentVolumeClaim:
-#          claimName: xgl-cache-vol
-      - name: xgl-root-vol
-        emptyDir: {}
-#        persistentVolumeClaim:
-#          claimName: xgl-root-vol

+ 117 - 0
xgl.yml

@@ -0,0 +1,117 @@
+apiVersion: apps/v1
+kind: Deployment
+metadata:
+  name: xgl
+spec:
+  replicas: 1
+  selector:
+    matchLabels:
+      app: xgl
+  template:
+    metadata:
+      labels:
+        app: xgl
+    spec:
+      hostname: xgl
+      containers:
+      - name: xgl
+        image: ghcr.io/ehfd/nvidia-glx-desktop:latest
+        env:
+        - name: TZ
+          value: "UTC"
+        - name: SIZEW
+          value: "1920"
+        - name: SIZEH
+          value: "1080"
+        - name: REFRESH
+          value: "60"
+        - name: DPI
+          value: "96"
+        - name: CDEPTH
+          value: "24"
+        - name: VIDEO_PORT
+          value: "DFP"
+        # Choose either `value:` or `secretKeyRef:` but not both at the same time
+        - name: PASSWD
+          value: "mypasswd"
+#          valueFrom:
+#            secretKeyRef:
+#              name: my-pass
+#              key: my-pass
+        # Uncomment this to enable noVNC, disabing selkies-gstreamer and ignoring all its parameters except `BASIC_AUTH_PASSWORD`, which will be used for authentication with noVNC, `BASIC_AUTH_PASSWORD` also defaulting to `PASSWD` if not provided
+#        - name: NOVNC_ENABLE
+#          value: "true"
+        ###
+        # selkies-gstreamer parameters, for additional configurations see lines that start with "parser.add_argument" in https://github.com/selkies-project/selkies-gstreamer/blob/master/src/selkies_gstreamer/__main__.py
+        ###
+        # Change `WEBRTC_ENCODER` to `x264enc` if your GPU doesn't support `H.264 (AVCHD)` under the `NVENC - Encoding` section in https://developer.nvidia.com/video-encode-and-decode-gpu-support-matrix-new
+        - name: WEBRTC_ENCODER
+          value: "nvh264enc"
+        - name: WEBRTC_ENABLE_RESIZE
+          value: "false"
+        - name: ENABLE_AUDIO
+          value: "true"
+        - name: ENABLE_BASIC_AUTH
+          value: "true"
+        # Defaults to `PASSWD` if unspecified, choose either `value:` or `secretKeyRef:` but not both at the same time
+#        - name: BASIC_AUTH_PASSWORD
+#          value: "mypasswd"
+#          valueFrom:
+#            secretKeyRef:
+#              name: my-pass
+#              key: my-pass
+        ###
+        # Uncomment below to use your TURN server with shared secret for improved network compatibility
+        ###
+#        - name: TURN_HOST
+#          value: "turn.example.com"
+#        - name: TURN_PORT
+#          value: "3478"
+        # Provide only `TURN_SHARED_SECRET` for time-limited shared secret authentication or both `TURN_USERNAME` and `TURN_PASSWORD` for legacy long term authentication, but do not provide both authentication methods at the same time 
+#        - name: TURN_SHARED_SECRET
+#          valueFrom:
+#            secretKeyRef:
+#              name: turn-shared-secret
+#              key: turn-shared-secret
+#        - name: TURN_USERNAME
+#          value: "username"
+        # Choose either `value:` or `secretKeyRef:` but not both at the same time
+#        - name: TURN_PASSWORD
+#          value: "mypasswd"
+#          valueFrom:
+#            secretKeyRef:
+#              name: turn-password
+#              key: turn-password
+        stdin: true
+        tty: true
+        ports:
+        - name: http
+          containerPort: 8080
+          protocol: TCP
+        resources:
+          limits:
+            memory: 64Gi
+            cpu: "16"
+            nvidia.com/gpu: 1
+          requests:
+            memory: 100Mi
+            cpu: 100m
+        volumeMounts:
+        - mountPath: /dev/shm
+          name: dshm
+        - mountPath: /cache
+          name: xgl-cache-vol
+        - mountPath: /home/user
+          name: xgl-root-vol
+      volumes:
+      - name: dshm
+        emptyDir:
+          medium: Memory
+      - name: xgl-cache-vol
+        emptyDir: {}
+#        persistentVolumeClaim:
+#          claimName: xgl-cache-vol
+      - name: xgl-root-vol
+        emptyDir: {}
+#        persistentVolumeClaim:
+#          claimName: xgl-root-vol