Dockerfile 28 KB

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