Dockerfile 11 KB

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