Dockerfile 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  1. # Ubuntu release versions 18.04 and 20.04 are supported
  2. ARG UBUNTU_RELEASE=20.04
  3. ARG CUDA_VERSION=11.4.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, but we want to manually install drivers
  9. ARG NVIDIA_VISIBLE_DEVICES=all
  10. # Supress interactive menu while installing keyboard-configuration
  11. ARG DEBIAN_FRONTEND=noninteractive
  12. ENV NVIDIA_DRIVER_CAPABILITIES all
  13. ENV PULSE_SERVER 127.0.0.1:4713
  14. # Default environment variables (password is "mypasswd")
  15. ENV TZ UTC
  16. ENV SIZEW 1920
  17. ENV SIZEH 1080
  18. ENV REFRESH 60
  19. ENV DPI 96
  20. ENV CDEPTH 24
  21. ENV VIDEO_PORT DFP
  22. ENV PASSWD mypasswd
  23. ENV NOVNC_ENABLE false
  24. ENV WEBRTC_ENCODER nvh264enc
  25. ENV WEBRTC_ENABLE_RESIZE false
  26. ENV ENABLE_AUDIO true
  27. ENV ENABLE_BASIC_AUTH true
  28. # Install locales to prevent errors
  29. RUN apt-get clean && \
  30. apt-get update && apt-get install --no-install-recommends -y locales && \
  31. rm -rf /var/lib/apt/lists/* && \
  32. locale-gen en_US.UTF-8
  33. ENV LANG en_US.UTF-8
  34. ENV LANGUAGE en_US:en
  35. ENV LC_ALL en_US.UTF-8
  36. # Install Xorg, MATE Desktop, and others
  37. RUN dpkg --add-architecture i386 && \
  38. apt-get update && apt-get install --no-install-recommends -y \
  39. software-properties-common \
  40. apt-utils \
  41. build-essential \
  42. ca-certificates \
  43. kmod \
  44. libc6:i386 \
  45. libc6-dev \
  46. curl \
  47. file \
  48. wget \
  49. gzip \
  50. zip \
  51. unzip \
  52. gcc \
  53. git \
  54. jq \
  55. make \
  56. python \
  57. python-numpy \
  58. python3 \
  59. python3-numpy \
  60. mlocate \
  61. nano \
  62. vim \
  63. htop \
  64. firefox \
  65. supervisor \
  66. net-tools \
  67. libpci3 \
  68. libelf-dev \
  69. libglvnd-dev \
  70. vainfo \
  71. vdpauinfo \
  72. pkg-config \
  73. mesa-utils \
  74. mesa-utils-extra \
  75. libglu1 \
  76. libglu1:i386 \
  77. libsm6 \
  78. libxv1 \
  79. libxv1:i386 \
  80. libxtst6 \
  81. libxtst6:i386 \
  82. x11-xkb-utils \
  83. x11-xserver-utils \
  84. x11-apps \
  85. dbus-x11 \
  86. libdbus-c++-1-0v5 \
  87. xauth \
  88. xinit \
  89. xfonts-base \
  90. xkb-data \
  91. libxrandr-dev \
  92. xorg-dev && \
  93. apt-get install -y ubuntu-mate-desktop libreoffice && \
  94. 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 && \
  95. # Support libva and VA-API through NVIDIA VDPAU
  96. 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/* && \
  97. # Remove Bluetooth packages that throw errors
  98. apt-get autoremove --purge -y \
  99. blueman \
  100. pulseaudio-module-bluetooth && \
  101. rm -rf /var/lib/apt/lists/*
  102. # Wine, Winetricks, and PlayOnLinux, comment out the below lines to disable
  103. ARG WINE_BRANCH=devel
  104. RUN if [ "${UBUNTU_RELEASE}" = "18.04" ]; then add-apt-repository ppa:cybermax-dexter/sdl2-backport; fi && \
  105. curl -fsSL -o /usr/share/keyrings/winehq-archive.key "https://dl.winehq.org/wine-builds/winehq.key" && \
  106. 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" && \
  107. apt-get update && apt-get install -y \
  108. winehq-${WINE_BRANCH} \
  109. q4wine \
  110. playonlinux && \
  111. rm -rf /var/lib/apt/lists/* && \
  112. curl -fsSL -o /usr/bin/winetricks "https://raw.githubusercontent.com/Winetricks/winetricks/master/src/winetricks" && \
  113. chmod 755 /usr/bin/winetricks && \
  114. curl -fsSL -o /usr/share/bash-completion/completions/winetricks "https://raw.githubusercontent.com/Winetricks/winetricks/master/src/winetricks.bash-completion"
  115. # Install latest selkies-gstreamer (https://github.com/selkies-project/selkies-gstreamer) build, Python application, and web application
  116. RUN apt-get update && apt-get install --no-install-recommends -y \
  117. build-essential \
  118. python3-pip \
  119. python3-dev \
  120. python3-gi \
  121. python3-setuptools \
  122. python3-wheel \
  123. tzdata \
  124. sudo \
  125. udev \
  126. xclip \
  127. x11-utils \
  128. xdotool \
  129. wmctrl \
  130. jq \
  131. gdebi-core \
  132. x11-xserver-utils \
  133. xserver-xorg-core \
  134. libopus0 \
  135. libgdk-pixbuf2.0-0 \
  136. libsrtp2-1 \
  137. libxdamage1 \
  138. libxml2-dev \
  139. libwebrtc-audio-processing1 \
  140. libcairo-gobject2 \
  141. pulseaudio \
  142. libpulse0 \
  143. libpangocairo-1.0-0 \
  144. libgirepository1.0-dev \
  145. libjpeg-dev \
  146. zlib1g-dev \
  147. x264 && \
  148. rm -rf /var/lib/apt/lists/* && \
  149. cd /opt && \
  150. SELKIES_VERSION=$(curl -fsSL "https://api.github.com/repos/selkies-project/selkies-gstreamer/releases/latest" | jq -r '.tag_name' | sed 's/[^0-9\.\-]*//g') && \
  151. 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 - && \
  152. 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" && \
  153. pip3 install -e "git+https://github.com/selkies-project/python-xlib.git@add-xfixes-cursor#egg=python-xlib" && \
  154. curl -fsSL "https://github.com/selkies-project/selkies-gstreamer/releases/download/v${SELKIES_VERSION}/selkies-gstreamer-web-v${SELKIES_VERSION}.tgz" | tar -zxf - && \
  155. cd /usr/local/cuda/lib64 && sudo find . -maxdepth 1 -type l -name "*libnvrtc.so.*" -exec sh -c 'ln -sf $(basename {}) libnvrtc.so' \;
  156. # Install latest noVNC web interface for fallback
  157. RUN apt-get update && apt-get install --no-install-recommends -y \
  158. autoconf \
  159. automake \
  160. autotools-dev \
  161. chrpath \
  162. debhelper \
  163. jq \
  164. python \
  165. python-numpy \
  166. python3 \
  167. python3-numpy \
  168. libc6-dev \
  169. libcairo2-dev \
  170. libjpeg-turbo8-dev \
  171. libssl-dev \
  172. libv4l-dev \
  173. libvncserver-dev \
  174. libtool-bin \
  175. libxdamage-dev \
  176. libxinerama-dev \
  177. libxrandr-dev \
  178. libxss-dev \
  179. libxtst-dev \
  180. libavahi-client-dev && \
  181. rm -rf /var/lib/apt/lists/* && \
  182. X11VNC_VERSION=$(curl -fsSL "https://api.github.com/repos/LibVNC/x11vnc/releases/latest" | jq -r '.tag_name' | sed 's/[^0-9\.\-]*//g') && \
  183. curl -fsSL https://github.com/LibVNC/x11vnc/archive/${X11VNC_VERSION}.tar.gz | tar -xzf - -C /tmp && \
  184. cd /tmp/x11vnc-${X11VNC_VERSION} && autoreconf -fi && ./configure && make install && cd / && rm -rf /tmp/* && \
  185. NOVNC_VERSION=$(curl -fsSL "https://api.github.com/repos/noVNC/noVNC/releases/latest" | jq -r '.tag_name' | sed 's/[^0-9\.\-]*//g') && \
  186. curl -fsSL https://github.com/novnc/noVNC/archive/v${NOVNC_VERSION}.tar.gz | tar -xzf - -C /opt && \
  187. mv /opt/noVNC-${NOVNC_VERSION} /opt/noVNC && \
  188. ln -s /opt/noVNC/vnc.html /opt/noVNC/index.html && \
  189. git clone https://github.com/novnc/websockify /opt/noVNC/utils/websockify
  190. # Add custom packages below this comment
  191. # Create user with password ${PASSWD}
  192. RUN apt-get update && apt-get install --no-install-recommends -y \
  193. sudo && \
  194. rm -rf /var/lib/apt/lists/* && \
  195. groupadd -g 1000 user && \
  196. useradd -ms /bin/bash user -u 1000 -g 1000 && \
  197. usermod -a -G adm,audio,cdrom,dialout,dip,fax,floppy,input,lp,lpadmin,netdev,plugdev,scanner,ssh,sudo,tape,tty,video,voice user && \
  198. echo "user ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers && \
  199. chown user:user /home/user && \
  200. echo "user:${PASSWD}" | chpasswd && \
  201. ln -snf "/usr/share/zoneinfo/$TZ" /etc/localtime && echo "$TZ" > /etc/timezone
  202. COPY entrypoint.sh /etc/entrypoint.sh
  203. RUN chmod 755 /etc/entrypoint.sh
  204. COPY selkies-gstreamer-entrypoint.sh /etc/selkies-gstreamer-entrypoint.sh
  205. RUN chmod 755 /etc/selkies-gstreamer-entrypoint.sh
  206. COPY supervisord.conf /etc/supervisord.conf
  207. RUN chmod 755 /etc/supervisord.conf
  208. EXPOSE 8080
  209. USER user
  210. ENV USER=user
  211. WORKDIR /home/user
  212. ENTRYPOINT ["/usr/bin/supervisord"]