Dockerfile 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475
  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-common \
  63. cups-filters \
  64. cups-pdf \
  65. curl \
  66. file \
  67. wget \
  68. bzip2 \
  69. gzip \
  70. xz-utils \
  71. unar \
  72. rar \
  73. unrar \
  74. zip \
  75. unzip \
  76. zstd \
  77. gcc \
  78. git \
  79. jq \
  80. make \
  81. python3 \
  82. python3-cups \
  83. python3-numpy \
  84. mlocate \
  85. nano \
  86. vim \
  87. htop \
  88. ibus \
  89. ibus-data \
  90. fakeroot \
  91. fonts-dejavu-core \
  92. fonts-freefont-ttf \
  93. fonts-hack \
  94. fonts-liberation \
  95. fonts-noto \
  96. fonts-noto-cjk \
  97. fonts-noto-cjk-extra \
  98. fonts-noto-color-emoji \
  99. fonts-noto-extra \
  100. fonts-noto-ui-extra \
  101. fonts-noto-hinted \
  102. fonts-noto-mono \
  103. fonts-noto-unhinted \
  104. fonts-opensymbol \
  105. fonts-symbola \
  106. fonts-ubuntu \
  107. lame \
  108. less \
  109. libavcodec-extra \
  110. libpulse0 \
  111. pulseaudio \
  112. supervisor \
  113. net-tools \
  114. libglvnd-dev \
  115. libglvnd-dev:i386 \
  116. libgl1-mesa-dev \
  117. libgl1-mesa-dev:i386 \
  118. libegl1-mesa-dev \
  119. libegl1-mesa-dev:i386 \
  120. libgles2-mesa-dev \
  121. libgles2-mesa-dev:i386 \
  122. libglvnd0 \
  123. libglvnd0:i386 \
  124. libgl1 \
  125. libgl1:i386 \
  126. libglx0 \
  127. libglx0:i386 \
  128. libegl1 \
  129. libegl1:i386 \
  130. libgles2 \
  131. libgles2:i386 \
  132. libglu1 \
  133. libglu1:i386 \
  134. libsm6 \
  135. libsm6:i386 \
  136. pkg-config \
  137. packagekit-tools \
  138. mesa-utils \
  139. mesa-utils-extra \
  140. va-driver-all \
  141. va-driver-all:i386 \
  142. i965-va-driver-shaders \
  143. i965-va-driver-shaders:i386 \
  144. intel-media-va-driver-non-free \
  145. intel-media-va-driver-non-free:i386 \
  146. libmfx-tools \
  147. libva2 \
  148. libva2:i386 \
  149. vainfo \
  150. vdpau-driver-all \
  151. vdpau-driver-all:i386 \
  152. vdpauinfo \
  153. xserver-xorg-input-all \
  154. xserver-xorg-input-wacom \
  155. xserver-xorg-video-all \
  156. xserver-xorg-video-intel \
  157. xserver-xorg-video-qxl \
  158. vulkan-tools \
  159. mesa-vulkan-drivers \
  160. mesa-vulkan-drivers:i386 \
  161. libvulkan-dev \
  162. libvulkan-dev:i386 \
  163. libxau6 \
  164. libxau6:i386 \
  165. libxdmcp6 \
  166. libxdmcp6:i386 \
  167. libxcb1 \
  168. libxcb1:i386 \
  169. libxext6 \
  170. libxext6:i386 \
  171. libx11-6 \
  172. libx11-6:i386 \
  173. libxv1 \
  174. libxv1:i386 \
  175. libxtst6 \
  176. libxtst6:i386 \
  177. xdg-user-dirs \
  178. xdg-utils \
  179. dbus-user-session \
  180. dbus-x11 \
  181. libdbus-c++-1-0v5 \
  182. xkb-data \
  183. x11-xkb-utils \
  184. x11-xserver-utils \
  185. x11-utils \
  186. x11-apps \
  187. xauth \
  188. xbitmaps \
  189. xinit \
  190. xfonts-base \
  191. libxrandr-dev \
  192. # Install essential Xorg and NVIDIA packages, packages above this line should be the same between docker-nvidia-glx-desktop and docker-nvidia-egl-desktop
  193. kmod \
  194. libc6-dev \
  195. libc6:i386 \
  196. libpci3 \
  197. libelf-dev \
  198. xorg && \
  199. rm -rf /var/lib/apt/lists/* && \
  200. # Configure EGL manually
  201. mkdir -p /usr/share/glvnd/egl_vendor.d/ && \
  202. echo "{\n\
  203. \"file_format_version\" : \"1.0.0\",\n\
  204. \"ICD\": {\n\
  205. \"library_path\": \"libEGL_nvidia.so.0\"\n\
  206. }\n\
  207. }" > /usr/share/glvnd/egl_vendor.d/10_nvidia.json
  208. # Anything below this line should be always kept the same between docker-nvidia-glx-desktop and docker-nvidia-egl-desktop
  209. # Install KDE and other GUI packages
  210. ENV XDG_CURRENT_DESKTOP KDE
  211. ENV KWIN_COMPOSE N
  212. ENV KWIN_X11_NO_SYNC_TO_VBLANK 1
  213. # Use sudoedit to change protected files instead of using sudo on kate
  214. ENV SUDO_EDITOR kate
  215. RUN mkdir -pm755 /etc/apt/preferences.d && \
  216. echo "Package: firefox*\n\
  217. Pin: version 1:1snap*\n\
  218. Pin-Priority: -1" > /etc/apt/preferences.d/firefox-nosnap && \
  219. add-apt-repository -y ppa:mozillateam/ppa && \
  220. apt-get update && apt-get install --no-install-recommends -y \
  221. kde-plasma-desktop \
  222. adwaita-icon-theme-full \
  223. appmenu-gtk3-module \
  224. ark \
  225. aspell \
  226. aspell-en \
  227. breeze \
  228. breeze-cursor-theme \
  229. breeze-gtk-theme \
  230. breeze-icon-theme \
  231. debconf-kde-helper \
  232. desktop-file-utils \
  233. dolphin \
  234. dolphin-plugins \
  235. dbus-x11 \
  236. filelight \
  237. frameworkintegration \
  238. gwenview \
  239. haveged \
  240. hunspell \
  241. im-config \
  242. kate \
  243. kcalc \
  244. kcharselect \
  245. kdeadmin \
  246. kde-config-cddb \
  247. kde-config-gtk-style \
  248. kde-config-gtk-style-preview \
  249. kdeconnect \
  250. kdegraphics-thumbnailers \
  251. kdenetwork-filesharing \
  252. kde-spectacle \
  253. kdf \
  254. kdialog \
  255. kget \
  256. kimageformat-plugins \
  257. kinfocenter \
  258. kio \
  259. kio-extras \
  260. kmag \
  261. kmenuedit \
  262. kmix \
  263. kmousetool \
  264. kmouth \
  265. ksshaskpass \
  266. ktimer \
  267. kwin-addons \
  268. kwin-x11 \
  269. libgdk-pixbuf2.0-bin \
  270. muon \
  271. okular \
  272. okular-extra-backends \
  273. partitionmanager \
  274. plasma-browser-integration \
  275. plasma-dataengines-addons \
  276. plasma-discover \
  277. plasma-integration \
  278. plasma-runners-addons \
  279. plasma-widgets-addons \
  280. policykit-desktop-privileges \
  281. polkit-kde-agent-1 \
  282. print-manager \
  283. qapt-deb-installer \
  284. qml-module-org-kde-runnermodel \
  285. qml-module-org-kde-qqc2desktopstyle \
  286. qml-module-qtgraphicaleffects \
  287. qml-module-qtquick-xmllistmodel \
  288. qt5-image-formats-plugins \
  289. qtspeech5-flite-plugin \
  290. qtvirtualkeyboard-plugin \
  291. software-properties-qt \
  292. sonnet-plugins \
  293. sweeper \
  294. systemsettings \
  295. ubuntu-drivers-common \
  296. vlc \
  297. vlc-l10n \
  298. vlc-plugin-notify \
  299. vlc-plugin-samba \
  300. vlc-plugin-skins2 \
  301. vlc-plugin-video-splitter \
  302. vlc-plugin-visualization \
  303. xdg-desktop-portal-kde \
  304. xdg-user-dirs \
  305. firefox \
  306. pavucontrol-qt \
  307. transmission-qt && \
  308. apt-get install --install-recommends -y \
  309. libreoffice \
  310. libreoffice-kf5 \
  311. libreoffice-plasma \
  312. libreoffice-style-breeze && \
  313. rm -rf /var/lib/apt/lists/* && \
  314. # Fix KDE startup permissions issues in containers
  315. cp -f /usr/lib/x86_64-linux-gnu/libexec/kf5/start_kdeinit /tmp/ && \
  316. rm -f /usr/lib/x86_64-linux-gnu/libexec/kf5/start_kdeinit && \
  317. cp -r /tmp/start_kdeinit /usr/lib/x86_64-linux-gnu/libexec/kf5/start_kdeinit && \
  318. rm -f /tmp/start_kdeinit && \
  319. # Ensure Firefox is the default web browser
  320. update-alternatives --set x-www-browser /usr/bin/firefox
  321. # Wine, Winetricks, Lutris, and PlayOnLinux, this process must be consistent with https://wiki.winehq.org/Ubuntu
  322. ARG WINE_BRANCH=staging
  323. RUN mkdir -pm755 /etc/apt/keyrings && curl -fsSL -o /etc/apt/keyrings/winehq-archive.key "https://dl.winehq.org/wine-builds/winehq.key" && \
  324. 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" && \
  325. apt-get update && apt-get install --install-recommends -y \
  326. winehq-${WINE_BRANCH} && \
  327. apt-get install --no-install-recommends -y \
  328. q4wine \
  329. playonlinux && \
  330. LUTRIS_VERSION=$(curl -fsSL "https://api.github.com/repos/lutris/lutris/releases/latest" | jq -r '.tag_name' | sed 's/[^0-9\.\-]*//g') && \
  331. curl -fsSL -O "https://github.com/lutris/lutris/releases/download/v${LUTRIS_VERSION}/lutris_${LUTRIS_VERSION}_all.deb" && \
  332. apt-get install --no-install-recommends -y ./lutris_${LUTRIS_VERSION}_all.deb && rm -f "./lutris_${LUTRIS_VERSION}_all.deb" && \
  333. rm -rf /var/lib/apt/lists/* && \
  334. curl -fsSL -o /usr/bin/winetricks "https://raw.githubusercontent.com/Winetricks/winetricks/master/src/winetricks" && \
  335. chmod 755 /usr/bin/winetricks && \
  336. curl -fsSL -o /usr/share/bash-completion/completions/winetricks "https://raw.githubusercontent.com/Winetricks/winetricks/master/src/winetricks.bash-completion"
  337. # Install latest Selkies-GStreamer (https://github.com/selkies-project/selkies-gstreamer) build, Python application, and web application, should be consistent with selkies-gstreamer documentation
  338. RUN apt-get update && apt-get install --no-install-recommends -y \
  339. # GStreamer dependencies
  340. python3-pip \
  341. python3-dev \
  342. python3-gi \
  343. python3-setuptools \
  344. python3-wheel \
  345. udev \
  346. wmctrl \
  347. jq \
  348. gdebi-core \
  349. glib-networking \
  350. libopus0 \
  351. libgdk-pixbuf2.0-0 \
  352. libgtk2.0-bin \
  353. libgl-dev \
  354. libgles-dev \
  355. libglvnd-dev \
  356. libgudev-1.0-0 \
  357. xclip \
  358. x11-utils \
  359. xdotool \
  360. x11-xserver-utils \
  361. xserver-xorg-core \
  362. wayland-protocols \
  363. libwayland-dev \
  364. libwayland-egl-backend-dev \
  365. libx11-xcb1 \
  366. libxkbcommon0 \
  367. libxdamage1 \
  368. libxml2-dev \
  369. libwebrtc-audio-processing1 \
  370. libsrtp2-1 \
  371. libcairo-gobject2 \
  372. pulseaudio \
  373. libpulse0 \
  374. libpangocairo-1.0-0 \
  375. libgirepository1.0-dev \
  376. libjpeg-dev \
  377. libwebp-dev \
  378. libvpx-dev \
  379. zlib1g-dev \
  380. x264 \
  381. # AMD/Intel graphics driver dependencies
  382. va-driver-all \
  383. i965-va-driver-shaders \
  384. intel-media-va-driver-non-free \
  385. libmfx-tools \
  386. libva2 \
  387. vainfo \
  388. intel-gpu-tools \
  389. radeontop && \
  390. if [ "${UBUNTU_RELEASE}" \> "20.04" ]; then apt-get install --no-install-recommends -y xcvt; fi && \
  391. rm -rf /var/lib/apt/lists/* && \
  392. cd /opt && \
  393. # Automatically fetch the latest selkies-gstreamer version and install the components
  394. SELKIES_VERSION=$(curl -fsSL "https://api.github.com/repos/selkies-project/selkies-gstreamer/releases/latest" | jq -r '.tag_name' | sed 's/[^0-9\.\-]*//g') && \
  395. 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 - && \
  396. 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" && \
  397. curl -fsSL "https://github.com/selkies-project/selkies-gstreamer/releases/download/v${SELKIES_VERSION}/selkies-gstreamer-web-v${SELKIES_VERSION}.tgz" | tar -zxf - && \
  398. cd /usr/local/cuda/lib64 && sudo find . -maxdepth 1 -type l -name "*libnvrtc.so.*" -exec sh -c 'ln -snf $(basename {}) libnvrtc.so' \;
  399. # Install the noVNC web interface and the latest x11vnc for fallback
  400. RUN apt-get update && apt-get install --no-install-recommends -y \
  401. autoconf \
  402. automake \
  403. autotools-dev \
  404. chrpath \
  405. debhelper \
  406. git \
  407. jq \
  408. python3 \
  409. python3-numpy \
  410. libc6-dev \
  411. libcairo2-dev \
  412. libjpeg-turbo8-dev \
  413. libssl-dev \
  414. libv4l-dev \
  415. libvncserver-dev \
  416. libtool-bin \
  417. libxdamage-dev \
  418. libxinerama-dev \
  419. libxrandr-dev \
  420. libxss-dev \
  421. libxtst-dev \
  422. libavahi-client-dev && \
  423. rm -rf /var/lib/apt/lists/* && \
  424. # Build the latest x11vnc source to avoid various errors
  425. git clone "https://github.com/LibVNC/x11vnc.git" /tmp/x11vnc && \
  426. cd /tmp/x11vnc && autoreconf -fi && ./configure && make install && cd / && rm -rf /tmp/* && \
  427. curl -fsSL "https://github.com/novnc/noVNC/archive/v${NOVNC_VERSION}.tar.gz" | tar -xzf - -C /opt && \
  428. mv -f "/opt/noVNC-${NOVNC_VERSION}" /opt/noVNC && \
  429. ln -snf /opt/noVNC/vnc.html /opt/noVNC/index.html && \
  430. # Use the latest Websockify source to expose noVNC
  431. git clone "https://github.com/novnc/websockify.git" /opt/noVNC/utils/websockify
  432. # 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
  433. # Create user with password ${PASSWD} and assign adequate groups
  434. RUN apt-get update && apt-get install --no-install-recommends -y \
  435. sudo \
  436. tzdata && \
  437. rm -rf /var/lib/apt/lists/* && \
  438. groupadd -g 1000 user && \
  439. useradd -ms /bin/bash user -u 1000 -g 1000 && \
  440. 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 && \
  441. echo "user ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers && \
  442. chown user:user /home/user && \
  443. echo "user:${PASSWD}" | chpasswd && \
  444. ln -snf "/usr/share/zoneinfo/$TZ" /etc/localtime && echo "$TZ" > /etc/timezone
  445. # Copy scripts and configurations used to start the container
  446. COPY entrypoint.sh /etc/entrypoint.sh
  447. RUN chmod 755 /etc/entrypoint.sh
  448. COPY selkies-gstreamer-entrypoint.sh /etc/selkies-gstreamer-entrypoint.sh
  449. RUN chmod 755 /etc/selkies-gstreamer-entrypoint.sh
  450. COPY supervisord.conf /etc/supervisord.conf
  451. RUN chmod 755 /etc/supervisord.conf
  452. EXPOSE 8080
  453. USER user
  454. ENV SHELL /bin/bash
  455. ENV USER user
  456. WORKDIR /home/user
  457. ENTRYPOINT ["/usr/bin/supervisord"]