浏览代码

Fix installation

Seungmin Kim 1 年之前
父节点
当前提交
baa24a1193
共有 2 个文件被更改,包括 32 次插入29 次删除
  1. 10 10
      Dockerfile
  2. 22 19
      entrypoint.sh

+ 10 - 10
Dockerfile

@@ -136,6 +136,11 @@ RUN apt-get update && apt-get install --no-install-recommends -y \
         xserver-xorg-video-all \
         xserver-xorg-video-intel \
         xserver-xorg-video-qxl \
+        # NVIDIA driver installer dependencies
+        kmod \
+        libc6-dev \
+        libpci3 \
+        libelf-dev \
         # OpenGL libraries
         libxau6 \
         libxdmcp6 \
@@ -195,6 +200,7 @@ RUN apt-get update && apt-get install --no-install-recommends -y \
         vdpau-driver-all:i386 \
         mesa-vulkan-drivers:i386 \
         libvulkan-dev:i386 \
+        libc6:i386 \
         libxau6:i386 \
         libxdmcp6:i386 \
         libxcb1:i386 \
@@ -270,15 +276,9 @@ ENV SELKIES_ENCODER=nvh264enc
 ENV SELKIES_ENABLE_RESIZE=false
 ENV SELKIES_ENABLE_BASIC_AUTH=true
 
-# Install Xorg and NVIDIA driver installer dependencies
+# Install Xorg
 RUN apt-get update && apt-get install --no-install-recommends -y \
-        kmod \
-        libc6-dev \
-        libpci3 \
-        libelf-dev \
-        pkg-config \
         xorg && \
