Dockerfile 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389
  1. # Ubuntu release versions 22.04, 20.04, and 18.04 are supported
  2. ARG UBUNTU_RELEASE=22.04
  3. ARG CUDA_VERSION=11.7.1
  4. FROM nvcr.io/nvidia/cuda:${CUDA_VERSION}-runtime-ubuntu${UBUNTU_RELEASE}
  5. LABEL maintainer "https://github.com/ehfd,https://github.com/danisla"
  6. ARG UBUNTU_RELEASE
  7. ARG CUDA_VERSION
  8. # Make all NVIDIA GPUs visible by default
  9. ARG NVIDIA_VISIBLE_DEVICES=all
  10. # Use noninteractive mode to skip confirmation when installing packages
  11. ARG DEBIAN_FRONTEND=noninteractive
  12. # All NVIDIA driver capabilities should preferably be used, check `NVIDIA_DRIVER_CAPABILITIES` inside the container if things do not work
  13. ENV NVIDIA_DRIVER_CAPABILITIES all
  14. # Enable AppImage execution in a container
  15. ENV APPIMAGE_EXTRACT_AND_RUN 1
  16. # System defaults that should not be changed
  17. ENV DISPLAY :0
  18. ENV XDG_RUNTIME_DIR /tmp/runtime-user
  19. ENV PULSE_SERVER unix:/run/pulse/native
  20. ENV LD_LIBRARY_PATH /usr/lib/x86_64-linux-gnu:/usr/lib/i386-linux-gnu${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
  21. # Default environment variables (password is "mypasswd")
  22. ENV TZ UTC
  23. ENV SIZEW 1920
  24. ENV SIZEH 1080
  25. ENV REFRESH 60
  26. ENV DPI 96
  27. ENV CDEPTH 24
  28. ENV VIDEO_PORT DFP
  29. ENV PASSWD mypasswd
  30. ENV NOVNC_ENABLE false
  31. ENV WEBRTC_ENCODER nvh264enc
  32. ENV WEBRTC_ENABLE_RESIZE false
  33. ENV ENABLE_AUDIO true
  34. ENV ENABLE_BASIC_AUTH true
  35. # Set versions for components that should be manually checked before upgrading, other component versions are automatically determined by fetching the version online
  36. ARG NOVNC_VERSION=1.3.0
  37. # Install locales to prevent X11 errors
  38. RUN apt-get clean && \
  39. apt-get update && apt-get install --no-install-recommends -y locales && \
  40. rm -rf /var/lib/apt/lists/* && \
  41. locale-gen en_US.UTF-8
  42. ENV LANG en_US.UTF-8
  43. ENV LANGUAGE en_US:en
  44. ENV LC_ALL en_US.UTF-8
  45. # Install Xorg and other important libraries or packages
  46. RUN dpkg --add-architecture i386 && \
  47. apt-get update && apt-get install --no-install-recommends -y \
  48. software-properties-common \
  49. alsa-base \
  50. alsa-utils \
  51. apt-transport-https \
  52. apt-utils \
  53. build-essential \
  54. ca-certificates \
  55. cups-filters \
  56. cups-common \
  57. cups-pdf \
  58. curl \
  59. file \
  60. wget \
  61. bzip2 \
  62. gzip \
  63. p7zip-full \
  64. xz-utils \
  65. zip \
  66. unzip \
  67. zstd \
  68. gcc \
  69. git \
  70. jq \
  71. make \
  72. python3 \
  73. python3-cups \
  74. python3-numpy \
  75. mlocate \
  76. nano \
  77. vim \
  78. htop \
  79. fonts-dejavu-core \
  80. fonts-freefont-ttf \
  81. fonts-noto \
  82. fonts-noto-cjk \
  83. fonts-noto-cjk-extra \
  84. fonts-noto-color-emoji \
  85. fonts-noto-hinted \
  86. fonts-noto-mono \
  87. fonts-opensymbol \
  88. fonts-symbola \
  89. fonts-ubuntu \
  90. libpulse0 \
  91. pulseaudio \
  92. supervisor \
  93. net-tools \
  94. libglvnd-dev \
  95. libglvnd-dev:i386 \
  96. libgl1-mesa-dev \
  97. libgl1-mesa-dev:i386 \
  98. libegl1-mesa-dev \
  99. libegl1-mesa-dev:i386 \
  100. libgles2-mesa-dev \
  101. libgles2-mesa-dev:i386 \
  102. libglvnd0 \
  103. libglvnd0:i386 \
  104. libgl1 \
  105. libgl1:i386 \
  106. libglx0 \
  107. libglx0:i386 \
  108. libegl1 \
  109. libegl1:i386 \
  110. libgles2 \
  111. libgles2:i386 \
  112. libglu1 \
  113. libglu1:i386 \
  114. libsm6 \
  115. libsm6:i386 \
  116. vainfo \
  117. vdpauinfo \
  118. pkg-config \
  119. mesa-utils \
  120. mesa-utils-extra \
  121. va-driver-all \
  122. xserver-xorg-input-all \
  123. xserver-xorg-video-all \
  124. mesa-vulkan-drivers \
  125. libvulkan-dev \
  126. libvulkan-dev:i386 \
  127. libxau6 \
  128. libxau6:i386 \
  129. libxdmcp6 \
  130. libxdmcp6:i386 \
  131. libxcb1 \
  132. libxcb1:i386 \
  133. libxext6 \
  134. libxext6:i386 \
  135. libx11-6 \
  136. libx11-6:i386 \
  137. libxv1 \
  138. libxv1:i386 \
  139. libxtst6 \
  140. libxtst6:i386 \
  141. xdg-utils \
  142. dbus-x11 \
  143. libdbus-c++-1-0v5 \
  144. xkb-data \
  145. x11-xkb-utils \
  146. x11-xserver-utils \
  147. x11-utils \
  148. x11-apps \
  149. xauth \
  150. xbitmaps \
  151. xinit \
  152. xfonts-base \
  153. libxrandr-dev \
  154. # Install essential Xorg and NVIDIA packages, packages above this line should be the same between docker-nvidia-glx-desktop and docker-nvidia-egl-desktop
  155. kmod \
  156. libc6-dev \
  157. libc6:i386 \
  158. libpci3 \
  159. libelf-dev \
  160. xorg && \
  161. # Install Vulkan utilities
  162. if [ "${UBUNTU_RELEASE}" \< "20.04" ]; then apt-get install --no-install-recommends -y vulkan-utils; else apt-get install --no-install-recommends -y vulkan-tools; fi && \
  163. # Support decoding from libva or VA-API through NVIDIA VDPAU
  164. curl -fsSL -o /tmp/vdpau-va-driver.deb "https://launchpad.net/~saiarcot895/+archive/ubuntu/chromium-dev/+files/vdpau-va-driver_0.7.4-6ubuntu2~ppa1~18.04.1_amd64.deb" && apt-get install --no-install-recommends -y /tmp/vdpau-va-driver.deb && rm -rf /tmp/* && \
  165. rm -rf /var/lib/apt/lists/* && \
  166. # Configure EGL manually
  167. mkdir -p /usr/share/glvnd/egl_vendor.d/ && \
  168. echo "{\n\
  169. \"file_format_version\" : \"1.0.0\",\n\
  170. \"ICD\": {\n\
  171. \"library_path\": \"libEGL_nvidia.so.0\"\n\
  172. }\n\
  173. }" > /usr/share/glvnd/egl_vendor.d/10_nvidia.json
  174. # Anything below this line should be always kept the same between docker-nvidia-glx-desktop and docker-nvidia-egl-desktop
  175. # Install KDE and other GUI packages
  176. ENV XDG_CURRENT_DESKTOP KDE
  177. ENV KWIN_COMPOSE N
  178. # Use sudoedit to change protected files instead of using sudo on kate
  179. ENV SUDO_EDITOR kate
  180. RUN mkdir -pm755 /etc/apt/preferences.d && \
  181. echo "Package: firefox*\n\
  182. Pin: release o=Ubuntu*\n\
  183. Pin-Priority: -1" > /etc/apt/preferences.d/firefox-ppa && \
  184. add-apt-repository -y ppa:mozillateam/ppa && \
  185. apt-get update && apt-get install --no-install-recommends -y \
  186. kde-plasma-desktop \
  187. kwin-addons \
  188. kwin-x11 \
  189. kdeadmin \
  190. akregator \
  191. ark \
  192. baloo-kf5 \
  193. breeze-cursor-theme \
  194. breeze-icon-theme \
  195. debconf-kde-helper \
  196. colord-kde \
  197. desktop-file-utils \
  198. filelight \
  199. gwenview \
  200. hspell \
  201. kaddressbook \
  202. kaffeine \
  203. kate \
  204. kcalc \
  205. kcharselect \
  206. kdeconnect \
  207. kde-spectacle \
  208. kdf \
  209. kget \
  210. kgpg \
  211. khelpcenter \
  212. khotkeys \
  213. kimageformat-plugins \
  214. kinfocenter \
  215. kio-extras \
  216. kleopatra \
  217. kmail \
  218. kmenuedit \
  219. kmix \
  220. knotes \
  221. kontact \
  222. kopete \
  223. korganizer \
  224. krdc \
  225. ktimer \
  226. kwalletmanager \
  227. okular \
  228. okular-extra-backends \
  229. plasma-dataengines-addons \
  230. plasma-discover \
  231. plasma-runners-addons \
  232. plasma-wallpapers-addons \
  233. plasma-widgets-addons \
  234. plasma-workspace-wallpapers \
  235. qtvirtualkeyboard-plugin \
  236. sonnet-plugins \
  237. sweeper \
  238. systemsettings \
  239. xdg-desktop-portal-kde \
  240. kubuntu-restricted-extras \
  241. kubuntu-wallpapers \
  242. firefox \
  243. transmission-qt && \
  244. apt-get update && apt-get install -y \
  245. libreoffice \
  246. libreoffice-kf5 \
  247. libreoffice-plasma \
  248. libreoffice-style-breeze && \
  249. rm -rf /var/lib/apt/lists/* && \
  250. # Fix KDE startup permissions issues in containers
  251. cp -f /usr/lib/x86_64-linux-gnu/libexec/kf5/start_kdeinit /tmp/ && \
  252. rm -f /usr/lib/x86_64-linux-gnu/libexec/kf5/start_kdeinit && \
  253. cp -r /tmp/start_kdeinit /usr/lib/x86_64-linux-gnu/libexec/kf5/start_kdeinit && \
  254. rm -f /tmp/start_kdeinit
  255. # Wine, Winetricks, Lutris, and PlayOnLinux, this process must be consistent with https://wiki.winehq.org/Ubuntu
  256. ARG WINE_BRANCH=staging
  257. RUN if [ "${UBUNTU_RELEASE}" \< "20.04" ]; then add-apt-repository -y ppa:cybermax-dexter/sdl2-backport; fi && \
  258. mkdir -pm755 /etc/apt/keyrings && curl -fsSL -o /etc/apt/keyrings/winehq-archive.key "https://dl.winehq.org/wine-builds/winehq.key" && \
  259. 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" && \
  260. apt-get update && apt-get install --install-recommends -y \
  261. winehq-${WINE_BRANCH} && \
  262. apt-get update && apt-get install --no-install-recommends -y \
  263. q4wine \
  264. playonlinux && \
  265. LUTRIS_VERSION=$(curl -fsSL "https://api.github.com/repos/lutris/lutris/releases/latest" | jq -r '.tag_name' | sed 's/[^0-9\.\-]*//g') && \
  266. curl -fsSL -O "https://github.com/lutris/lutris/releases/download/v${LUTRIS_VERSION}/lutris_${LUTRIS_VERSION}_all.deb" && \
  267. apt-get update && apt-get install --no-install-recommends -y ./lutris_${LUTRIS_VERSION}_all.deb && rm -f "./lutris_${LUTRIS_VERSION}_all.deb" && \
  268. rm -rf /var/lib/apt/lists/* && \
  269. curl -fsSL -o /usr/bin/winetricks "https://raw.githubusercontent.com/Winetricks/winetricks/master/src/winetricks" && \
  270. chmod 755 /usr/bin/winetricks && \
  271. curl -fsSL -o /usr/share/bash-completion/completions/winetricks "https://raw.githubusercontent.com/Winetricks/winetricks/master/src/winetricks.bash-completion"
  272. # Install latest selkies-gstreamer (https://github.com/selkies-project/selkies-gstreamer) build, Python application, and web application, should be consistent with selkies-gstreamer documentation
  273. RUN apt-get update && apt-get install --no-install-recommends -y \
  274. build-essential \
  275. python3-pip \
  276. python3-dev \
  277. python3-gi \
  278. python3-setuptools \
  279. python3-wheel \
  280. tzdata \
  281. sudo \
  282. udev \
  283. xclip \
  284. x11-utils \
  285. xdotool \
  286. wmctrl \
  287. jq \
  288. gdebi-core \
  289. x11-xserver-utils \
  290. xserver-xorg-core \
  291. libopus0 \
  292. libgdk-pixbuf2.0-0 \
  293. libsrtp2-1 \
  294. libxdamage1 \
  295. libxml2-dev \
  296. libwebrtc-audio-processing1 \
  297. libcairo-gobject2 \
  298. pulseaudio \
  299. libpulse0 \
  300. libpangocairo-1.0-0 \
  301. libgirepository1.0-dev \
  302. libjpeg-dev \
  303. libvpx-dev \
  304. zlib1g-dev \
  305. x264 && \
  306. if [ "${UBUNTU_RELEASE}" \> "20.04" ]; then apt-get install --no-install-recommends -y xcvt; fi && \
  307. rm -rf /var/lib/apt/lists/* && \
  308. cd /opt && \
  309. # Automatically fetch the latest selkies-gstreamer version and install the components
  310. SELKIES_VERSION=$(curl -fsSL "https://api.github.com/repos/selkies-project/selkies-gstreamer/releases/latest" | jq -r '.tag_name' | sed 's/[^0-9\.\-]*//g') && \
  311. 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 - && \
  312. 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" && \
  313. curl -fsSL "https://github.com/selkies-project/selkies-gstreamer/releases/download/v${SELKIES_VERSION}/selkies-gstreamer-web-v${SELKIES_VERSION}.tgz" | tar -zxf - && \
  314. cd /usr/local/cuda/lib64 && sudo find . -maxdepth 1 -type l -name "*libnvrtc.so.*" -exec sh -c 'ln -snf $(basename {}) libnvrtc.so' \;
  315. # Install the noVNC web interface and the latest x11vnc for fallback
  316. RUN apt-get update && apt-get install --no-install-recommends -y \
  317. autoconf \
  318. automake \
  319. autotools-dev \
  320. chrpath \
  321. debhelper \
  322. git \
  323. jq \
  324. python3 \
  325. python3-numpy \
  326. libc6-dev \
  327. libcairo2-dev \
  328. libjpeg-turbo8-dev \
  329. libssl-dev \
  330. libv4l-dev \
  331. libvncserver-dev \
  332. libtool-bin \
  333. libxdamage-dev \
  334. libxinerama-dev \
  335. libxrandr-dev \
  336. libxss-dev \
  337. libxtst-dev \
  338. libavahi-client-dev && \
  339. rm -rf /var/lib/apt/lists/* && \
  340. # Build the latest x11vnc source to avoid various errors
  341. git clone "https://github.com/LibVNC/x11vnc.git" /tmp/x11vnc && \
  342. cd /tmp/x11vnc && autoreconf -fi && ./configure && make install && cd / && rm -rf /tmp/* && \
  343. curl -fsSL "https://github.com/novnc/noVNC/archive/v${NOVNC_VERSION}.tar.gz" | tar -xzf - -C /opt && \
  344. mv -f "/opt/noVNC-${NOVNC_VERSION}" /opt/noVNC && \
  345. ln -snf /opt/noVNC/vnc.html /opt/noVNC/index.html && \
  346. # Use the latest Websockify source to expose noVNC
  347. git clone "https://github.com/novnc/websockify.git" /opt/noVNC/utils/websockify
  348. # 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
  349. # Create user with password ${PASSWD} and assign adequate groups
  350. RUN apt-get update && apt-get install --no-install-recommends -y \
  351. sudo && \
  352. rm -rf /var/lib/apt/lists/* && \
  353. groupadd -g 1000 user && \
  354. useradd -ms /bin/bash user -u 1000 -g 1000 && \
  355. usermod -a -G adm,audio,cdrom,dialout,dip,fax,floppy,input,lp,lpadmin,plugdev,pulse-access,scanner,sudo,tape,tty,video,voice user && \
  356. echo "user ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers && \
  357. chown user:user /home/user && \
  358. echo "user:${PASSWD}" | chpasswd && \
  359. ln -snf "/usr/share/zoneinfo/$TZ" /etc/localtime && echo "$TZ" > /etc/timezone
  360. # Copy scripts and configurations used to start the container
  361. COPY entrypoint.sh /etc/entrypoint.sh
  362. RUN chmod 755 /etc/entrypoint.sh
  363. COPY selkies-gstreamer-entrypoint.sh /etc/selkies-gstreamer-entrypoint.sh
  364. RUN chmod 755 /etc/selkies-gstreamer-entrypoint.sh
  365. COPY supervisord.conf /etc/supervisord.conf
  366. RUN chmod 755 /etc/supervisord.conf
  367. EXPOSE 8080
  368. USER user
  369. ENV SHELL /bin/bash
  370. ENV USER user
  371. WORKDIR /home/user
  372. ENTRYPOINT ["/usr/bin/supervisord"]