Dockerfile 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481
  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. fcitx \
  238. fcitx-tools \
  239. filelight \
  240. frameworkintegration \
  241. gwenview \
  242. haveged \
  243. hunspell \
  244. im-config \
  245. kate \
  246. kcalc \
  247. kcharselect \
  248. kdeadmin \
  249. kde-config-fcitx \
  250. kde-config-gtk-style \
  251. kde-config-gtk-style-preview \
  252. kdeconnect \
  253. kdegraphics-thumbnailers \
  254. kde-spectacle \
  255. kdf \
  256. kdialog \
  257. kget \
  258. kimageformat-plugins \
  259. kinfocenter \
  260. kio \
  261. kio-extras \
  262. kmag \
  263. kmenuedit \
  264. kmix \
  265. kmousetool \
  266. kmouth \
  267. ksshaskpass \
  268. ktimer \
  269. kwin-addons \
  270. kwin-x11 \
  271. libgdk-pixbuf2.0-bin \
  272. libgtk2.0-bin \
  273. libgtk-3-bin \
  274. okular \
  275. okular-extra-backends \
  276. partitionmanager \
  277. plasma-browser-integration \
  278. plasma-calendar-addons \
  279. plasma-dataengines-addons \
  280. plasma-discover \
  281. plasma-integration \
  282. plasma-runners-addons \
  283. plasma-widgets-addons \
  284. policykit-desktop-privileges \
  285. polkit-kde-agent-1 \
  286. print-manager \
  287. qapt-deb-installer \
  288. qml-module-org-kde-runnermodel \
  289. qml-module-org-kde-qqc2desktopstyle \
  290. qml-module-qtgraphicaleffects \
  291. qml-module-qtquick-xmllistmodel \
  292. qt5-gtk-platformtheme \
  293. qt5-image-formats-plugins \
  294. qt5-style-plugins \
  295. qtspeech5-flite-plugin \
  296. qtvirtualkeyboard-plugin \
  297. software-properties-qt \
  298. sonnet-plugins \
  299. sweeper \
  300. systemsettings \
  301. ubuntu-drivers-common \
  302. vlc \
  303. vlc-l10n \
  304. vlc-plugin-notify \
  305. vlc-plugin-samba \
  306. vlc-plugin-skins2 \
  307. vlc-plugin-video-splitter \
  308. vlc-plugin-visualization \
  309. xdg-desktop-portal-kde \
  310. xdg-user-dirs \
  311. firefox \
  312. pavucontrol-qt \
  313. transmission-qt && \
  314. apt-get install --install-recommends -y \
  315. libreoffice \
  316. libreoffice-kf5 \
  317. libreoffice-plasma \
  318. libreoffice-style-breeze && \
  319. rm -rf /var/lib/apt/lists/* && \
  320. # Fix KDE startup permissions issues in containers
  321. cp -f /usr/lib/x86_64-linux-gnu/libexec/kf5/start_kdeinit /tmp/ && \
  322. rm -f /usr/lib/x86_64-linux-gnu/libexec/kf5/start_kdeinit && \
  323. cp -r /tmp/start_kdeinit /usr/lib/x86_64-linux-gnu/libexec/kf5/start_kdeinit && \
  324. rm -f /tmp/start_kdeinit && \
  325. # Ensure Firefox is the default web browser
  326. update-alternatives --set x-www-browser /usr/bin/firefox
  327. # Wine, Winetricks, Lutris, and PlayOnLinux, this process must be consistent with https://wiki.winehq.org/Ubuntu
  328. ARG WINE_BRANCH=staging
  329. RUN mkdir -pm755 /etc/apt/keyrings && curl -fsSL -o /etc/apt/keyrings/winehq-archive.key "https://dl.winehq.org/wine-builds/winehq.key" && \
  330. 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" && \
  331. apt-get update && apt-get install --install-recommends -y \
  332. winehq-${WINE_BRANCH} && \
  333. apt-get install --no-install-recommends -y \
  334. q4wine \
  335. playonlinux && \
  336. LUTRIS_VERSION=$(curl -fsSL "https://api.github.com/repos/lutris/lutris/releases/latest" | jq -r '.tag_name' | sed 's/[^0-9\.\-]*//g') && \
  337. curl -fsSL -O "https://github.com/lutris/lutris/releases/download/v${LUTRIS_VERSION}/lutris_${LUTRIS_VERSION}_all.deb" && \
  338. apt-get install --no-install-recommends -y ./lutris_${LUTRIS_VERSION}_all.deb && rm -f "./lutris_${LUTRIS_VERSION}_all.deb" && \
  339. rm -rf /var/lib/apt/lists/* && \
  340. curl -fsSL -o /usr/bin/winetricks "https://raw.githubusercontent.com/Winetricks/winetricks/master/src/winetricks" && \
  341. chmod 755 /usr/bin/winetricks && \
  342. curl -fsSL -o /usr/share/bash-completion/completions/winetricks "https://raw.githubusercontent.com/Winetricks/winetricks/master/src/winetricks.bash-completion"
  343. # Install latest Selkies-GStreamer (https://github.com/selkies-project/selkies-gstreamer) build, Python application, and web application, should be consistent with selkies-gstreamer documentation
  344. RUN apt-get update && apt-get install --no-install-recommends -y \
  345. # GStreamer dependencies
  346. python3-pip \
  347. python3-dev \
  348. python3-gi \
  349. python3-setuptools \
  350. python3-wheel \
  351. udev \
  352. wmctrl \
  353. jq \
  354. gdebi-core \
  355. glib-networking \
  356. libopus0 \
  357. libgdk-pixbuf2.0-0 \
  358. libgtk2.0-bin \
  359. libgl-dev \
  360. libgles-dev \
  361. libglvnd-dev \
  362. libgudev-1.0-0 \
  363. xclip \
  364. x11-utils \
  365. xdotool \
  366. x11-xserver-utils \
  367. xserver-xorg-core \
  368. wayland-protocols \
  369. libwayland-dev \
  370. libwayland-egl-backend-dev \
  371. libx11-xcb1 \
  372. libxkbcommon0 \
  373. libxdamage1 \
  374. libxml2-dev \
  375. libwebrtc-audio-processing1 \
  376. libsrtp2-1 \
  377. libcairo-gobject2 \
  378. pulseaudio \
  379. libpulse0 \
  380. libpangocairo-1.0-0 \
  381. libgirepository1.0-dev \
  382. libjpeg-dev \
  383. libwebp-dev \
  384. libvpx-dev \
  385. zlib1g-dev \
  386. x264 \
  387. # AMD/Intel graphics driver dependencies
  388. va-driver-all \
  389. i965-va-driver-shaders \
  390. intel-media-va-driver-non-free \
  391. libmfx-tools \
  392. libva2 \
  393. vainfo \
  394. intel-gpu-tools \
  395. radeontop && \
  396. if [ "${UBUNTU_RELEASE}" \> "20.04" ]; then apt-get install --no-install-recommends -y xcvt; fi && \
  397. rm -rf /var/lib/apt/lists/* && \
  398. cd /opt && \
  399. # Automatically fetch the latest selkies-gstreamer version and install the components
  400. SELKIES_VERSION=$(curl -fsSL "https://api.github.com/repos/selkies-project/selkies-gstreamer/releases/latest" | jq -r '.tag_name' | sed 's/[^0-9\.\-]*//g') && \
  401. 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 - && \
  402. 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" && \
  403. curl -fsSL "https://github.com/selkies-project/selkies-gstreamer/releases/download/v${SELKIES_VERSION}/selkies-gstreamer-web-v${SELKIES_VERSION}.tgz" | tar -zxf - && \
  404. cd /usr/local/cuda/lib64 && sudo find . -maxdepth 1 -type l -name "*libnvrtc.so.*" -exec sh -c 'ln -snf $(basename {}) libnvrtc.so' \;
  405. # Install the noVNC web interface and the latest x11vnc for fallback
  406. RUN apt-get update && apt-get install --no-install-recommends -y \
  407. autoconf \
  408. automake \
  409. autotools-dev \
  410. chrpath \
  411. debhelper \
  412. git \
  413. jq \
  414. python3 \
  415. python3-numpy \
  416. libc6-dev \
  417. libcairo2-dev \
  418. libjpeg-turbo8-dev \
  419. libssl-dev \
  420. libv4l-dev \
  421. libvncserver-dev \
  422. libtool-bin \
  423. libxdamage-dev \
  424. libxinerama-dev \
  425. libxrandr-dev \
  426. libxss-dev \
  427. libxtst-dev \
  428. libavahi-client-dev && \
  429. rm -rf /var/lib/apt/lists/* && \
  430. # Build the latest x11vnc source to avoid various errors
  431. git clone "https://github.com/LibVNC/x11vnc.git" /tmp/x11vnc && \
  432. cd /tmp/x11vnc && autoreconf -fi && ./configure && make install && cd / && rm -rf /tmp/* && \
  433. curl -fsSL "https://github.com/novnc/noVNC/archive/v${NOVNC_VERSION}.tar.gz" | tar -xzf - -C /opt && \
  434. mv -f "/opt/noVNC-${NOVNC_VERSION}" /opt/noVNC && \
  435. ln -snf /opt/noVNC/vnc.html /opt/noVNC/index.html && \
  436. # Use the latest Websockify source to expose noVNC
  437. git clone "https://github.com/novnc/websockify.git" /opt/noVNC/utils/websockify
  438. # 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
  439. # Create user with password ${PASSWD} and assign adequate groups
  440. RUN apt-get update && apt-get install --no-install-recommends -y \
  441. sudo \
  442. tzdata && \
  443. rm -rf /var/lib/apt/lists/* && \
  444. groupadd -g 1000 user && \
  445. useradd -ms /bin/bash user -u 1000 -g 1000 && \
  446. 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 && \
  447. echo "user ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers && \
  448. chown user:user /home/user && \
  449. echo "user:${PASSWD}" | chpasswd && \
  450. ln -snf "/usr/share/zoneinfo/$TZ" /etc/localtime && echo "$TZ" > /etc/timezone
  451. # Copy scripts and configurations used to start the container
  452. COPY entrypoint.sh /etc/entrypoint.sh
  453. RUN chmod 755 /etc/entrypoint.sh
  454. COPY selkies-gstreamer-entrypoint.sh /etc/selkies-gstreamer-entrypoint.sh
  455. RUN chmod 755 /etc/selkies-gstreamer-entrypoint.sh
  456. COPY supervisord.conf /etc/supervisord.conf
  457. RUN chmod 755 /etc/supervisord.conf
  458. EXPOSE 8080
  459. USER user
  460. ENV SHELL /bin/bash
  461. ENV USER user
  462. WORKDIR /home/user
  463. ENTRYPOINT ["/usr/bin/supervisord"]