-    if [ "$(dpkg --print-architecture)" = "amd64" ]; then apt-get install --no-install-recommends -y libc6:i386; fi && \
     apt-get clean && rm -rf /var/lib/apt/lists/* /var/cache/debconf/* /var/log/* /tmp/* /var/tmp/*
 
 # Anything below this line should always be kept the same between docker-nvidia-glx-desktop and docker-nvidia-egl-desktop
@@ -432,10 +432,10 @@ Pin-Priority: -1" > /etc/apt/preferences.d/firefox-nosnap && \
         libreoffice-kf5 \
         libreoffice-plasma \
         libreoffice-style-breeze && \
-    # Ensure Firefox as the default web browser
-    update-alternatives --set x-www-browser /usr/bin/firefox && xdg-settings set default-web-browser firefox.desktop && \
     # Install Google Chrome for supported architectures
-    if [ "$(dpkg --print-architecture)" = "amd64" ]; then cd /tmp && curl -o google-chrome-stable.deb -fsSL "https://dl.google.com/linux/direct/google-chrome-stable_current_$(dpkg --print-architecture).deb" && apt-get update && apt-get install --no-install-recommends -y ./google-chrome-stable.deb && rm -f google-chrome-stable.deb && sed -i '/^Exec=/ s/$/ --password-store=basic/' /usr/share/applications/google-chrome.desktop; fi && \
+    if [ "$(dpkg --print-architecture)" = "amd64" ]; then cd /tmp && curl -o google-chrome-stable.deb -fsSL "https://dl.google.com/linux/direct/google-chrome-stable_current_$(dpkg --print-architecture).deb" && apt-get update && apt-get install --no-install-recommends -y ./google-chrome-stable.deb && rm -f google-chrome-stable.deb && sed -i '/^Exec=/ s/$/ --password-store=basic --in-process-gpu/' /usr/share/applications/google-chrome.desktop; fi && \
+    # Ensure Firefox as the default web browser
+    update-alternatives --set x-www-browser /usr/bin/firefox && \
     apt-get clean && rm -rf /var/lib/apt/lists/* /var/cache/debconf/* /var/log/* /tmp/* /var/tmp/* && \
     # Fix KDE startup permissions issues in containers
     MULTI_ARCH=$(dpkg --print-architecture | sed -e 's/arm64/aarch64-linux-gnu/' -e 's/armhf/arm-linux-gnueabihf/' -e 's/riscv64/riscv64-linux-gnu/' -e 's/ppc64el/powerpc64le-linux-gnu/' -e 's/s390x/s390x-linux-gnu/' -e 's/i.*86/i386-linux-gnu/' -e 's/amd64/x86_64-linux-gnu/' -e 's/unknown/x86_64-linux-gnu/') && \

+ 22 - 19
entrypoint.sh

@@ -39,8 +39,8 @@ export PIPEWIRE_RUNTIME_DIR="${PIPEWIRE_RUNTIME_DIR:-${XDG_RUNTIME_DIR:-/tmp}}"
 export PULSE_RUNTIME_PATH="${PULSE_RUNTIME_PATH:-${XDG_RUNTIME_DIR:-/tmp}/pulse}"
 export PULSE_SERVER="${PULSE_SERVER:-unix:${PULSE_RUNTIME_PATH:-${XDG_RUNTIME_DIR:-/tmp}/pulse}/native}"
 
+# Install NVIDIA userspace driver components including X graphic libraries, keep contents except outermost if condition same as docker-nvidia-egl-desktop
 if ! command -v nvidia-xconfig >/dev/null 2>&1; then
-  # Install NVIDIA userspace driver components including X graphic libraries, keep contents same as docker-nvidia-egl-desktop
   export NVIDIA_DRIVER_ARCH="$(dpkg --print-architecture | sed -e 's/arm64/aarch64/' -e 's/armhf/32bit-ARM/' -e 's/i.*86/x86/' -e 's/amd64/x86_64/' -e 's/unknown/x86_64/')"
   if [ -z "${NVIDIA_DRIVER_VERSION}" ]; then
     # Driver version is provided by the kernel through the container toolkit, prioritize kernel driver version if available
@@ -50,31 +50,34 @@ if ! command -v nvidia-xconfig >/dev/null 2>&1; then
       # Use NVIDIA-SMI when not available
       export NVIDIA_DRIVER_VERSION="$(nvidia-smi --version | grep 'DRIVER version' | cut -d: -f2 | tr -d ' ')"
     else
-      echo "Failed to find NVIDIA GPU driver version. You might not be using the NVIDIA container toolkit. Exiting."
-      exit 1
+      echo 'Failed to find NVIDIA GPU driver version, container will likely not start because of no NVIDIA container toolkit or NVIDIA GPU driver present'
     fi
   fi
   cd /tmp
   # If version is different, new installer will overwrite the existing components
   if [ ! -f "/tmp/NVIDIA-Linux-${NVIDIA_DRIVER_ARCH}-${NVIDIA_DRIVER_VERSION}.run" ]; then
     # Check multiple sources in order to probe both consumer and datacenter driver versions
-    curl -fsSL -O "https://international.download.nvidia.com/XFree86/Linux-${NVIDIA_DRIVER_ARCH}/${NVIDIA_DRIVER_VERSION}/NVIDIA-Linux-${NVIDIA_DRIVER_ARCH}-${NVIDIA_DRIVER_VERSION}.run" || curl -fsSL -O "https://international.download.nvidia.com/tesla/${NVIDIA_DRIVER_VERSION}/NVIDIA-Linux-${NVIDIA_DRIVER_ARCH}-${NVIDIA_DRIVER_VERSION}.run" || { echo "Failed NVIDIA GPU driver download. Exiting."; exit 1; }
+    curl -fsSL -O "https://international.download.nvidia.com/XFree86/Linux-${NVIDIA_DRIVER_ARCH}/${NVIDIA_DRIVER_VERSION}/NVIDIA-Linux-${NVIDIA_DRIVER_ARCH}-${NVIDIA_DRIVER_VERSION}.run" || curl -fsSL -O "https://international.download.nvidia.com/tesla/${NVIDIA_DRIVER_VERSION}/NVIDIA-Linux-${NVIDIA_DRIVER_ARCH}-${NVIDIA_DRIVER_VERSION}.run" || echo 'Failed NVIDIA GPU driver download'
+  fi
+  if [ -f "/tmp/NVIDIA-Linux-${NVIDIA_DRIVER_ARCH}-${NVIDIA_DRIVER_VERSION}.run" ]; then
+    # Extract installer before installing
+    sh "NVIDIA-Linux-${NVIDIA_DRIVER_ARCH}-${NVIDIA_DRIVER_VERSION}.run" -x
+    cd "NVIDIA-Linux-${NVIDIA_DRIVER_ARCH}-${NVIDIA_DRIVER_VERSION}"
+    # Run NVIDIA driver installation without the kernel modules and host components
+    sudo ./nvidia-installer --silent \
+                      --accept-license \
+                      --no-kernel-module \
+                      --install-compat32-libs \
+                      --no-nouveau-check \
+                      --no-nvidia-modprobe \
+                      --no-systemd \
+                      --no-rpms \
+                      --no-backup \
+                      --no-check-for-alternate-installs
+    rm -rf /tmp/NVIDIA* && cd ~
+  else
+    echo 'Unless using non-NVIDIA GPUs, container will likely not work correctly'
   fi
-  # Extract installer before installing
-  sh "NVIDIA-Linux-${NVIDIA_DRIVER_ARCH}-${NVIDIA_DRIVER_VERSION}.run" -x
-  cd "NVIDIA-Linux-${NVIDIA_DRIVER_ARCH}-${NVIDIA_DRIVER_VERSION}"
-  # Run NVIDIA driver installation without the kernel modules and host components
-  sudo ./nvidia-installer --silent \
-                    --accept-license \
-                    --no-kernel-module \
-                    --install-compat32-libs \
-                    --no-nouveau-check \
-                    --no-nvidia-modprobe \
-                    --no-systemd \
-                    --no-rpms \
-                    --no-backup \
-                    --no-check-for-alternate-installs
-  rm -rf /tmp/NVIDIA* && cd ~
 fi
 
 # Allow starting Xorg from a pseudoterminal instead of strictly on a tty console