Dockerfile 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333
  1. # Ubuntu release versions 18.04 and 20.04 are supported
  2. ARG UBUNTU_RELEASE=20.04
  3. ARG CUDA_VERSION=11.2.2
  4. FROM nvcr.io/nvidia/cudagl:${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 PULSE_SERVER 127.0.0.1:4713
  19. ENV XDG_RUNTIME_DIR /tmp
  20. # Default environment variables (password is "mypasswd")
  21. ENV TZ UTC
  22. ENV SIZEW 1920
  23. ENV SIZEH 1080
  24. ENV REFRESH 60
  25. ENV DPI 96
  26. ENV CDEPTH 24
  27. ENV VIDEO_PORT DFP
  28. ENV PASSWD mypasswd
  29. ENV NOVNC_ENABLE false
  30. ENV WEBRTC_ENCODER nvh264enc
  31. ENV WEBRTC_ENABLE_RESIZE false
  32. ENV ENABLE_AUDIO true
  33. ENV ENABLE_BASIC_AUTH true
  34. # Set versions for components that should be manually checked before upgrading, other component versions are automatically determined by fetching the version online
  35. ARG NOVNC_VERSION=1.3.0
  36. # Install locales to prevent Xorg errors
  37. RUN apt-get clean && \
  38. apt-get update && apt-get install --no-install-recommends -y locales && \
  39. rm -rf /var/lib/apt/lists/* && \
  40. locale-gen en_US.UTF-8
  41. ENV LANG en_US.UTF-8
  42. ENV LANGUAGE en_US:en
  43. ENV LC_ALL en_US.UTF-8
  44. # Install Xorg, Xfce4 desktop environment, and other utility packages
  45. RUN dpkg --add-architecture i386 && \
  46. apt-get update && apt-get install --no-install-recommends -y \
  47. software-properties-common \
  48. apt-transport-https \
  49. apt-utils \
  50. build-essential \
  51. ca-certificates \
  52. kmod \
  53. libc6:i386 \
  54. libc6-dev \
  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. firefox \
  80. transmission-gtk \
  81. qpdfview \
  82. xarchiver \
  83. adwaita-icon-theme-full \
  84. brltty \
  85. brltty-x11 \
  86. desktop-file-utils \
  87. fonts-dejavu-core \
  88. fonts-freefont-ttf \
  89. fonts-noto \
  90. fonts-noto-cjk \
  91. fonts-noto-cjk-extra \
  92. fonts-noto-color-emoji \
  93. fonts-noto-hinted \
  94. fonts-noto-mono \
  95. fonts-opensymbol \
  96. fonts-symbola \
  97. fonts-ubuntu \
  98. gucharmap \
  99. mpd \
  100. onboard \
  101. parole \
  102. policykit-desktop-privileges \
  103. libpulse0 \
  104. pulseaudio \
  105. pavucontrol \
  106. ristretto \
  107. supervisor \
  108. thunar \
  109. thunar-volman \
  110. thunar-archive-plugin \
  111. thunar-media-tags-plugin \
  112. net-tools \
  113. libgtk-3-bin \
  114. libpci3 \
  115. libelf-dev \
  116. libglvnd-dev \
  117. vainfo \
  118. vdpauinfo \
  119. pkg-config \
  120. mesa-utils \
  121. mesa-utils-extra \
  122. mesa-va-drivers \
  123. mesa-vulkan-drivers \
  124. libvulkan-dev \
  125. libvulkan-dev:i386 \
  126. libglu1 \
  127. libglu1:i386 \
  128. libsm6 \
  129. libxv1 \
  130. libxv1:i386 \
  131. libxtst6 \
  132. libxtst6:i386 \
  133. xdg-utils \
  134. x11-xkb-utils \
  135. x11-xserver-utils \
  136. x11-utils \
  137. x11-apps \
  138. dbus-x11 \
  139. libdbus-c++-1-0v5 \
  140. dmz-cursor-theme \
  141. numlockx \
  142. xauth \
  143. xcursor-themes \
  144. xinit \
  145. xfonts-base \
  146. xkb-data \
  147. libxrandr-dev \
  148. xorg \
  149. xubuntu-artwork \
  150. xfburn \
  151. xfpanel-switch \
  152. xfce4 \
  153. xfdesktop4 \
  154. xfwm4 \
  155. xfce4-appfinder \
  156. xfce4-clipman \
  157. xfce4-dict \
  158. xfce4-goodies \
  159. xfce4-notes \
  160. xfce4-notifyd \
  161. xfce4-panel \
  162. xfce4-screenshooter \
  163. xfce4-session \
  164. xfce4-settings \
  165. xfce4-taskmanager \
  166. xfce4-terminal \
  167. xfce4-appmenu-plugin \
  168. xfce4-battery-plugin \
  169. xfce4-clipman-plugin \
  170. xfce4-cpufreq-plugin \
  171. xfce4-cpugraph-plugin \
  172. xfce4-diskperf-plugin \
  173. xfce4-datetime-plugin \
  174. xfce4-fsguard-plugin \
  175. xfce4-genmon-plugin \
  176. xfce4-indicator-plugin \
  177. xfce4-mpc-plugin \
  178. xfce4-mount-plugin \
  179. xfce4-netload-plugin \
  180. xfce4-notes-plugin \
  181. xfce4-places-plugin \
  182. xfce4-pulseaudio-plugin \
  183. xfce4-sensors-plugin \
  184. xfce4-smartbookmark-plugin \
  185. xfce4-statusnotifier-plugin \
  186. xfce4-systemload-plugin \
  187. xfce4-timer-plugin \
  188. xfce4-verve-plugin \
  189. xfce4-weather-plugin \
  190. xfce4-whiskermenu-plugin \
  191. xfce4-xkb-plugin && \
  192. # Install LibreOffice with the recommended packages
  193. apt-get install -y libreoffice && \
  194. # Prevent dialogs at desktop environment start
  195. cp -rf /etc/xdg/xfce4/panel/default.xml /etc/xdg/xfce4/xfconf/xfce-perchannel-xml/xfce4-panel.xml && \
  196. # Install Vulkan packages
  197. if [ "${UBUNTU_RELEASE}" = "18.04" ]; then apt-get install --no-install-recommends -y vulkan-utils; else apt-get install --no-install-recommends -y vulkan-tools; fi && \
  198. # Support decoding from libva or VA-API through NVIDIA VDPAU
  199. 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/* && \
  200. rm -rf /var/lib/apt/lists/*
  201. # Wine, Winetricks, Lutris, and PlayOnLinux, this process must be consistent with https://wiki.winehq.org/Ubuntu
  202. ARG WINE_BRANCH=staging
  203. RUN if [ "${UBUNTU_RELEASE}" = "18.04" ]; then add-apt-repository ppa:cybermax-dexter/sdl2-backport; fi && \
  204. mkdir -pm755 /etc/apt/keyrings && curl -fsSL -o /etc/apt/keyrings/winehq-archive.key "https://dl.winehq.org/wine-builds/winehq.key" && \
  205. 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" && \
  206. apt-get update && apt-get install --install-recommends -y \
  207. winehq-${WINE_BRANCH} && \
  208. apt-get update && apt-get install --no-install-recommends -y \
  209. q4wine \
  210. playonlinux && \
  211. LUTRIS_VERSION=$(curl -fsSL "https://api.github.com/repos/lutris/lutris/releases/latest" | jq -r '.tag_name' | sed 's/[^0-9\.\-]*//g') && \
  212. curl -fsSL -O "https://github.com/lutris/lutris/releases/download/v${LUTRIS_VERSION}/lutris_${LUTRIS_VERSION}_all.deb" && \
  213. apt-get update && apt-get install --no-install-recommends -y ./lutris_${LUTRIS_VERSION}_all.deb && rm -f "./lutris_${LUTRIS_VERSION}_all.deb" && \
  214. rm -rf /var/lib/apt/lists/* && \
  215. curl -fsSL -o /usr/bin/winetricks "https://raw.githubusercontent.com/Winetricks/winetricks/master/src/winetricks" && \
  216. chmod 755 /usr/bin/winetricks && \
  217. curl -fsSL -o /usr/share/bash-completion/completions/winetricks "https://raw.githubusercontent.com/Winetricks/winetricks/master/src/winetricks.bash-completion"
  218. # Install latest selkies-gstreamer (https://github.com/selkies-project/selkies-gstreamer) build, Python application, and web application, should be consistent with selkies-gstreamer documentation
  219. RUN apt-get update && apt-get install --no-install-recommends -y \
  220. build-essential \
  221. python3-pip \
  222. python3-dev \
  223. python3-gi \
  224. python3-setuptools \
  225. python3-wheel \
  226. tzdata \
  227. sudo \
  228. udev \
  229. xclip \
  230. x11-utils \
  231. xdotool \
  232. wmctrl \
  233. jq \
  234. gdebi-core \
  235. x11-xserver-utils \
  236. xserver-xorg-core \
  237. libopus0 \
  238. libgdk-pixbuf2.0-0 \
  239. libsrtp2-1 \
  240. libxdamage1 \
  241. libxml2-dev \
  242. libwebrtc-audio-processing1 \
  243. libcairo-gobject2 \
  244. pulseaudio \
  245. libpulse0 \
  246. libpangocairo-1.0-0 \
  247. libgirepository1.0-dev \
  248. libjpeg-dev \
  249. libvpx-dev \
  250. zlib1g-dev \
  251. x264 && \
  252. if [ "${UBUNTU_RELEASE}" \> "20.04" ]; then apt-get install --no-install-recommends -y xcvt; fi && \
  253. rm -rf /var/lib/apt/lists/* && \
  254. cd /opt && \
  255. # Automatically fetch the latest selkies-gstreamer version and install the components
  256. SELKIES_VERSION=$(curl -fsSL "https://api.github.com/repos/selkies-project/selkies-gstreamer/releases/latest" | jq -r '.tag_name' | sed 's/[^0-9\.\-]*//g') && \
  257. 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 - && \
  258. 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" && \
  259. if [ "${UBUNTU_RELEASE}" \> "18.04" ]; then pip3 install --upgrade --no-deps --force-reinstall "https://github.com/python-xlib/python-xlib/archive/e8cf018.zip"; fi && \
  260. curl -fsSL "https://github.com/selkies-project/selkies-gstreamer/releases/download/v${SELKIES_VERSION}/selkies-gstreamer-web-v${SELKIES_VERSION}.tgz" | tar -zxf - && \
  261. cd /usr/local/cuda/lib64 && sudo find . -maxdepth 1 -type l -name "*libnvrtc.so.*" -exec sh -c 'ln -sf $(basename {}) libnvrtc.so' \;
  262. # Install the noVNC web interface and the latest x11vnc for fallback
  263. RUN apt-get update && apt-get install --no-install-recommends -y \
  264. autoconf \
  265. automake \
  266. autotools-dev \
  267. chrpath \
  268. debhelper \
  269. git \
  270. jq \
  271. python3 \
  272. python3-numpy \
  273. libc6-dev \
  274. libcairo2-dev \
  275. libjpeg-turbo8-dev \
  276. libssl-dev \
  277. libv4l-dev \
  278. libvncserver-dev \
  279. libtool-bin \
  280. libxdamage-dev \
  281. libxinerama-dev \
  282. libxrandr-dev \
  283. libxss-dev \
  284. libxtst-dev \
  285. libavahi-client-dev && \
  286. rm -rf /var/lib/apt/lists/* && \
  287. # Build the latest x11vnc source to avoid various errors
  288. git clone "https://github.com/LibVNC/x11vnc.git" /tmp/x11vnc && \
  289. cd /tmp/x11vnc && autoreconf -fi && ./configure && make install && cd / && rm -rf /tmp/* && \
  290. curl -fsSL "https://github.com/novnc/noVNC/archive/v${NOVNC_VERSION}.tar.gz" | tar -xzf - -C /opt && \
  291. mv -f "/opt/noVNC-${NOVNC_VERSION}" /opt/noVNC && \
  292. ln -s /opt/noVNC/vnc.html /opt/noVNC/index.html && \
  293. # Use the latest Websockify source to expose noVNC
  294. git clone "https://github.com/novnc/websockify.git" /opt/noVNC/utils/websockify
  295. # Add custom packages below this comment, or use FROM in a new container and replace entrypoint.sh or supervisord.conf, and set ENTRYPOINT to /usr/bin/supervisord
  296. # Create user with password ${PASSWD} and assign adequate groups
  297. RUN apt-get update && apt-get install --no-install-recommends -y \
  298. sudo && \
  299. rm -rf /var/lib/apt/lists/* && \
  300. groupadd -g 1000 user && \
  301. useradd -ms /bin/bash user -u 1000 -g 1000 && \
  302. usermod -a -G adm,audio,cdrom,dialout,dip,fax,floppy,input,lp,lpadmin,plugdev,scanner,sudo,tape,tty,video,voice user && \
  303. echo "user ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers && \
  304. chown user:user /home/user && \
  305. echo "user:${PASSWD}" | chpasswd && \
  306. ln -snf "/usr/share/zoneinfo/$TZ" /etc/localtime && echo "$TZ" > /etc/timezone
  307. # Copy scripts and configurations used to start the container
  308. COPY entrypoint.sh /etc/entrypoint.sh
  309. RUN chmod 755 /etc/entrypoint.sh
  310. COPY selkies-gstreamer-entrypoint.sh /etc/selkies-gstreamer-entrypoint.sh
  311. RUN chmod 755 /etc/selkies-gstreamer-entrypoint.sh
  312. COPY supervisord.conf /etc/supervisord.conf
  313. RUN chmod 755 /etc/supervisord.conf
  314. EXPOSE 8080
  315. USER user
  316. ENV USER=user
  317. WORKDIR /home/user
  318. ENTRYPOINT ["/usr/bin/supervisord"]