Dockerfile 12 KB

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