Dockerfile 27 KB

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