Dockerfile 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617
  1. # This Source Code Form is subject to the terms of the Mozilla Public
  2. # License, v. 2.0. If a copy of the MPL was not distributed with this
  3. # file, You can obtain one at https://mozilla.org/MPL/2.0/.
  4. # Supported base images: Ubuntu 24.04, 22.04, 20.04
  5. ARG DISTRIB_RELEASE=24.04
  6. FROM ubuntu:${DISTRIB_RELEASE}
  7. ARG DISTRIB_RELEASE
  8. LABEL maintainer="https://github.com/ehfd,https://github.com/danisla"
  9. ARG DEBIAN_FRONTEND=noninteractive
  10. # Configure rootless user environment for constrained conditions without escalated root privileges inside containers
  11. ARG TZ=UTC
  12. ARG PASSWD=mypasswd
  13. RUN apt-get clean && apt-get update && apt-get dist-upgrade -y && apt-get install --no-install-recommends -y \
  14. apt-utils \
  15. dbus-user-session \
  16. fakeroot \
  17. locales \
  18. ssl-cert \
  19. sudo \
  20. udev \
  21. tzdata && \
  22. apt-get clean && rm -rf /var/lib/apt/lists/* /var/cache/debconf/* /var/log/* /tmp/* /var/tmp/* && \
  23. locale-gen en_US.UTF-8 && \
  24. ln -snf "/usr/share/zoneinfo/$TZ" /etc/localtime && echo "$TZ" > /etc/timezone && \
  25. # Only use sudo-root for root-owned directory (/dev, /proc, /sys) or user/group permission operations, not for apt-get installation or file/directory operations
  26. mv -f /usr/bin/sudo /usr/bin/sudo-root && \
  27. ln -snf /usr/bin/fakeroot /usr/bin/sudo && \
  28. groupadd -g 1000 ubuntu || echo 'Failed to add ubuntu group' && \
  29. useradd -ms /bin/bash ubuntu -u 1000 -g 1000 || echo 'Failed to add ubuntu user' && \
  30. usermod -a -G adm,audio,cdrom,dialout,dip,fax,floppy,games,input,lp,plugdev,render,ssl-cert,sudo,tape,tty,video,voice ubuntu && \
  31. echo "ubuntu ALL=(ALL:ALL) NOPASSWD: ALL" >> /etc/sudoers && \
  32. echo "ubuntu:${PASSWD}" | chpasswd && \
  33. chown -R -f --no-preserve-root ubuntu:ubuntu / || echo 'Failed to set filesystem ownership to ubuntu user'
  34. # Set locales
  35. ENV LANG="en_US.UTF-8"
  36. ENV LANGUAGE="en_US:en"
  37. ENV LC_ALL="en_US.UTF-8"
  38. USER 1000
  39. # Use BUILDAH_FORMAT=docker in buildah
  40. SHELL ["/usr/bin/fakeroot", "--", "/bin/sh", "-c"]
  41. # Install operating system libraries or packages
  42. RUN apt-get update && apt-get install --no-install-recommends -y \
  43. # Operating system packages
  44. software-properties-common \
  45. build-essential \
  46. ca-certificates \
  47. cups-browsed \
  48. cups-bsd \
  49. cups-common \
  50. cups-filters \
  51. printer-driver-cups-pdf \
  52. alsa-base \
  53. alsa-utils \
  54. file \
  55. gnupg \
  56. curl \
  57. wget \
  58. bzip2 \
  59. gzip \
  60. xz-utils \
  61. unar \
  62. rar \
  63. unrar \
  64. zip \
  65. unzip \
  66. zstd \
  67. gcc \
  68. git \
  69. coturn \
  70. jq \
  71. python3 \
  72. python3-cups \
  73. python3-numpy \
  74. nano \
  75. vim \
  76. htop \
  77. fonts-dejavu \
  78. fonts-freefont-ttf \
  79. fonts-hack \
  80. fonts-liberation \
  81. fonts-noto \
  82. fonts-noto-cjk \
  83. fonts-noto-cjk-extra \
  84. fonts-noto-color-emoji \
  85. fonts-noto-extra \
  86. fonts-noto-ui-extra \
  87. fonts-noto-hinted \
  88. fonts-noto-mono \
  89. fonts-noto-unhinted \
  90. fonts-opensymbol \
  91. fonts-symbola \
  92. fonts-ubuntu \
  93. lame \
  94. less \
  95. libavcodec-extra \
  96. libpulse0 \
  97. supervisor \
  98. net-tools \
  99. packagekit-tools \
  100. pkg-config \
  101. mesa-utils \
  102. mesa-va-drivers \
  103. libva2 \
  104. vainfo \
  105. vdpau-driver-all \
  106. libvdpau-va-gl1 \
  107. vdpauinfo \
  108. mesa-vulkan-drivers \
  109. vulkan-tools \
  110. radeontop \
  111. libvulkan-dev \
  112. ocl-icd-libopencl1 \
  113. clinfo \
  114. xkb-data \
  115. xauth \
  116. xbitmaps \
  117. xdg-user-dirs \
  118. xdg-utils \
  119. xfonts-base \
  120. xfonts-scalable \
  121. xinit \
  122. xsettingsd \
  123. libxrandr-dev \
  124. x11-xkb-utils \
  125. x11-xserver-utils \
  126. x11-utils \
  127. x11-apps \
  128. xserver-xorg-input-all \
  129. xserver-xorg-input-wacom \
  130. xserver-xorg-video-all \
  131. xserver-xorg-video-intel \
  132. xserver-xorg-video-qxl \
  133. # OpenGL libraries
  134. libxau6 \
  135. libxdmcp6 \
  136. libxcb1 \
  137. libxext6 \
  138. libx11-6 \
  139. libxv1 \
  140. libxtst6 \
  141. libdrm2 \
  142. libegl1 \
  143. libgl1 \
  144. libopengl0 \
  145. libgles1 \
  146. libgles2 \
  147. libglvnd0 \
  148. libglx0 \
  149. libglu1 \
  150. libsm6 && \
  151. # PipeWire and WirePlumber
  152. mkdir -pm755 /etc/apt/trusted.gpg.d && curl -fsSL "https://keyserver.ubuntu.com/pks/lookup?op=get&search=0xFC43B7352BCC0EC8AF2EEB8B25088A0359807596" | gpg --dearmor -o /etc/apt/trusted.gpg.d/pipewire-debian-ubuntu-pipewire-upstream.gpg && \
  153. mkdir -pm755 /etc/apt/sources.list.d && echo "deb https://ppa.launchpadcontent.net/pipewire-debian/pipewire-upstream/ubuntu $(grep UBUNTU_CODENAME= /etc/os-release | cut -d= -f2 | tr -d '\"') main" > "/etc/apt/sources.list.d/pipewire-debian-ubuntu-pipewire-upstream-$(grep UBUNTU_CODENAME= /etc/os-release | cut -d= -f2 | tr -d '\"').list" && \
  154. mkdir -pm755 /etc/apt/sources.list.d && echo "deb https://ppa.launchpadcontent.net/pipewire-debian/wireplumber-upstream/ubuntu $(grep UBUNTU_CODENAME= /etc/os-release | cut -d= -f2 | tr -d '\"') main" > "/etc/apt/sources.list.d/pipewire-debian-ubuntu-wireplumber-upstream-$(grep UBUNTU_CODENAME= /etc/os-release | cut -d= -f2 | tr -d '\"').list" && \
  155. apt-get update && apt-get install --no-install-recommends -y \
  156. pipewire \
  157. pipewire-alsa \
  158. pipewire-audio-client-libraries \
  159. pipewire-jack \
  160. pipewire-locales \
  161. pipewire-v4l2 \
  162. pipewire-libcamera \
  163. gstreamer1.0-pipewire \
  164. libpipewire-0.3-modules \
  165. libpipewire-module-x11-bell \
  166. libspa-0.2-jack \
  167. libspa-0.2-modules \
  168. wireplumber \
  169. wireplumber-locales \
  170. gir1.2-wp-0.4 && \
  171. # Packages only meant for x86_64
  172. if [ "$(dpkg --print-architecture)" = "amd64" ]; then \
  173. dpkg --add-architecture i386 && apt-get update && apt-get install --no-install-recommends -y \
  174. intel-gpu-tools \
  175. nvtop \
  176. va-driver-all \
  177. i965-va-driver-shaders \
  178. intel-media-va-driver-non-free \
  179. va-driver-all:i386 \
  180. i965-va-driver-shaders:i386 \
  181. intel-media-va-driver-non-free:i386 \
  182. libva2:i386 \
  183. vdpau-driver-all:i386 \
  184. mesa-vulkan-drivers:i386 \
  185. libvulkan-dev:i386 \
  186. libxau6:i386 \
  187. libxdmcp6:i386 \
  188. libxcb1:i386 \
  189. libxext6:i386 \
  190. libx11-6:i386 \
  191. libxv1:i386 \
  192. libxtst6:i386 \
  193. libdrm2:i386 \
  194. libegl1:i386 \
  195. libgl1:i386 \
  196. libopengl0:i386 \
  197. libgles1:i386 \
  198. libgles2:i386 \
  199. libglvnd0:i386 \
  200. libglx0:i386 \
  201. libglu1:i386 \
  202. libsm6:i386; fi && \
  203. apt-get clean && rm -rf /var/lib/apt/lists/* /var/cache/debconf/* /var/log/* /tmp/* /var/tmp/* && \
  204. echo "/usr/local/nvidia/lib" >> /etc/ld.so.conf.d/nvidia.conf && \
  205. echo "/usr/local/nvidia/lib64" >> /etc/ld.so.conf.d/nvidia.conf && \
  206. # Configure OpenCL manually
  207. mkdir -pm755 /etc/OpenCL/vendors && echo "libnvidia-opencl.so.1" > /etc/OpenCL/vendors/nvidia.icd && \
  208. # Configure Vulkan manually
  209. VULKAN_API_VERSION=$(dpkg -s libvulkan1 | grep -oP 'Version: [0-9|\.]+' | grep -oP '[0-9]+(\.[0-9]+)(\.[0-9]+)') && \
  210. mkdir -pm755 /etc/vulkan/icd.d/ && echo "{\n\
  211. \"file_format_version\" : \"1.0.0\",\n\
  212. \"ICD\": {\n\
  213. \"library_path\": \"libGLX_nvidia.so.0\",\n\
  214. \"api_version\" : \"${VULKAN_API_VERSION}\"\n\
  215. }\n\
  216. }" > /etc/vulkan/icd.d/nvidia_icd.json && \
  217. # Configure EGL manually
  218. mkdir -pm755 /usr/share/glvnd/egl_vendor.d/ && echo "{\n\
  219. \"file_format_version\" : \"1.0.0\",\n\
  220. \"ICD\": {\n\
  221. \"library_path\": \"libEGL_nvidia.so.0\"\n\
  222. }\n\
  223. }" > /usr/share/glvnd/egl_vendor.d/10_nvidia.json
  224. # Expose NVIDIA libraries and paths
  225. ENV PATH="/usr/local/nvidia/bin${PATH:+:${PATH}}"
  226. ENV LD_LIBRARY_PATH="${LD_LIBRARY_PATH:+${LD_LIBRARY_PATH}:}/usr/local/nvidia/lib:/usr/local/nvidia/lib64"
  227. # Make all NVIDIA GPUs visible by default
  228. ENV NVIDIA_VISIBLE_DEVICES=all
  229. # All NVIDIA driver capabilities should preferably be used, check `NVIDIA_DRIVER_CAPABILITIES` inside the container if things do not work
  230. ENV NVIDIA_DRIVER_CAPABILITIES=all
  231. # Disable VSYNC for NVIDIA GPUs
  232. ENV __GL_SYNC_TO_VBLANK=0
  233. # Set default DISPLAY environment
  234. ENV DISPLAY=":0"
  235. # Anything above this line should always be kept the same between docker-nvidia-glx-desktop and docker-nvidia-egl-desktop
  236. # Default environment variables (password is "mypasswd")
  237. ENV DISPLAY_SIZEW=1920
  238. ENV DISPLAY_SIZEH=1080
  239. ENV DISPLAY_REFRESH=60
  240. ENV DISPLAY_DPI=96
  241. ENV DISPLAY_CDEPTH=24
  242. ENV VIDEO_PORT=DFP
  243. ENV NOVNC_ENABLE=false
  244. ENV SELKIES_ENCODER=nvh264enc
  245. ENV SELKIES_ENABLE_RESIZE=false
  246. ENV SELKIES_ENABLE_BASIC_AUTH=true
  247. # Set versions for components that should be manually checked before upgrading, other component versions are automatically determined by fetching the version online
  248. ARG NOVNC_VERSION=1.5.0
  249. # Install Xorg and NVIDIA driver installer dependencies
  250. RUN apt-get update && apt-get install --no-install-recommends -y \
  251. kmod \
  252. libc6-dev \
  253. libpci3 \
  254. libelf-dev \
  255. pkg-config \
  256. xorg && \
  257. if [ "$(dpkg --print-architecture)" = "amd64" ]; then apt-get install --no-install-recommends -y libc6:i386; fi && \
  258. apt-get clean && rm -rf /var/lib/apt/lists/* /var/cache/debconf/* /var/log/* /tmp/* /var/tmp/*
  259. # Anything below this line should always be kept the same between docker-nvidia-glx-desktop and docker-nvidia-egl-desktop
  260. # Install KDE and other GUI packages
  261. ENV DESKTOP_SESSION=plasma
  262. ENV XDG_SESSION_DESKTOP=KDE
  263. ENV XDG_CURRENT_DESKTOP=KDE
  264. ENV XDG_SESSION_TYPE=x11
  265. ENV XDG_SESSION_ID="${DISPLAY#*:}"
  266. ENV KDE_FULL_SESSION=true
  267. ENV KDE_APPLICATIONS_AS_SCOPE=1
  268. ENV KWIN_COMPOSE=N
  269. ENV KWIN_X11_NO_SYNC_TO_VBLANK=1
  270. # Use sudoedit to change protected files instead of using sudo on kate
  271. ENV SUDO_EDITOR=kate
  272. # Set input to fcitx
  273. ENV GTK_IM_MODULE=fcitx
  274. ENV QT_IM_MODULE=fcitx
  275. ENV XIM=fcitx
  276. ENV XMODIFIERS="@im=fcitx"
  277. # Enable AppImage execution in containers
  278. ENV APPIMAGE_EXTRACT_AND_RUN=1
  279. RUN mkdir -pm755 /etc/apt/preferences.d && echo "Package: firefox*\n\
  280. Pin: version 1:1snap*\n\
  281. Pin-Priority: -1" > /etc/apt/preferences.d/firefox-nosnap && \
  282. mkdir -pm755 /etc/apt/trusted.gpg.d && curl -fsSL "https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x0AB215679C571D1C8325275B9BDB3D89CE49EC21" | gpg --dearmor -o /etc/apt/trusted.gpg.d/mozillateam-ubuntu-ppa.gpg && \
  283. mkdir -pm755 /etc/apt/sources.list.d && echo "deb https://ppa.launchpadcontent.net/mozillateam/ppa/ubuntu $(grep UBUNTU_CODENAME= /etc/os-release | cut -d= -f2 | tr -d '\"') main" > "/etc/apt/sources.list.d/mozillateam-ubuntu-ppa-$(grep UBUNTU_CODENAME= /etc/os-release | cut -d= -f2 | tr -d '\"').list" && \
  284. apt-get update && apt-get install --no-install-recommends -y \
  285. kde-plasma-desktop \
  286. adwaita-icon-theme-full \
  287. appmenu-gtk3-module \
  288. ark \
  289. aspell \
  290. aspell-en \
  291. breeze \
  292. breeze-cursor-theme \
  293. breeze-gtk-theme \
  294. breeze-icon-theme \
  295. dbus-x11 \
  296. debconf-kde-helper \
  297. desktop-file-utils \
  298. dolphin \
  299. dolphin-plugins \
  300. enchant-2 \
  301. fcitx \
  302. fcitx-frontend-gtk2 \
  303. fcitx-frontend-gtk3 \
  304. fcitx-frontend-qt5 \
  305. fcitx-module-dbus \
  306. fcitx-module-kimpanel \
  307. fcitx-module-lua \
  308. fcitx-module-x11 \
  309. fcitx-tools \
  310. fcitx-hangul \
  311. fcitx-libpinyin \
  312. fcitx-m17n \
  313. fcitx-mozc \
  314. fcitx-sayura \
  315. fcitx-unikey \
  316. filelight \
  317. frameworkintegration \
  318. gwenview \
  319. haveged \
  320. hunspell \
  321. im-config \
  322. kate \
  323. kcalc \
  324. kcharselect \
  325. kdeadmin \
  326. kde-config-fcitx \
  327. kde-config-gtk-style \
  328. kde-config-gtk-style-preview \
  329. kdeconnect \
  330. kdegraphics-thumbnailers \
  331. kde-spectacle \
  332. kdf \
  333. kdialog \
  334. kget \
  335. kimageformat-plugins \
  336. kinfocenter \
  337. kio \
  338. kio-extras \
  339. kmag \
  340. kmenuedit \
  341. kmix \
  342. kmousetool \
  343. kmouth \
  344. ksshaskpass \
  345. ktimer \
  346. kwayland-integration \
  347. kwin-addons \
  348. kwin-x11 \
  349. libdbusmenu-glib4 \
  350. libdbusmenu-gtk3-4 \
  351. libgail-common \
  352. libgdk-pixbuf2.0-bin \
  353. libgtk2.0-bin \
  354. libgtk-3-bin \
  355. libkf5baloowidgets-bin \
  356. libkf5dbusaddons-bin \
  357. libkf5iconthemes-bin \
  358. libkf5kdelibs4support5-bin \
  359. libkf5khtml-bin \
  360. libkf5parts-plugins \
  361. libqt5multimedia5-plugins \
  362. librsvg2-common \
  363. media-player-info \
  364. okular \
  365. okular-extra-backends \
  366. partitionmanager \
  367. plasma-browser-integration \
  368. plasma-calendar-addons \
  369. plasma-dataengines-addons \
  370. plasma-discover \
  371. plasma-integration \
  372. plasma-runners-addons \
  373. plasma-widgets-addons \
  374. policykit-desktop-privileges \
  375. polkit-kde-agent-1 \
  376. print-manager \
  377. qapt-deb-installer \
  378. qml-module-org-kde-runnermodel \
  379. qml-module-org-kde-qqc2desktopstyle \
  380. qml-module-qtgraphicaleffects \
  381. qml-module-qtquick-xmllistmodel \
  382. qt5-gtk-platformtheme \
  383. qt5-image-formats-plugins \
  384. qt5-style-plugins \
  385. qtspeech5-flite-plugin \
  386. qtvirtualkeyboard-plugin \
  387. software-properties-qt \
  388. sonnet-plugins \
  389. sweeper \
  390. systemsettings \
  391. ubuntu-drivers-common \
  392. vlc \
  393. vlc-l10n \
  394. vlc-plugin-access-extra \
  395. vlc-plugin-notify \
  396. vlc-plugin-samba \
  397. vlc-plugin-skins2 \
  398. vlc-plugin-video-splitter \
  399. vlc-plugin-visualization \
  400. xdg-desktop-portal-kde \
  401. xdg-user-dirs \
  402. firefox \
  403. transmission-qt && \
  404. apt-get install --install-recommends -y \
  405. libreoffice \
  406. libreoffice-kf5 \
  407. libreoffice-plasma \
  408. libreoffice-style-breeze && \
  409. apt-get clean && rm -rf /var/lib/apt/lists/* /var/cache/debconf/* /var/log/* /tmp/* /var/tmp/* && \
  410. # Fix KDE startup permissions issues in containers
  411. MULTI_ARCH=$(dpkg --print-architecture | sed -e 's/arm64/aarch64-linux-gnu/' -e 's/armhf/arm-linux-gnueabihf/' -e 's/riscv64/riscv64-linux-gnu/' -e 's/ppc64el/powerpc64le-linux-gnu/' -e 's/s390x/s390x-linux-gnu/' -e 's/i.*86/i386-linux-gnu/' -e 's/amd64/x86_64-linux-gnu/' -e 's/unknown/x86_64-linux-gnu/') && \
  412. cp -f /usr/lib/${MULTI_ARCH}/libexec/kf5/start_kdeinit /tmp/ && \
  413. rm -f /usr/lib/${MULTI_ARCH}/libexec/kf5/start_kdeinit && \
  414. cp -f /tmp/start_kdeinit /usr/lib/${MULTI_ARCH}/libexec/kf5/start_kdeinit && \
  415. rm -f /tmp/start_kdeinit && \
  416. # KDE disable screen lock, double-click to open instead of single-click
  417. echo "[Daemon]\n\
  418. Autolock=false\n\
  419. LockOnResume=false" > /etc/xdg/kscreenlockerrc && \
  420. echo "[KDE]\n\
  421. SingleClick=false\n\
  422. \n\
  423. [KDE Action Restrictions]\n\
  424. action/lock_screen=false\n\
  425. logout=false" > /etc/xdg/kdeglobals
  426. # Wine, Winetricks, Lutris, and PlayOnLinux, this process must be consistent with https://wiki.winehq.org/Ubuntu
  427. ARG WINE_BRANCH=staging
  428. RUN if [ "$(dpkg --print-architecture)" = "amd64" ]; then \
  429. mkdir -pm755 /etc/apt/keyrings && curl -fsSL -o /etc/apt/keyrings/winehq-archive.key "https://dl.winehq.org/wine-builds/winehq.key" && \
  430. curl -fsSL -o "/etc/apt/sources.list.d/winehq-$(grep UBUNTU_CODENAME= /etc/os-release | cut -d= -f2 | tr -d '\"').sources" "https://dl.winehq.org/wine-builds/ubuntu/dists/$(grep UBUNTU_CODENAME= /etc/os-release | cut -d= -f2 | tr -d '\"')/winehq-$(grep UBUNTU_CODENAME= /etc/os-release | cut -d= -f2 | tr -d '\"').sources" && \
  431. apt-get update && apt-get install --install-recommends -y \
  432. winehq-${WINE_BRANCH} && \
  433. apt-get install --no-install-recommends -y \
  434. q4wine \
  435. playonlinux && \
  436. LUTRIS_VERSION="$(curl -fsSL "https://api.github.com/repos/lutris/lutris/releases/latest" | jq -r '.tag_name' | sed 's/[^0-9\.\-]*//g')" && \
  437. curl -fsSL -O "https://github.com/lutris/lutris/releases/download/v${LUTRIS_VERSION}/lutris_${LUTRIS_VERSION}_all.deb" && \
  438. apt-get install --no-install-recommends -y ./lutris_${LUTRIS_VERSION}_all.deb && rm -f "./lutris_${LUTRIS_VERSION}_all.deb" && \
  439. apt-get clean && rm -rf /var/lib/apt/lists/* /var/cache/debconf/* /var/log/* /tmp/* /var/tmp/* && \
  440. curl -fsSL -o /usr/bin/winetricks "https://raw.githubusercontent.com/Winetricks/winetricks/master/src/winetricks" && \
  441. chmod 755 /usr/bin/winetricks && \
  442. curl -fsSL -o /usr/share/bash-completion/completions/winetricks "https://raw.githubusercontent.com/Winetricks/winetricks/master/src/winetricks.bash-completion"; fi
  443. # Install latest Selkies-GStreamer (https://github.com/selkies-project/selkies-gstreamer) build, Python application, and web application, should be consistent with Selkies-GStreamer documentation
  444. ARG PIP_BREAK_SYSTEM_PACKAGES=1
  445. RUN apt-get update && apt-get install --no-install-recommends -y \
  446. # GStreamer dependencies
  447. python3-pip \
  448. python3-dev \
  449. python3-gi \
  450. python3-setuptools \
  451. python3-wheel \
  452. libaa1 \
  453. bzip2 \
  454. libgcrypt20 \
  455. libcairo-gobject2 \
  456. libpangocairo-1.0-0 \
  457. libgdk-pixbuf2.0-0 \
  458. libsoup2.4-1 \
  459. libsoup-gnome2.4-1 \
  460. libgirepository-1.0-1 \
  461. glib-networking \
  462. libglib2.0-0 \
  463. libjson-glib-1.0-0 \
  464. libgudev-1.0-0 \
  465. alsa-utils \
  466. jackd2 \
  467. libjack-jackd2-0 \
  468. libpulse0 \
  469. libogg0 \
  470. libopus0 \
  471. libvorbis-dev \
  472. libjpeg-turbo8 \
  473. libopenjp2-7 \
  474. libvpx-dev \
  475. libwebp-dev \
  476. x264 \
  477. x265 \
  478. libdrm2 \
  479. libegl1 \
  480. libgl1 \
  481. libopengl0 \
  482. libgles1 \
  483. libgles2 \
  484. libglvnd0 \
  485. libglx0 \
  486. wayland-protocols \
  487. libwayland-dev \
  488. libwayland-egl1 \
  489. wmctrl \
  490. xsel \
  491. xdotool \
  492. x11-utils \
  493. x11-xserver-utils \
  494. xserver-xorg-core \
  495. libx11-xcb1 \
  496. libxcb-dri3-0 \
  497. libxkbcommon0 \
  498. libxdamage1 \
  499. libxfixes3 \
  500. libxv1 \
  501. libxtst6 \
  502. libxext6 && \
  503. if [ "$(grep VERSION_ID= /etc/os-release | cut -d= -f2 | tr -d '\"')" \> "20.04" ]; then apt-get install --no-install-recommends -y xcvt libopenh264-dev libde265-0 svt-av1 aom-tools; else apt-get install --no-install-recommends -y mesa-utils-extra; fi && \
  504. # Automatically fetch the latest selkies-gstreamer version and install the components
  505. SELKIES_VERSION="$(curl -fsSL "https://api.github.com/repos/selkies-project/selkies-gstreamer/releases/latest" | jq -r '.tag_name' | sed 's/[^0-9\.\-]*//g')" && \
  506. cd /opt && curl -fsSL "https://github.com/selkies-project/selkies-gstreamer/releases/download/v${SELKIES_VERSION}/gstreamer-selkies_gpl_v${SELKIES_VERSION}_ubuntu$(grep VERSION_ID= /etc/os-release | cut -d= -f2 | tr -d '\"')_$(dpkg --print-architecture).tar.gz" | tar -xzf - && \
  507. cd /tmp && 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 --no-cache-dir --force-reinstall "selkies_gstreamer-${SELKIES_VERSION}-py3-none-any.whl" && rm -f "selkies_gstreamer-${SELKIES_VERSION}-py3-none-any.whl" && \
  508. cd /opt && curl -fsSL "https://github.com/selkies-project/selkies-gstreamer/releases/download/v${SELKIES_VERSION}/selkies-gstreamer-web_v${SELKIES_VERSION}.tar.gz" | tar -xzf - && \
  509. cd /tmp && curl -o selkies-js-interposer.deb -fsSL "https://github.com/selkies-project/selkies-gstreamer/releases/download/v${SELKIES_VERSION}/selkies-js-interposer_v${SELKIES_VERSION}_ubuntu$(grep VERSION_ID= /etc/os-release | cut -d= -f2 | tr -d '\"')_$(dpkg --print-architecture).deb" && apt-get update && apt-get install --no-install-recommends -y ./selkies-js-interposer.deb && rm -f selkies-js-interposer.deb && \
  510. apt-get clean && rm -rf /var/lib/apt/lists/* /var/cache/debconf/* /var/log/* /tmp/* /var/tmp/*
  511. # Add configuration for Selkies-GStreamer Joystick interposer
  512. ENV SELKIES_INTERPOSER='/usr/$LIB/selkies_joystick_interposer.so'
  513. ENV LD_PRELOAD="${SELKIES_INTERPOSER}${LD_PRELOAD:+:${LD_PRELOAD}}"
  514. ENV SDL_JOYSTICK_DEVICE=/dev/input/js0
  515. # Install the noVNC web interface and the latest x11vnc for fallback
  516. RUN apt-get update && apt-get install --no-install-recommends -y \
  517. autoconf \
  518. automake \
  519. autotools-dev \
  520. chrpath \
  521. debhelper \
  522. git \
  523. jq \
  524. python3 \
  525. python3-numpy \
  526. libc6-dev \
  527. libcairo2-dev \
  528. libjpeg-turbo8-dev \
  529. libssl-dev \
  530. libv4l-dev \
  531. libvncserver-dev \
  532. libtool-bin \
  533. libxdamage-dev \
  534. libxinerama-dev \
  535. libxrandr-dev \
  536. libxss-dev \
  537. libxtst-dev \
  538. libavahi-client-dev && \
  539. apt-get clean && rm -rf /var/lib/apt/lists/* /var/cache/debconf/* /var/log/* /tmp/* /var/tmp/* && \
  540. # Build the latest x11vnc source to avoid various errors
  541. git clone "https://github.com/LibVNC/x11vnc.git" /tmp/x11vnc && \
  542. cd /tmp/x11vnc && autoreconf -fi && ./configure && make install && cd / && rm -rf /tmp/* && \
  543. curl -fsSL "https://github.com/novnc/noVNC/archive/v${NOVNC_VERSION}.tar.gz" | tar -xzf - -C /opt && \
  544. mv -f "/opt/noVNC-${NOVNC_VERSION}" /opt/noVNC && \
  545. cd /opt/noVNC && ln -snf vnc.html index.html && \
  546. # Use the latest Websockify source to expose noVNC
  547. git clone "https://github.com/novnc/websockify.git" /opt/noVNC/utils/websockify
  548. # 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
  549. # Copy scripts and configurations used to start the container with `--chown=1000:1000`
  550. COPY --chown=1000:1000 entrypoint.sh /etc/entrypoint.sh
  551. RUN chmod 755 /etc/entrypoint.sh
  552. COPY --chown=1000:1000 selkies-gstreamer-entrypoint.sh /etc/selkies-gstreamer-entrypoint.sh
  553. RUN chmod 755 /etc/selkies-gstreamer-entrypoint.sh
  554. COPY --chown=1000:1000 supervisord.conf /etc/supervisord.conf
  555. RUN chmod 755 /etc/supervisord.conf
  556. # Configure coTURN script
  557. RUN echo "#!/bin/bash\n\
  558. set -e\n\
  559. turnserver \
  560. --verbose \
  561. --listening-ip=\"0.0.0.0\" \
  562. --listening-ip=\"::\" \
  563. --listening-port=\"\${SELKIES_TURN_PORT:-3478}\" \
  564. --realm=\"\${TURN_REALM:-example.com}\" \
  565. --external-ip=\"\${SELKIES_TURN_HOST:-\$(curl -fsSL checkip.amazonaws.com)}\" \
  566. --min-port=\"\${TURN_MIN_PORT:-49152}\" \
  567. --max-port=\"\${TURN_MAX_PORT:-65535}\" \
  568. --channel-lifetime=\"\${TURN_CHANNEL_LIFETIME:--1}\" \
  569. --lt-cred-mech \
  570. --user \"selkies:\${TURN_RANDOM_PASSWORD}\" \
  571. --no-cli \
  572. --cli-password=\"\${TURN_RANDOM_PASSWORD:-\$(tr -dc 'A-Za-z0-9' < /dev/urandom 2>/dev/null | head -c 24)}\" \
  573. --allow-loopback-peers \
  574. \${TURN_EXTRA_ARGS} \$@\
  575. " > /etc/start-turnserver.sh && chmod 755 /etc/start-turnserver.sh
  576. SHELL ["/bin/sh", "-c"]
  577. USER 0
  578. # Enable sudo through sudo-root with uid 0
  579. RUN if [ -d "/usr/libexec/sudo" ]; then SUDO_LIB="/usr/libexec/sudo"; else SUDO_LIB="/usr/lib/sudo"; fi && \
  580. chown -R -f --no-preserve-root root:root /usr/bin/sudo-root /etc/sudo.conf /etc/sudoers /etc/sudoers.d /etc/sudo_logsrvd.conf "${SUDO_LIB}" || echo 'Failed to provide root permissions to sudo' && \
  581. chmod -f 4755 /usr/bin/sudo-root || echo 'Failed to set chmod to sudo-root'
  582. USER 1000
  583. ENV PIPEWIRE_LATENCY="32/48000"
  584. ENV XDG_RUNTIME_DIR=/tmp/runtime-ubuntu
  585. ENV PIPEWIRE_RUNTIME_DIR="${PIPEWIRE_RUNTIME_DIR:-${XDG_RUNTIME_DIR:-/tmp}}"
  586. ENV PULSE_RUNTIME_PATH="${PULSE_RUNTIME_PATH:-${XDG_RUNTIME_DIR:-/tmp}/pulse}"
  587. ENV PULSE_SERVER="${PULSE_SERVER:-unix:${PULSE_RUNTIME_PATH:-${XDG_RUNTIME_DIR:-/tmp}/pulse}/native}"
  588. USER 1000
  589. ENV SHELL=/bin/bash
  590. ENV USER=ubuntu
  591. WORKDIR /home/ubuntu
  592. EXPOSE 8080
  593. ENTRYPOINT ["/usr/bin/supervisord"]