Dockerfile 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676
  1. # syntax=docker/dockerfile:1.7
  2. # Final target:
  3. # Ubuntu 24.04 + NVIDIA GLX + XFCE + PipeWire + Firefox + Selkies
  4. #
  5. # The build uses intermediate stages, but produces a single final image.
  6. ARG DISTRIB_RELEASE=24.04
  7. ARG SELKIES_IMAGE=ghcr.io/selkies-project/selkies/py-build:main
  8. ARG SELKIES_GIT_REF=main
  9. ARG NVIDIA_VAAPI_DRIVER_VERSION=latest
  10. # -----------------------------------------------------------------------------
  11. # Current Selkies wheel
  12. # -----------------------------------------------------------------------------
  13. FROM ${SELKIES_IMAGE} AS selkies-build
  14. # -----------------------------------------------------------------------------
  15. # Selkies joystick interposer
  16. # -----------------------------------------------------------------------------
  17. # Build the Selkies joystick interposer directly from its official source.
  18. FROM docker.io/library/ubuntu:${DISTRIB_RELEASE} AS selkies-js-interposer-builder
  19. ARG DEBIAN_FRONTEND=noninteractive
  20. ARG SELKIES_GIT_REF
  21. SHELL ["/bin/bash", "-o", "pipefail", "-c"]
  22. RUN apt-get update \
  23. && apt-get install --no-install-recommends -y \
  24. build-essential \
  25. ca-certificates \
  26. curl \
  27. && rm -rf /var/lib/apt/lists/*
  28. RUN set -eux; \
  29. curl -fsSL \
  30. "https://raw.githubusercontent.com/selkies-project/selkies/${SELKIES_GIT_REF}/addons/js-interposer/joystick_interposer.c" \
  31. -o /tmp/joystick_interposer.c; \
  32. install -d -m 0755 /out; \
  33. gcc -shared -fPIC -O2 \
  34. -Wl,-z,relro,-z,now \
  35. -o /out/selkies_joystick_interposer.so \
  36. /tmp/joystick_interposer.c \
  37. -ldl; \
  38. test -s /out/selkies_joystick_interposer.so
  39. # -----------------------------------------------------------------------------
  40. # Build the Selkies Python environment
  41. # -----------------------------------------------------------------------------
  42. FROM docker.io/library/ubuntu:${DISTRIB_RELEASE} AS selkies-runtime-builder
  43. ARG DEBIAN_FRONTEND=noninteractive
  44. SHELL ["/bin/bash", "-o", "pipefail", "-c"]
  45. COPY --from=selkies-build /opt/pypi/dist/selkies-*.whl /tmp/
  46. RUN apt-get update \
  47. && apt-get install --no-install-recommends -y \
  48. build-essential \
  49. libsm6 \
  50. libopus0 \
  51. libpulse0 \
  52. libxkbcommon-dev \
  53. pkg-config \
  54. python3 \
  55. python3-dev \
  56. python3-pip \
  57. python3-venv \
  58. && python3 -m venv /opt/selkies \
  59. && /opt/selkies/bin/python -m pip install \
  60. --no-cache-dir \
  61. --upgrade \
  62. pip \
  63. setuptools \
  64. wheel \
  65. && printf '%s\n' \
  66. 'pixelflux==1.6.4' \
  67. 'pcmflux==1.0.8' \
  68. > /tmp/selkies-constraints.txt \
  69. && /opt/selkies/bin/python -m pip install \
  70. --no-cache-dir \
  71. --force-reinstall \
  72. --constraint /tmp/selkies-constraints.txt \
  73. /tmp/selkies-*.whl
  74. # -----------------------------------------------------------------------------
  75. # Build the current nvidia-vaapi-driver without retaining build dependencies
  76. # -----------------------------------------------------------------------------
  77. FROM docker.io/library/ubuntu:${DISTRIB_RELEASE} AS nvidia-vaapi-builder
  78. ARG DEBIAN_FRONTEND=noninteractive
  79. ARG NVIDIA_VAAPI_DRIVER_VERSION
  80. SHELL ["/bin/bash", "-o", "pipefail", "-c"]
  81. RUN apt-get update \
  82. && apt-get install --no-install-recommends -y \
  83. ca-certificates \
  84. curl \
  85. gcc \
  86. jq \
  87. meson \
  88. ninja-build \
  89. pkg-config \
  90. libdrm-dev \
  91. libegl-dev \
  92. libffmpeg-nvenc-dev \
  93. libgstreamer-plugins-bad1.0-dev \
  94. libva-dev \
  95. && rm -rf /var/lib/apt/lists/*
  96. RUN set -eux; \
  97. version="${NVIDIA_VAAPI_DRIVER_VERSION}"; \
  98. if [[ "${version}" == "latest" ]]; then \
  99. version="$(curl -fsSL https://api.github.com/repos/elFarto/nvidia-vaapi-driver/releases/latest \
  100. | jq -r '.tag_name' \
  101. | sed 's/^v//')"; \
  102. fi; \
  103. curl -fsSL \
  104. "https://github.com/elFarto/nvidia-vaapi-driver/archive/refs/tags/v${version}.tar.gz" \
  105. -o /tmp/nvidia-vaapi-driver.tar.gz; \
  106. mkdir -p /tmp/nvidia-vaapi-driver; \
  107. tar -xzf /tmp/nvidia-vaapi-driver.tar.gz \
  108. --strip-components=1 \
  109. -C /tmp/nvidia-vaapi-driver; \
  110. cd /tmp/nvidia-vaapi-driver; \
  111. meson setup build \
  112. --prefix=/usr \
  113. --buildtype=release; \
  114. meson compile -C build; \
  115. DESTDIR=/out meson install -C build
  116. # -----------------------------------------------------------------------------
  117. # Build the Selkies web frontend from the official source repository
  118. # -----------------------------------------------------------------------------
  119. FROM docker.io/library/node:22-bookworm-slim AS selkies-web-builder
  120. ARG DEBIAN_FRONTEND=noninteractive
  121. ARG SELKIES_GIT_REF=main
  122. ARG SELKIES_MODE=websockets
  123. ARG SELKIES_UPLOAD_DIR=/home/ubuntu/Desktop
  124. SHELL ["/bin/bash", "-o", "pipefail", "-c"]
  125. RUN apt-get update \
  126. && apt-get install --no-install-recommends -y \
  127. ca-certificates \
  128. cmake \
  129. curl \
  130. git \
  131. && rm -rf /var/lib/apt/lists/*
  132. WORKDIR /tmp/selkies
  133. RUN curl -fsSL \
  134. "https://github.com/selkies-project/selkies/archive/${SELKIES_GIT_REF}.tar.gz" \
  135. -o /tmp/selkies.tar.gz \
  136. && tar -xzf /tmp/selkies.tar.gz \
  137. --strip-components=1 \
  138. -C /tmp/selkies \
  139. && rm -f /tmp/selkies.tar.gz
  140. RUN set -eux; \
  141. cd /tmp/selkies/addons/selkies-web-core; \
  142. npm install; \
  143. npm run build; \
  144. \
  145. cd /tmp/selkies/addons/selkies-dashboard; \
  146. cp ../selkies-web-core/dist/selkies-core.js src/; \
  147. npm install; \
  148. SELKIES_INJECT=1 \
  149. SELKIES_MODE="${SELKIES_MODE}" \
  150. SELKIES_UPLOAD_DIR="${SELKIES_UPLOAD_DIR}" \
  151. npm run build; \
  152. \
  153. mkdir -p dist/src; \
  154. cp ../selkies-web-core/dist/selkies-core.js dist/src/; \
  155. cp ../universal-touch-gamepad/universalTouchGamepad.js dist/src/; \
  156. cp -r ../selkies-web-core/dist/jsdb dist/; \
  157. \
  158. mkdir -p /out; \
  159. cp -a dist/. /out/; \
  160. test -f /out/index.html
  161. FROM docker.io/library/ubuntu:${DISTRIB_RELEASE} AS pixelflux-legacy-builder
  162. ARG DEBIAN_FRONTEND=noninteractive
  163. ARG PIXELFLUX_VERSION=1.6.4
  164. SHELL ["/bin/bash", "-o", "pipefail", "-c"]
  165. RUN apt-get update \
  166. && apt-get install --no-install-recommends -y \
  167. ca-certificates \
  168. curl \
  169. g++ \
  170. libavcodec-dev \
  171. libavutil-dev \
  172. libjpeg-dev \
  173. libx11-dev \
  174. libx264-dev \
  175. libxext-dev \
  176. libxfixes-dev \
  177. libyuv-dev \
  178. && rm -rf /var/lib/apt/lists/*
  179. WORKDIR /tmp/pixelflux
  180. RUN curl -fsSL \
  181. "https://codeload.github.com/linuxserver/pixelflux/tar.gz/refs/tags/${PIXELFLUX_VERSION}" \
  182. -o /tmp/pixelflux.tar.gz \
  183. && tar -xzf /tmp/pixelflux.tar.gz \
  184. --strip-components=1 \
  185. -C /tmp/pixelflux \
  186. && mkdir -p /out \
  187. && g++ \
  188. -std=c++17 \
  189. -Wno-unused-function \
  190. -fPIC \
  191. -O3 \
  192. -flto \
  193. -shared \
  194. -Ipixelflux/include \
  195. -o /out/screen_capture_module.so \
  196. pixelflux/screen_capture_module.cpp \
  197. pixelflux/include/xxhash.c \
  198. -lX11 \
  199. -lXext \
  200. -lXfixes \
  201. -ljpeg \
  202. -lx264 \
  203. -lyuv \
  204. -ldl \
  205. -lavcodec \
  206. -lavutil \
  207. && test -s /out/screen_capture_module.so
  208. # -----------------------------------------------------------------------------
  209. # Final image
  210. # -----------------------------------------------------------------------------
  211. FROM docker.io/library/ubuntu:${DISTRIB_RELEASE}
  212. ARG DEBIAN_FRONTEND=noninteractive
  213. ARG DISTRIB_RELEASE
  214. ARG TZ=UTC
  215. ARG USER_NAME=ubuntu
  216. ARG USER_UID=1000
  217. ARG USER_GID=1000
  218. LABEL org.opencontainers.image.title="Selkies NVIDIA XFCE Desktop" \
  219. org.opencontainers.image.description="XFCE remote desktop with Selkies, PipeWire and NVIDIA acceleration" \
  220. org.opencontainers.image.source="https://github.com/selkies-project/selkies"
  221. SHELL ["/bin/bash", "-o", "pipefail", "-c"]
  222. ENV TZ="${TZ}" \
  223. LANG="en_US.UTF-8" \
  224. LANGUAGE="en_US:en" \
  225. LC_ALL="en_US.UTF-8" \
  226. PASSWD="mypasswd" \
  227. DISPLAY=":20" \
  228. DISPLAY_SIZEW="1920" \
  229. DISPLAY_SIZEH="1080" \
  230. DISPLAY_REFRESH="60" \
  231. DISPLAY_DPI="96" \
  232. DISPLAY_CDEPTH="24" \
  233. VIDEO_PORT="DFP" \
  234. DESKTOP_SESSION="xfce" \
  235. XDG_SESSION_DESKTOP="xfce" \
  236. XDG_CURRENT_DESKTOP="XFCE" \
  237. XDG_SESSION_TYPE="x11" \
  238. SELKIES_MODE="websockets" \
  239. SELKIES_PORT="8081" \
  240. SELKIES_ENCODER="h264enc" \
  241. SELKIES_ENABLE_RESIZE="false" \
  242. SELKIES_ENABLE_BASIC_AUTH="true" \
  243. NVIDIA_VISIBLE_DEVICES="all" \
  244. NVIDIA_DRIVER_CAPABILITIES="all" \
  245. __GL_SYNC_TO_VBLANK="0" \
  246. __GLX_VENDOR_LIBRARY_NAME="nvidia" \
  247. LIBVA_DRIVER_NAME="nvidia" \
  248. NVD_BACKEND="direct" \
  249. MOZ_DISABLE_RDD_SANDBOX="1" \
  250. MOZ_X11_EGL="1" \
  251. PIPEWIRE_LATENCY="128/48000" \
  252. XDG_RUNTIME_DIR="/tmp/runtime-ubuntu" \
  253. PIPEWIRE_RUNTIME_DIR="/tmp/runtime-ubuntu" \
  254. PULSE_RUNTIME_PATH="/tmp/runtime-ubuntu/pulse" \
  255. PULSE_SERVER="unix:/tmp/runtime-ubuntu/pulse/native" \
  256. DBUS_SYSTEM_BUS_ADDRESS="unix:path=/tmp/runtime-ubuntu/dbus-system-bus" \
  257. APPIMAGE_EXTRACT_AND_RUN="1" \
  258. SUDO_EDITOR="mousepad"
  259. # Bootstrap packages needed to configure APT repositories.
  260. RUN apt-get update \
  261. && apt-get install --no-install-recommends -y \
  262. ca-certificates \
  263. curl \
  264. gnupg \
  265. locales \
  266. ssl-cert \
  267. tzdata \
  268. && locale-gen en_US.UTF-8 fr_FR.UTF-8 \
  269. && ln -snf "/usr/share/zoneinfo/${TZ}" /etc/localtime \
  270. && echo "${TZ}" > /etc/timezone \
  271. && rm -rf /var/lib/apt/lists/*
  272. # Keep the same Mozilla and PipeWire repositories as the original image.
  273. RUN install -d -m 0755 \
  274. /etc/apt/preferences.d \
  275. /etc/apt/sources.list.d \
  276. /etc/apt/trusted.gpg.d \
  277. && printf '%s\n' \
  278. 'Package: firefox*' \
  279. 'Pin: version 1:1snap*' \
  280. 'Pin-Priority: -1' \
  281. > /etc/apt/preferences.d/firefox-nosnap \
  282. && curl -fsSL \
  283. 'https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x738BEB9321D1AAEC13EA9391AEBDF4819BE21867' \
  284. | gpg --dearmor \
  285. > /etc/apt/trusted.gpg.d/mozillateam-ubuntu-ppa.gpg \
  286. && echo \
  287. "deb https://ppa.launchpadcontent.net/mozillateam/ppa/ubuntu noble main" \
  288. > /etc/apt/sources.list.d/mozillateam-ubuntu-ppa.list \
  289. && curl -fsSL \
  290. 'https://keyserver.ubuntu.com/pks/lookup?op=get&search=0xFC43B7352BCC0EC8AF2EEB8B25088A0359807596' \
  291. | gpg --dearmor \
  292. > /etc/apt/trusted.gpg.d/pipewire-debian-ubuntu.gpg \
  293. && echo \
  294. "deb https://ppa.launchpadcontent.net/pipewire-debian/pipewire-upstream/ubuntu noble main" \
  295. > /etc/apt/sources.list.d/pipewire-upstream.list \
  296. && echo \
  297. "deb https://ppa.launchpadcontent.net/pipewire-debian/wireplumber-upstream/ubuntu noble main" \
  298. > /etc/apt/sources.list.d/wireplumber-upstream.list
  299. # Base system, desktop, Xorg, NVIDIA runtime interfaces and user tools.
  300. # There are deliberately no Intel/AMD VA-API or Vulkan drivers and no i386
  301. # architecture.
  302. RUN apt-get update \
  303. && apt-get install --no-install-recommends -y \
  304. apt-utils \
  305. bash-completion \
  306. binutils \
  307. btop \
  308. bzip2 \
  309. clinfo \
  310. dbus-user-session \
  311. dbus-x11 \
  312. desktop-file-utils \
  313. dnsutils \
  314. file \
  315. firefox \
  316. fonts-dejavu \
  317. fonts-liberation \
  318. fonts-noto \
  319. fonts-noto-cjk \
  320. fonts-noto-color-emoji \
  321. fonts-noto-mono \
  322. fonts-ubuntu \
  323. fuse \
  324. git \
  325. gvfs \
  326. jq \
  327. kmod \
  328. less \
  329. libdrm2 \
  330. libegl1 \
  331. libelf-dev \
  332. libgcrypt20 \
  333. libgl1 \
  334. libgles1 \
  335. libgles2 \
  336. libglu1-mesa \
  337. libglvnd-dev \
  338. libglvnd0 \
  339. libglx0 \
  340. libgstreamer-plugins-bad1.0-0 \
  341. libopengl0 \
  342. libopus0 \
  343. libpci3 \
  344. libpulse0 \
  345. libsm6 \
  346. libva-drm2 \
  347. libva-x11-2 \
  348. libva2 \
  349. libvulkan1 \
  350. libx11-6 \
  351. libx11-xcb1 \
  352. libxau6 \
  353. libxcb-dri3-0 \
  354. libxcb1 \
  355. libxdamage1 \
  356. libxdmcp6 \
  357. libxext6 \
  358. libxfixes3 \
  359. libxkbcommon0 \
  360. libxtst6 \
  361. libxv1 \
  362. mousepad \
  363. nano \
  364. neofetch \
  365. net-tools \
  366. ocl-icd-libopencl1 \
  367. pavucontrol \
  368. pciutils \
  369. procps \
  370. psmisc \
  371. python3 \
  372. python3-pip \
  373. python3-venv \
  374. ristretto \
  375. sudo \
  376. supervisor \
  377. thunar \
  378. tumbler \
  379. udev \
  380. unzip \
  381. vainfo \
  382. vim \
  383. vulkan-tools \
  384. wget \
  385. wmctrl \
  386. x11-apps \
  387. x11-utils \
  388. x11-xkb-utils \
  389. x11-xserver-utils \
  390. x264 \
  391. x265 \
  392. xauth \
  393. xbitmaps \
  394. xclip \
  395. xcvt \
  396. xdg-user-dirs \
  397. xdg-utils \
  398. xfce4 \
  399. xfce4-goodies \
  400. xfce4-notifyd \
  401. xfce4-pulseaudio-plugin \
  402. xfce4-terminal \
  403. xfonts-base \
  404. xfonts-scalable \
  405. xinit \
  406. xkb-data \
  407. xsel \
  408. xserver-xorg-core \
  409. xserver-xorg-input-libinput \
  410. xserver-xorg-legacy \
  411. xsettingsd \
  412. xterm \
  413. xdotool \
  414. xz-utils \
  415. zip \
  416. zstd \
  417. pipewire \
  418. pipewire-alsa \
  419. pipewire-audio-client-libraries \
  420. pipewire-jack \
  421. pipewire-libcamera \
  422. pipewire-locales \
  423. pipewire-v4l2 \
  424. pipewire-vulkan \
  425. gstreamer1.0-libcamera \
  426. gstreamer1.0-pipewire \
  427. gir1.2-wp-0.5 \
  428. libpipewire-0.3-modules \
  429. libpipewire-module-x11-bell \
  430. libspa-0.2-bluetooth \
  431. libspa-0.2-jack \
  432. libspa-0.2-modules \
  433. wireplumber \
  434. wireplumber-locales \
  435. apache2-utils \
  436. nginx \
  437. netcat-openbsd \
  438. && apt-get clean \
  439. && rm -rf \
  440. /var/lib/apt/lists/* \
  441. /var/cache/apt/* \
  442. /var/cache/debconf/* \
  443. /var/log/* \
  444. /tmp/* \
  445. /var/tmp/*
  446. # Install only the compiled NVIDIA VA-API runtime from the builder stage.
  447. COPY --from=nvidia-vaapi-builder /out/usr/ /usr/
  448. # Make NVIDIA libraries injected by NVIDIA Container Toolkit discoverable.
  449. RUN printf '%s\n' \
  450. '/usr/local/nvidia/lib' \
  451. '/usr/local/nvidia/lib64' \
  452. > /etc/ld.so.conf.d/nvidia.conf \
  453. && install -d -m 0755 \
  454. /etc/OpenCL/vendors \
  455. /etc/vulkan/icd.d \
  456. /usr/share/glvnd/egl_vendor.d \
  457. && echo 'libnvidia-opencl.so.1' \
  458. > /etc/OpenCL/vendors/nvidia.icd \
  459. && cat > /etc/vulkan/icd.d/nvidia_icd.json <<'EOF'
  460. {
  461. "file_format_version": "1.0.0",
  462. "ICD": {
  463. "library_path": "libGLX_nvidia.so.0",
  464. "api_version": "1.3.0"
  465. }
  466. }
  467. EOF
  468. RUN cat > /usr/share/glvnd/egl_vendor.d/10_nvidia.json <<'EOF'
  469. {
  470. "file_format_version": "1.0.0",
  471. "ICD": {
  472. "library_path": "libEGL_nvidia.so.0"
  473. }
  474. }
  475. EOF
  476. ENV PATH="/opt/selkies/bin:/usr/local/nvidia/bin:${PATH}" \
  477. LD_LIBRARY_PATH="/usr/local/nvidia/lib:/usr/local/nvidia/lib64"
  478. # Install the Selkies wheel from the official stable build image.
  479. COPY --from=selkies-runtime-builder /opt/selkies /opt/selkies
  480. COPY --from=pixelflux-legacy-builder \
  481. /out/screen_capture_module.so \
  482. /tmp/screen_capture_module.so
  483. RUN set -eux; \
  484. PIXELFLUX_DIR="$(/opt/selkies/bin/python -c \
  485. 'from pathlib import Path; import pixelflux; print(Path(pixelflux.__file__).resolve().parent)')"; \
  486. install -m 0755 \
  487. /tmp/screen_capture_module.so \
  488. "${PIXELFLUX_DIR}/screen_capture_module.so"; \
  489. ldd "${PIXELFLUX_DIR}/screen_capture_module.so"; \
  490. test -z "$(ldd "${PIXELFLUX_DIR}/screen_capture_module.so" | grep 'not found' || true)"; \
  491. rm -f /tmp/screen_capture_module.so
  492. COPY --chown=${USER_UID}:${USER_GID} \
  493. --from=selkies-web-builder \
  494. /out/ \
  495. /opt/selkies-web/
  496. COPY --from=selkies-js-interposer-builder \
  497. /out/selkies_joystick_interposer.so \
  498. /usr/local/lib/selkies_joystick_interposer.so
  499. RUN chmod 0755 /usr/local/lib/selkies_joystick_interposer.so
  500. # Create the regular desktop user. sudo-root is kept because Xorg and the
  501. # NVIDIA userspace installer need a few targeted root operations at runtime.
  502. RUN set -eux; \
  503. if ! getent group "${USER_NAME}" >/dev/null; then \
  504. groupadd --gid "${USER_GID}" "${USER_NAME}"; \
  505. fi; \
  506. if ! id -u "${USER_NAME}" >/dev/null 2>&1; then \
  507. useradd \
  508. --uid "${USER_UID}" \
  509. --gid "${USER_NAME}" \
  510. --create-home \
  511. --shell /bin/bash \
  512. "${USER_NAME}"; \
  513. else \
  514. usermod --shell /bin/bash "${USER_NAME}"; \
  515. fi; \
  516. for group in \
  517. adm audio cdrom dialout dip fax floppy games input lp plugdev render \
  518. ssl-cert sudo tape tty video voice; \
  519. do \
  520. getent group "${group}" >/dev/null \
  521. && usermod -aG "${group}" "${USER_NAME}" \
  522. || true; \
  523. done; \
  524. echo "${USER_NAME} ALL=(ALL:ALL) NOPASSWD: ALL" \
  525. > "/etc/sudoers.d/${USER_NAME}"; \
  526. chmod 0440 "/etc/sudoers.d/${USER_NAME}"; \
  527. echo "${USER_NAME}:${PASSWD}" | chpasswd; \
  528. cp -a /usr/bin/sudo /usr/bin/sudo-root; \
  529. chown root:root /usr/bin/sudo-root; \
  530. chmod 4755 /usr/bin/sudo-root; \
  531. install -d \
  532. -o "${USER_UID}" \
  533. -g "${USER_GID}" \
  534. -m 0700 \
  535. /tmp/runtime-ubuntu; \
  536. chown -R \
  537. "${USER_UID}:${USER_GID}" \
  538. "/home/${USER_NAME}" \
  539. /etc/X11 \
  540. /opt/selkies
  541. # XFCE defaults suitable for a permanently streamed desktop.
  542. RUN install -d -m 0755 \
  543. /etc/xdg/xfce4/xfconf/xfce-perchannel-xml \
  544. /etc/firefox/policies \
  545. && if [[ -f /etc/xdg/xfce4/panel/default.xml ]]; then \
  546. cp -f \
  547. /etc/xdg/xfce4/panel/default.xml \
  548. /etc/xdg/xfce4/xfconf/xfce-perchannel-xml/xfce4-panel.xml; \
  549. fi \
  550. && cat > /etc/xdg/xfce4/xfconf/xfce-perchannel-xml/xfce4-power-manager.xml <<'EOF'
  551. <?xml version="1.0" encoding="UTF-8"?>
  552. <channel name="xfce4-power-manager" version="1.0">
  553. <property name="xfce4-power-manager" type="empty">
  554. <property name="blank-on-ac" type="int" value="0"/>
  555. <property name="dpms-enabled" type="bool" value="false"/>
  556. <property name="lock-screen-suspend-hibernate" type="bool" value="false"/>
  557. </property>
  558. </channel>
  559. EOF
  560. RUN cat > /etc/firefox/policies/policies.json <<'EOF'
  561. {
  562. "policies": {
  563. "Preferences": {
  564. "gfx.x11-egl.force-enabled": {
  565. "Value": true,
  566. "Status": "default"
  567. },
  568. "media.ffmpeg.vaapi.enabled": {
  569. "Value": true,
  570. "Status": "default"
  571. },
  572. "media.hardware-video-decoding.force-enabled": {
  573. "Value": true,
  574. "Status": "default"
  575. },
  576. "media.rdd-ffmpeg.enabled": {
  577. "Value": true,
  578. "Status": "default"
  579. }
  580. }
  581. }
  582. }
  583. EOF
  584. RUN update-alternatives --set x-www-browser /usr/bin/firefox \
  585. || true
  586. # The three files below must be placed beside this Dockerfile.
  587. COPY --chown=${USER_UID}:${USER_GID} entrypoint.sh /etc/entrypoint.sh
  588. COPY --chown=${USER_UID}:${USER_GID} selkies-entrypoint.sh /etc/selkies-entrypoint.sh
  589. COPY --chown=${USER_UID}:${USER_GID} supervisord.conf /etc/supervisord.conf
  590. COPY --chown=${USER_UID}:${USER_GID} nginx.conf /etc/nginx/nginx.conf
  591. COPY --chown=${USER_UID}:${USER_GID} nginx-entrypoint.sh /etc/nginx-entrypoint.sh
  592. RUN sed -i 's/\r$//' \
  593. /etc/entrypoint.sh \
  594. /etc/selkies-entrypoint.sh \
  595. /etc/nginx-entrypoint.sh \
  596. && chmod 0755 \
  597. /etc/entrypoint.sh \
  598. /etc/selkies-entrypoint.sh \
  599. /etc/nginx-entrypoint.sh \
  600. /etc/supervisord.conf
  601. USER ${USER_UID}:${USER_GID}
  602. ENV USER="${USER_NAME}" \
  603. HOME="/home/${USER_NAME}" \
  604. SHELL="/bin/bash"
  605. WORKDIR /home/${USER_NAME}
  606. EXPOSE 8080
  607. ENTRYPOINT ["/usr/bin/supervisord", "-c", "/etc/supervisord.conf"]