Dockerfile 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515
  1. # This Source Code Form is subject to the terms of the Mozilla Public
  2. # License, v. 2.0. If a copy of the MPL was not distributed with this
  3. # file, You can obtain one at https://mozilla.org/MPL/2.0/.
  4. # Ubuntu release versions 22.04, and 20.04 are supported
  5. ARG UBUNTU_RELEASE=22.04
  6. ARG CUDA_VERSION=11.7.1
  7. FROM nvcr.io/nvidia/cuda:${CUDA_VERSION}-runtime-ubuntu${UBUNTU_RELEASE}
  8. LABEL maintainer "https://github.com/ehfd,https://github.com/danisla"
  9. ARG UBUNTU_RELEASE
  10. ARG CUDA_VERSION
  11. # Make all NVIDIA GPUs visible by default
  12. ARG NVIDIA_VISIBLE_DEVICES=all
  13. # Use noninteractive mode to skip confirmation when installing packages
  14. ARG DEBIAN_FRONTEND=noninteractive
  15. # All NVIDIA driver capabilities should preferably be used, check `NVIDIA_DRIVER_CAPABILITIES` inside the container if things do not work
  16. ENV NVIDIA_DRIVER_CAPABILITIES all
  17. # Disable VSYNC for NVIDIA GPUs
  18. ENV __GL_SYNC_TO_VBLANK 0
  19. # Enable AppImage execution in a container
  20. ENV APPIMAGE_EXTRACT_AND_RUN 1
  21. # System defaults that should not be changed
  22. ENV DISPLAY :0
  23. ENV XDG_RUNTIME_DIR /tmp/runtime-user
  24. ENV PULSE_SERVER unix:/run/pulse/native
  25. ENV LD_LIBRARY_PATH /usr/lib/x86_64-linux-gnu:/usr/lib/i386-linux-gnu${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
  26. # Default environment variables (password is "mypasswd")
  27. ENV TZ UTC
  28. ENV SIZEW 1920
  29. ENV SIZEH 1080
  30. ENV REFRESH 60
  31. ENV DPI 96
  32. ENV CDEPTH 24
  33. ENV VIDEO_PORT DFP
  34. ENV PASSWD mypasswd
  35. ENV NOVNC_ENABLE false
  36. ENV WEBRTC_ENCODER nvh264enc
  37. ENV WEBRTC_ENABLE_RESIZE false
  38. ENV ENABLE_AUDIO true
  39. ENV ENABLE_BASIC_AUTH true
  40. # Set versions for components that should be manually checked before upgrading, other component versions are automatically determined by fetching the version online
  41. ARG NOVNC_VERSION=1.4.0
  42. # Install locales to prevent X11 errors
  43. RUN apt-get clean && \
  44. apt-get update && apt-get install --no-install-recommends -y locales && \
  45. rm -rf /var/lib/apt/lists/* && \
  46. locale-gen en_US.UTF-8
  47. ENV LANG en_US.UTF-8
  48. ENV LANGUAGE en_US:en
  49. ENV LC_ALL en_US.UTF-8
  50. # Install Xorg and other important libraries or packages
  51. RUN dpkg --add-architecture i386 && \
  52. apt-get update && apt-get install --no-install-recommends -y \
  53. software-properties-common \
  54. alsa-base \
  55. alsa-utils \
  56. apt-transport-https \
  57. apt-utils \
  58. build-essential \
  59. ca-certificates \
  60. ssl-cert \
  61. cups-browsed \
  62. cups-bsd \
  63. cups-common \
  64. cups-filters \
  65. cups-pdf \
  66. curl \
  67. file \
  68. wget \
  69. bzip2 \
  70. gzip \
  71. xz-utils \
  72. unar \
  73. rar \
  74. unrar \
  75. zip \
  76. unzip \
  77. zstd \
  78. gcc \
  79. git \
  80. jq \
  81. make \
  82. python3 \
  83. python3-cups \
  84. python3-numpy \
  85. mlocate \
  86. nano \
  87. vim \
  88. htop \
  89. fakeroot \
  90. fonts-dejavu \
  91. fonts-freefont-ttf \
  92. fonts-hack \
  93. fonts-liberation \
  94. fonts-noto \
  95. fonts-noto-cjk \
  96. fonts-noto-cjk-extra \
  97. fonts-noto-color-emoji \
  98. fonts-noto-extra \
  99. fonts-noto-ui-extra \
  100. fonts-noto-hinted \
  101. fonts-noto-mono \
  102. fonts-noto-unhinted \
  103. fonts-opensymbol \
  104. fonts-symbola \
  105. fonts-ubuntu \
  106. lame \
  107. less \
  108. libavcodec-extra \
  109. libpulse0 \
  110. pulseaudio \
  111. supervisor \
  112. net-tools \
  113. libglvnd-dev \
  114. libglvnd-dev:i386 \
  115. libgl1-mesa-dev \
  116. libgl1-mesa-dev:i386 \
  117. libegl1-mesa-dev \
  118. libegl1-mesa-dev:i386 \
  119. libgles2-mesa-dev \
  120. libgles2-mesa-dev:i386 \
  121. libglvnd0 \
  122. libglvnd0:i386 \
  123. libgl1 \
  124. libgl1:i386 \
  125. libglx0 \
  126. libglx0:i386 \
  127. libegl1 \
  128. libegl1:i386 \
  129. libgles2 \
  130. libgles2:i386 \
  131. libglu1 \
  132. libglu1:i386 \
  133. libsm6 \
  134. libsm6:i386 \
  135. pkg-config \
  136. packagekit-tools \
  137. mesa-utils \
  138. mesa-utils-extra \
  139. va-driver-all \
  140. va-driver-all:i386 \
  141. i965-va-driver-shaders \
  142. i965-va-driver-shaders:i386 \
  143. intel-media-va-driver-non-free \
  144. intel-media-va-driver-non-free:i386 \
  145. libmfx-tools \
  146. libva2 \
  147. libva2:i386 \
  148. vainfo \
  149. vdpau-driver-all \
  150. vdpau-driver-all:i386 \
  151. vdpauinfo \
  152. xserver-xorg-input-all \
  153. xserver-xorg-input-wacom \
  154. xserver-xorg-video-all \
  155. xserver-xorg-video-intel \
  156. xserver-xorg-video-qxl \
  157. vulkan-tools \
  158. mesa-vulkan-drivers \
  159. mesa-vulkan-drivers:i386 \
  160. libvulkan-dev \
  161. libvulkan-dev:i386 \
  162. libxau6 \
  163. libxau6:i386 \
  164. libxdmcp6 \
  165. libxdmcp6:i386 \
  166. libxcb1 \
  167. libxcb1:i386 \
  168. libxext6 \
  169. libxext6:i386 \
  170. libx11-6 \
  171. libx11-6:i386 \
  172. libxv1 \
  173. libxv1:i386 \
  174. libxtst6 \
  175. libxtst6:i386 \
  176. xdg-user-dirs \
  177. xdg-utils \
  178. dbus-user-session \
  179. dbus-x11 \
  180. libdbus-c++-1-0v5 \
  181. xkb-data \
  182. x11-xkb-utils \
  183. x11-xserver-utils \
  184. x11-utils \
  185. x11-apps \
  186. xauth \
  187. xbitmaps \
  188. xfonts-base \
  189. xfonts-scalable \
  190. xinit \
  191. xsettingsd \
  192. libxrandr-dev \
  193. # Install essential Xorg and NVIDIA packages, packages above this line should be the same between docker-nvidia-glx-desktop and docker-nvidia-egl-desktop
  194. kmod \
  195. libc6-dev \
  196. libc6:i386 \
  197. libpci3 \
  198. libelf-dev \
  199. xorg && \
  200. rm -rf /var/lib/apt/lists/* && \
  201. # Configure EGL manually
  202. mkdir -p /usr/share/glvnd/egl_vendor.d/ && \
  203. echo "{\n\
  204. \"file_format_version\" : \"1.0.0\",\n\
  205. \"ICD\": {\n\
  206. \"library_path\": \"libEGL_nvidia.so.0\"\n\
  207. }\n\
  208. }" > /usr/share/glvnd/egl_vendor.d/10_nvidia.json
  209. # Anything below this line should be always kept the same between docker-nvidia-glx-desktop and docker-nvidia-egl-desktop
  210. # Install KDE and other GUI packages
  211. ENV XDG_CURRENT_DESKTOP KDE
  212. ENV KWIN_COMPOSE N
  213. ENV KWIN_X11_NO_SYNC_TO_VBLANK 1
  214. # Use sudoedit to change protected files instead of using sudo on kate
  215. ENV SUDO_EDITOR kate
  216. RUN mkdir -pm755 /etc/apt/preferences.d && \
  217. echo "Package: firefox*\n\
  218. Pin: version 1:1snap*\n\
  219. Pin-Priority: -1" > /etc/apt/preferences.d/firefox-nosnap && \
  220. add-apt-repository -y ppa:mozillateam/ppa && \
  221. apt-get update && apt-get install --no-install-recommends -y \
  222. kde-plasma-desktop \
  223. adwaita-icon-theme-full \
  224. appmenu-gtk3-module \
  225. ark \
  226. aspell \
  227. aspell-en \
  228. breeze \
  229. breeze-cursor-theme \
  230. breeze-gtk-theme \
  231. breeze-icon-theme \
  232. debconf-kde-helper \
  233. desktop-file-utils \
  234. dolphin \
  235. dolphin-plugins \
  236. dbus-x11 \
  237. enchant-2 \
  238. fcitx \
  239. fcitx-frontend-gtk2 \
  240. fcitx-frontend-gtk3 \
  241. fcitx-frontend-qt5 \
  242. fcitx-module-dbus \
  243. fcitx-module-kimpanel \
  244. fcitx-module-lua \
  245. fcitx-module-x11 \
  246. fcitx-tools \
  247. filelight \
  248. frameworkintegration \
  249. gwenview \
  250. haveged \
  251. hunspell \
  252. im-config \
  253. kate \
  254. kcalc \
  255. kcharselect \
  256. kdeadmin \
  257. kde-config-fcitx \
  258. kde-config-gtk-style \
  259. kde-config-gtk-style-preview \
  260. kdeconnect \
  261. kdegraphics-thumbnailers \
  262. kde-spectacle \
  263. kdf \
  264. kdialog \
  265. kget \
  266. kimageformat-plugins \
  267. kinfocenter \
  268. kio \
  269. kio-extras \
  270. kmag \
  271. kmenuedit \
  272. kmix \
  273. kmousetool \
  274. kmouth \
  275. ksshaskpass \
  276. ktimer \
  277. kwayland-integration \
  278. kwin-addons \
  279. kwin-x11 \
  280. libdbusmenu-glib4 \
  281. libdbusmenu-gtk3-4 \
  282. libgail-common \
  283. libgdk-pixbuf2.0-bin \
  284. libgtk2.0-bin \
  285. libgtk-3-bin \
  286. libkf5baloowidgets-bin \
  287. libkf5dbusaddons-bin \
  288. libkf5iconthemes-bin \
  289. libkf5kdelibs4support5-bin \
  290. libkf5khtml-bin \
  291. libkf5parts-plugins \
  292. libqt5multimedia5-plugins \
  293. librsvg2-common \
  294. media-player-info \
  295. okular \
  296. okular-extra-backends \
  297. partitionmanager \
  298. plasma-browser-integration \
  299. plasma-calendar-addons \
  300. plasma-dataengines-addons \
  301. plasma-discover \
  302. plasma-integration \
  303. plasma-runners-addons \
  304. plasma-widgets-addons \
  305. policykit-desktop-privileges \
  306. polkit-kde-agent-1 \
  307. print-manager \
  308. qapt-deb-installer \
  309. qml-module-org-kde-runnermodel \
  310. qml-module-org-kde-qqc2desktopstyle \
  311. qml-module-qtgraphicaleffects \
  312. qml-module-qtquick-xmllistmodel \
  313. qt5-gtk-platformtheme \
  314. qt5-image-formats-plugins \
  315. qt5-style-plugins \
  316. qtspeech5-flite-plugin \
  317. qtvirtualkeyboard-plugin \
  318. software-properties-qt \
  319. sonnet-plugins \
  320. sweeper \
  321. systemsettings \
  322. ubuntu-drivers-common \
  323. vlc \
  324. vlc-l10n \
  325. vlc-plugin-access-extra \
  326. vlc-plugin-notify \
  327. vlc-plugin-samba \
  328. vlc-plugin-skins2 \
  329. vlc-plugin-video-splitter \
  330. vlc-plugin-visualization \
  331. xdg-desktop-portal-kde \
  332. xdg-user-dirs \
  333. firefox \
  334. pavucontrol-qt \
  335. transmission-qt && \
  336. apt-get install --install-recommends -y \
  337. libreoffice \
  338. libreoffice-kf5 \
  339. libreoffice-plasma \
  340. libreoffice-style-breeze && \
  341. rm -rf /var/lib/apt/lists/* && \
  342. # Fix KDE startup permissions issues in containers
  343. cp -f /usr/lib/x86_64-linux-gnu/libexec/kf5/start_kdeinit /tmp/ && \
  344. rm -f /usr/lib/x86_64-linux-gnu/libexec/kf5/start_kdeinit && \
  345. cp -r /tmp/start_kdeinit /usr/lib/x86_64-linux-gnu/libexec/kf5/start_kdeinit && \
  346. rm -f /tmp/start_kdeinit && \
  347. # KDE disable screen lock, double-click to open instead of single-click
  348. echo "[Daemon]\n\
  349. Autolock=false\n\
  350. LockOnResume=false" > /etc/xdg/kscreenlockerrc && \
  351. echo "[KDE]\n\
  352. SingleClick=false\n\
  353. \n\
  354. [KDE Action Restrictions]\n\
  355. action/lock_screen=false\n\
  356. logout=false" > /etc/xdg/kdeglobals && \
  357. # Ensure Firefox is the default web browser
  358. update-alternatives --set x-www-browser /usr/bin/firefox
  359. # Wine, Winetricks, Lutris, and PlayOnLinux, this process must be consistent with https://wiki.winehq.org/Ubuntu
  360. ARG WINE_BRANCH=staging
  361. RUN mkdir -pm755 /etc/apt/keyrings && curl -fsSL -o /etc/apt/keyrings/winehq-archive.key "https://dl.winehq.org/wine-builds/winehq.key" && \
  362. curl -fsSL -o "/etc/apt/sources.list.d/winehq-$(grep VERSION_CODENAME= /etc/os-release | cut -d= -f2).sources" "https://dl.winehq.org/wine-builds/ubuntu/dists/$(grep VERSION_CODENAME= /etc/os-release | cut -d= -f2)/winehq-$(grep VERSION_CODENAME= /etc/os-release | cut -d= -f2).sources" && \
  363. apt-get update && apt-get install --install-recommends -y \
  364. winehq-${WINE_BRANCH} && \
  365. apt-get install --no-install-recommends -y \
  366. q4wine \
  367. playonlinux && \
  368. LUTRIS_VERSION=$(curl -fsSL "https://api.github.com/repos/lutris/lutris/releases/latest" | jq -r '.tag_name' | sed 's/[^0-9\.\-]*//g') && \
  369. curl -fsSL -O "https://github.com/lutris/lutris/releases/download/v${LUTRIS_VERSION}/lutris_${LUTRIS_VERSION}_all.deb" && \
  370. apt-get install --no-install-recommends -y ./lutris_${LUTRIS_VERSION}_all.deb && rm -f "./lutris_${LUTRIS_VERSION}_all.deb" && \
  371. rm -rf /var/lib/apt/lists/* && \
  372. curl -fsSL -o /usr/bin/winetricks "https://raw.githubusercontent.com/Winetricks/winetricks/master/src/winetricks" && \
  373. chmod 755 /usr/bin/winetricks && \
  374. curl -fsSL -o /usr/share/bash-completion/completions/winetricks "https://raw.githubusercontent.com/Winetricks/winetricks/master/src/winetricks.bash-completion"
  375. # Install latest Selkies-GStreamer (https://github.com/selkies-project/selkies-gstreamer) build, Python application, and web application, should be consistent with selkies-gstreamer documentation
  376. RUN apt-get update && apt-get install --no-install-recommends -y \
  377. # GStreamer dependencies
  378. python3-pip \
  379. python3-dev \
  380. python3-gi \
  381. python3-setuptools \
  382. python3-wheel \
  383. udev \
  384. wmctrl \
  385. jq \
  386. gdebi-core \
  387. libgdk-pixbuf2.0-0 \
  388. libgtk2.0-bin \
  389. libgl-dev \
  390. libgles-dev \
  391. libglvnd-dev \
  392. libgudev-1.0-0 \
  393. xclip \
  394. x11-utils \
  395. xdotool \
  396. x11-xserver-utils \
  397. xserver-xorg-core \
  398. wayland-protocols \
  399. libwayland-dev \
  400. libwayland-egl1 \
  401. libx11-xcb1 \
  402. libxkbcommon0 \
  403. libxdamage1 \
  404. libsoup2.4-1 \
  405. libsoup-gnome2.4-1 \
  406. libsrtp2-1 \
  407. lame \
  408. libopus0 \
  409. libwebrtc-audio-processing1 \
  410. pulseaudio \
  411. libpulse0 \
  412. libcairo-gobject2 \
  413. libpangocairo-1.0-0 \
  414. libgirepository-1.0-1 \
  415. libopenjp2-7 \
  416. libjpeg-dev \
  417. libwebp-dev \
  418. libvpx-dev \
  419. zlib1g-dev \
  420. x264 \
  421. # AMD/Intel graphics driver dependencies
  422. va-driver-all \
  423. i965-va-driver-shaders \
  424. intel-media-va-driver-non-free \
  425. libmfx-tools \
  426. libva2 \
  427. vainfo \
  428. intel-gpu-tools \
  429. radeontop && \
  430. if [ "${UBUNTU_RELEASE}" \> "20.04" ]; then apt-get install --no-install-recommends -y xcvt; fi && \
  431. rm -rf /var/lib/apt/lists/* && \
  432. cd /opt && \
  433. # Automatically fetch the latest selkies-gstreamer version and install the components
  434. SELKIES_VERSION=$(curl -fsSL "https://api.github.com/repos/selkies-project/selkies-gstreamer/releases/latest" | jq -r '.tag_name' | sed 's/[^0-9\.\-]*//g') && \
  435. 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 - && \
  436. 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" && \
  437. curl -fsSL "https://github.com/selkies-project/selkies-gstreamer/releases/download/v${SELKIES_VERSION}/selkies-gstreamer-web-v${SELKIES_VERSION}.tgz" | tar -zxf - && \
  438. cd /usr/local/cuda/lib64 && sudo find . -maxdepth 1 -type l -name "*libnvrtc.so.*" -exec sh -c 'ln -snf $(basename {}) libnvrtc.so' \;
  439. # Install the noVNC web interface and the latest x11vnc for fallback
  440. RUN apt-get update && apt-get install --no-install-recommends -y \
  441. autoconf \
  442. automake \
  443. autotools-dev \
  444. chrpath \
  445. debhelper \
  446. git \
  447. jq \
  448. python3 \
  449. python3-numpy \
  450. libc6-dev \
  451. libcairo2-dev \
  452. libjpeg-turbo8-dev \
  453. libssl-dev \
  454. libv4l-dev \
  455. libvncserver-dev \
  456. libtool-bin \
  457. libxdamage-dev \
  458. libxinerama-dev \
  459. libxrandr-dev \
  460. libxss-dev \
  461. libxtst-dev \
  462. libavahi-client-dev && \
  463. rm -rf /var/lib/apt/lists/* && \
  464. # Build the latest x11vnc source to avoid various errors
  465. git clone "https://github.com/LibVNC/x11vnc.git" /tmp/x11vnc && \
  466. cd /tmp/x11vnc && autoreconf -fi && ./configure && make install && cd / && rm -rf /tmp/* && \
  467. curl -fsSL "https://github.com/novnc/noVNC/archive/v${NOVNC_VERSION}.tar.gz" | tar -xzf - -C /opt && \
  468. mv -f "/opt/noVNC-${NOVNC_VERSION}" /opt/noVNC && \
  469. ln -snf /opt/noVNC/vnc.html /opt/noVNC/index.html && \
  470. # Use the latest Websockify source to expose noVNC
  471. git clone "https://github.com/novnc/websockify.git" /opt/noVNC/utils/websockify
  472. # Add custom packages right below this comment, or use FROM in a new container and replace entrypoint.sh or supervisord.conf, and set ENTRYPOINT to /usr/bin/supervisord
  473. # Create user with password ${PASSWD} and assign adequate groups
  474. RUN apt-get update && apt-get install --no-install-recommends -y \
  475. sudo \
  476. tzdata && \
  477. rm -rf /var/lib/apt/lists/* && \
  478. groupadd -g 1000 user && \
  479. useradd -ms /bin/bash user -u 1000 -g 1000 && \
  480. usermod -a -G adm,audio,cdrom,dialout,dip,fax,floppy,input,lp,lpadmin,plugdev,pulse-access,scanner,ssl-cert,sudo,tape,tty,video,voice user && \
  481. echo "user ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers && \
  482. chown user:user /home/user && \
  483. echo "user:${PASSWD}" | chpasswd && \
  484. ln -snf "/usr/share/zoneinfo/$TZ" /etc/localtime && echo "$TZ" > /etc/timezone
  485. # Copy scripts and configurations used to start the container
  486. COPY entrypoint.sh /etc/entrypoint.sh
  487. RUN chmod 755 /etc/entrypoint.sh
  488. COPY selkies-gstreamer-entrypoint.sh /etc/selkies-gstreamer-entrypoint.sh
  489. RUN chmod 755 /etc/selkies-gstreamer-entrypoint.sh
  490. COPY supervisord.conf /etc/supervisord.conf
  491. RUN chmod 755 /etc/supervisord.conf
  492. EXPOSE 8080
  493. USER user
  494. ENV SHELL /bin/bash
  495. ENV USER user
  496. WORKDIR /home/user
  497. ENTRYPOINT ["/usr/bin/supervisord"]