Dockerfile 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601
  1. # syntax=docker/dockerfile:1.7
  2. # =============================================================================
  3. # Versions
  4. # =============================================================================
  5. # Update these values whenever the NVIDIA GPU Operator driver changes.
  6. ARG NVIDIA_DRIVER_BRANCH=580
  7. ARG NVIDIA_DRIVER_VERSION=580.126.20
  8. ARG NVIDIA_DRIVER_PACKAGE_VERSION=580.126.20-1ubuntu1
  9. ARG SUNSHINE_REF=0784774
  10. ARG BUILD_DEPS_VERSION=v2026.724.203728
  11. ARG NV_CODEC_HEADERS_VERSION=n13.0.19.1
  12. # ============================================================================
  13. # Build du FFmpeg utilisé par Sunshine
  14. # nv-codec-headers volontairement limité à NVENC API 13.0
  15. # ============================================================================
  16. FROM docker.io/library/ubuntu:24.04 AS ffmpeg-build
  17. ARG BUILD_DEPS_VERSION
  18. ARG NV_CODEC_HEADERS_VERSION
  19. ENV DEBIAN_FRONTEND=noninteractive
  20. RUN apt-get update && \
  21. apt-get install -y --no-install-recommends \
  22. autoconf \
  23. automake \
  24. build-essential \
  25. ca-certificates \
  26. cmake \
  27. git \
  28. libass-dev \
  29. libfreetype6-dev \
  30. libgnutls28-dev \
  31. libmp3lame-dev \
  32. libnuma-dev \
  33. libopus-dev \
  34. libsdl2-dev \
  35. libtool \
  36. libvorbis-dev \
  37. libxcb1-dev \
  38. libxcb-shm0-dev \
  39. libxcb-xfixes0-dev \
  40. libx11-xcb-dev \
  41. libxcb-dri3-dev \
  42. make \
  43. meson \
  44. nasm \
  45. ninja-build \
  46. pkg-config \
  47. texinfo \
  48. wget \
  49. zlib1g-dev && \
  50. rm -rf /var/lib/apt/lists/*
  51. RUN git clone \
  52. --branch "${BUILD_DEPS_VERSION}" \
  53. --depth 1 \
  54. --recurse-submodules \
  55. https://github.com/LizardByte/build-deps.git \
  56. /src/build-deps
  57. # Le point important :
  58. # on remplace les nv-codec-headers utilisés pour compiler FFmpeg
  59. # par la dernière release API 13.0.
  60. RUN rm -rf /src/build-deps/third-party/FFmpeg/nv-codec-headers && \
  61. git clone \
  62. --branch "${NV_CODEC_HEADERS_VERSION}" \
  63. --depth 1 \
  64. https://github.com/FFmpeg/nv-codec-headers.git \
  65. /src/build-deps/third-party/FFmpeg/nv-codec-headers
  66. RUN cmake \
  67. -S /src/build-deps \
  68. -B /src/build-deps/build \
  69. -G "Unix Makefiles" \
  70. -DCMAKE_BUILD_TYPE=Release \
  71. -DCMAKE_INSTALL_PREFIX=/opt/build-deps \
  72. -DBUILD_ALL=OFF \
  73. -DBUILD_FFMPEG=ON \
  74. -DBUILD_FFMPEG_NV_CODEC_HEADERS=ON \
  75. -DBUILD_FFMPEG_CUDA_LLVM=OFF \
  76. -DBUILD_TESTS=OFF \
  77. -DBUILD_DOCS=OFF && \
  78. cmake --build /src/build-deps/build --parallel "$(nproc)" && \
  79. cmake --install /src/build-deps/build
  80. # ============================================================================
  81. # Build de Sunshine avec notre FFmpeg
  82. # ============================================================================
  83. FROM docker.io/nvidia/cuda:12.9.1-devel-ubuntu24.04 AS sunshine-build
  84. ARG SUNSHINE_REF
  85. ENV DEBIAN_FRONTEND=noninteractive
  86. RUN apt-get update && \
  87. apt-get install -y --no-install-recommends \
  88. ca-certificates \
  89. git && \
  90. rm -rf /var/lib/apt/lists/*
  91. RUN git clone \
  92. --filter=blob:none \
  93. https://github.com/LizardByte/Sunshine.git \
  94. /src/sunshine && \
  95. cd /src/sunshine && \
  96. git checkout "${SUNSHINE_REF}" && \
  97. git submodule update --init --recursive --depth 1
  98. # Installation des dépendances de compilation de Sunshine.
  99. # --skip-cuda désactive NVFBC/CUDA dans Sunshine, PAS NVENC via FFmpeg.
  100. RUN cd /src/sunshine && \
  101. ./scripts/linux_build.sh \
  102. --sudo-off \
  103. --skip-cuda \
  104. --step=deps
  105. # Remplacement du FFmpeg précompilé de LizardByte par le nôtre.
  106. COPY --from=ffmpeg-build /opt/build-deps/ffmpeg /tmp/custom-ffmpeg
  107. RUN cd /src/sunshine && \
  108. ./scripts/linux_build.sh \
  109. --sudo-off \
  110. --step=cmake
  111. RUN rm -rf /src/sunshine/build/_deps/ffmpeg && \
  112. mkdir -p /src/sunshine/build/_deps/ffmpeg && \
  113. cp -a \
  114. /tmp/custom-ffmpeg/. \
  115. /src/sunshine/build/_deps/ffmpeg/
  116. RUN cd /src/sunshine && \
  117. ./scripts/linux_build.sh \
  118. --sudo-off \
  119. --step=build && \
  120. ./scripts/linux_build.sh \
  121. --sudo-off \
  122. --step=package && \
  123. cp /src/sunshine/build/cpack_artifacts/Sunshine.deb /sunshine.deb
  124. # =============================================================================
  125. # Main image
  126. # =============================================================================
  127. FROM docker.io/library/ubuntu:24.04
  128. ARG NVIDIA_DRIVER_BRANCH
  129. ARG NVIDIA_DRIVER_VERSION
  130. ARG NVIDIA_DRIVER_PACKAGE_VERSION
  131. ARG USER_NAME=ubuntu
  132. ARG USER_UID=1000
  133. ARG USER_GID=1000
  134. ENV DEBIAN_FRONTEND=noninteractive \
  135. HOME=/home/ubuntu \
  136. USER=ubuntu \
  137. DISPLAY=:20 \
  138. DISPLAY_SIZEW=1920 \
  139. DISPLAY_SIZEH=1080 \
  140. DISPLAY_REFRESH=120 \
  141. DISPLAY_DPI=96 \
  142. DISPLAY_CDEPTH=24 \
  143. VIDEO_PORT=HDMI-0 \
  144. TZ=Europe/Paris \
  145. LANG=fr_FR.UTF-8 \
  146. LANGUAGE=fr_FR:fr \
  147. LC_ALL=fr_FR.UTF-8 \
  148. XDG_RUNTIME_DIR=/tmp/runtime-ubuntu \
  149. PIPEWIRE_RUNTIME_DIR=/tmp/runtime-ubuntu \
  150. PULSE_RUNTIME_PATH=/tmp/runtime-ubuntu/pulse \
  151. PULSE_SERVER=unix:/tmp/runtime-ubuntu/pulse/native \
  152. NVIDIA_VISIBLE_DEVICES=all \
  153. NVIDIA_DRIVER_CAPABILITIES=all \
  154. EXPECTED_NVIDIA_DRIVER_VERSION=${NVIDIA_DRIVER_VERSION} \
  155. NVIDIA_I386_PACKAGE_VERSION=${NVIDIA_DRIVER_PACKAGE_VERSION}
  156. SHELL ["/bin/bash", "-o", "pipefail", "-c"]
  157. USER root
  158. # =============================================================================
  159. # Base desktop / gaming environment
  160. # =============================================================================
  161. RUN dpkg --add-architecture i386 \
  162. && apt-get update \
  163. && apt-get install --no-install-recommends -y \
  164. btop fonts-noto-cjk fonts-ubuntu mousepad nano ristretto thunar \
  165. ubuntu-wallpapers \
  166. adwaita-icon-theme \
  167. elementary-xfce-icon-theme \
  168. greybird-gtk-theme \
  169. hicolor-icon-theme \
  170. humanity-icon-theme \
  171. keyboard-configuration \
  172. tango-icon-theme \
  173. xfce4-goodies \
  174. xfce4-notifyd \
  175. xfce4-pulseaudio-plugin \
  176. xfonts-base \
  177. xfonts-scalable \
  178. alsa-utils \
  179. ca-certificates \
  180. curl \
  181. dbus \
  182. dbus-user-session \
  183. dbus-x11 \
  184. file \
  185. fonts-dejavu \
  186. fonts-liberation \
  187. fonts-noto \
  188. fonts-noto-color-emoji \
  189. kmod \
  190. libasound2-plugins \
  191. libcap2-bin \
  192. libegl1 \
  193. libgbm1 \
  194. libgl1 \
  195. libglvnd0 \
  196. libglx0 \
  197. libpciaccess0 \
  198. libpulse0 \
  199. libvulkan1 \
  200. libx11-6 \
  201. libx11-xcb1 \
  202. libxdamage1 \
  203. libxext6 \
  204. libxfixes3 \
  205. libxinerama1 \
  206. libxrandr2 \
  207. libxss1 \
  208. libxtst6 \
  209. locales \
  210. mesa-utils \
  211. pciutils \
  212. pipewire \
  213. pipewire-pulse \
  214. procps \
  215. psmisc \
  216. pulseaudio-utils \
  217. sudo \
  218. supervisor \
  219. tzdata \
  220. udev \
  221. vulkan-tools \
  222. wireplumber \
  223. x11-utils \
  224. x11-xserver-utils \
  225. xauth \
  226. xcvt \
  227. xdg-user-dirs \
  228. xdg-utils \
  229. xfce4 \
  230. xfce4-terminal \
  231. xkb-data \
  232. xserver-xorg-core \
  233. xserver-xorg-input-libinput \
  234. xserver-xorg-legacy \
  235. xz-utils \
  236. && sed -i \
  237. -e 's/^# *fr_FR.UTF-8 UTF-8/fr_FR.UTF-8 UTF-8/' \
  238. -e 's/^# *en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' \
  239. /etc/locale.gen \
  240. && locale-gen \
  241. && apt-get clean \
  242. && rm -rf \
  243. /var/lib/apt/lists/* \
  244. /var/cache/apt/* \
  245. /var/cache/debconf/* \
  246. /tmp/* \
  247. /var/tmp/*
  248. # =============================================================================
  249. # Desktop user
  250. # =============================================================================
  251. RUN set -eux; \
  252. if ! getent group "${USER_GID}" >/dev/null; then \
  253. groupadd --gid "${USER_GID}" "${USER_NAME}"; \
  254. fi; \
  255. if ! id -u "${USER_NAME}" >/dev/null 2>&1; then \
  256. useradd \
  257. --uid "${USER_UID}" \
  258. --gid "${USER_GID}" \
  259. --create-home \
  260. --shell /bin/bash \
  261. "${USER_NAME}"; \
  262. else \
  263. usermod --shell /bin/bash "${USER_NAME}"; \
  264. fi; \
  265. for group in \
  266. audio \
  267. games \
  268. input \
  269. render \
  270. tty \
  271. video; \
  272. do \
  273. getent group "${group}" >/dev/null \
  274. && usermod -aG "${group}" "${USER_NAME}" \
  275. || true; \
  276. done; \
  277. echo "${USER_NAME} ALL=(ALL:ALL) NOPASSWD: ALL" \
  278. > "/etc/sudoers.d/${USER_NAME}"; \
  279. chmod 0440 "/etc/sudoers.d/${USER_NAME}"; \
  280. install \
  281. -d \
  282. -o "${USER_UID}" \
  283. -g "${USER_GID}" \
  284. -m 0700 \
  285. /tmp/runtime-ubuntu; \
  286. install \
  287. -d \
  288. -o "${USER_UID}" \
  289. -g "${USER_GID}" \
  290. /home/${USER_NAME}/.config/sunshine \
  291. /games
  292. # =============================================================================
  293. # NVIDIA repository + nvidia-xconfig
  294. #
  295. # Only the userspace Xorg configuration utility is installed here.
  296. # The kernel driver remains fully managed by the NVIDIA GPU Operator.
  297. # =============================================================================
  298. RUN curl -fsSLO \
  299. https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2404/x86_64/cuda-keyring_1.1-1_all.deb \
  300. && dpkg -i cuda-keyring_1.1-1_all.deb \
  301. && rm -f cuda-keyring_1.1-1_all.deb \
  302. && apt-get update \
  303. && apt-get install --no-install-recommends -y \
  304. "nvidia-xconfig=${NVIDIA_DRIVER_PACKAGE_VERSION}" \
  305. && nvidia-xconfig --version \
  306. && apt-get clean \
  307. && rm -rf \
  308. /var/lib/apt/lists/* \
  309. /var/cache/apt/*
  310. # =============================================================================
  311. # NVIDIA Xorg driver modules
  312. #
  313. # Extract only the Xorg-side NVIDIA modules matching the host driver.
  314. # Do not install the whole amd64 NVIDIA userspace stack with APT.
  315. # =============================================================================
  316. RUN cd /tmp \
  317. && apt-get update \
  318. && apt-get download \
  319. "xserver-xorg-video-nvidia-${NVIDIA_DRIVER_BRANCH}=${NVIDIA_DRIVER_PACKAGE_VERSION}" \
  320. && mkdir -p /tmp/nvidia-xorg \
  321. && dpkg-deb -x \
  322. "xserver-xorg-video-nvidia-${NVIDIA_DRIVER_BRANCH}_${NVIDIA_DRIVER_PACKAGE_VERSION}_amd64.deb" \
  323. /tmp/nvidia-xorg \
  324. && install -D -m 0755 \
  325. /tmp/nvidia-xorg/usr/lib/xorg/modules/drivers/nvidia_drv.so \
  326. /usr/lib/xorg/modules/drivers/nvidia_drv.so \
  327. && cp -a \
  328. /tmp/nvidia-xorg/usr/lib/xorg/modules/extensions/libglxserver_nvidia.so* \
  329. /usr/lib/xorg/modules/extensions/ \
  330. && rm -rf \
  331. /tmp/nvidia-xorg \
  332. /tmp/xserver-xorg-video-nvidia-*.deb \
  333. /var/lib/apt/lists/*
  334. # =============================================================================
  335. # NVIDIA GLVND / Vulkan configuration
  336. #
  337. # Actual 64-bit NVIDIA libraries are injected at runtime by the GPU Operator /
  338. # NVIDIA Container Toolkit.
  339. # =============================================================================
  340. RUN printf '%s\n' \
  341. '/usr/local/nvidia/lib' \
  342. '/usr/local/nvidia/lib64' \
  343. > /etc/ld.so.conf.d/nvidia.conf \
  344. && install -d -m 0755 \
  345. /etc/vulkan/icd.d \
  346. /usr/share/glvnd/egl_vendor.d \
  347. && cat > /etc/vulkan/icd.d/nvidia_icd.json <<'EOF'
  348. {
  349. "file_format_version": "1.0.0",
  350. "ICD": {
  351. "library_path": "libGLX_nvidia.so.0",
  352. "api_version": "1.3.0"
  353. }
  354. }
  355. EOF
  356. RUN cat > /usr/share/glvnd/egl_vendor.d/10_nvidia.json <<'EOF'
  357. {
  358. "file_format_version": "1.0.0",
  359. "ICD": {
  360. "library_path": "libEGL_nvidia.so.0"
  361. }
  362. }
  363. EOF
  364. # =============================================================================
  365. # Sunshine
  366. # =============================================================================
  367. COPY --from=sunshine-build /sunshine.deb /tmp/sunshine.deb
  368. RUN apt-get update \
  369. && apt-get install --no-install-recommends -y \
  370. /tmp/sunshine.deb \
  371. && setcap cap_sys_admin,cap_dac_override=ep \
  372. "$(command -v sunshine)" \
  373. && rm -f /tmp/sunshine.deb \
  374. && apt-get clean \
  375. && rm -rf \
  376. /var/lib/apt/lists/* \
  377. /var/cache/apt/*
  378. # =============================================================================
  379. # Steam + 32-bit Linux gaming runtime
  380. # =============================================================================
  381. RUN dpkg --add-architecture i386 \
  382. && apt-get update \
  383. && apt-get install --no-install-recommends -y \
  384. ca-certificates \
  385. curl \
  386. && curl -fsSL \
  387. https://repo.steampowered.com/steam/archive/stable/steam.gpg \
  388. -o /usr/share/keyrings/steam.gpg \
  389. && printf '%s\n' \
  390. 'deb [arch=amd64,i386 signed-by=/usr/share/keyrings/steam.gpg] https://repo.steampowered.com/steam/ stable steam' \
  391. > /etc/apt/sources.list.d/steam-bootstrap.list \
  392. && apt-get update \
  393. && apt-get install --no-install-recommends -y \
  394. steam-launcher \
  395. steam-libs-amd64 \
  396. steam-libs-i386 \
  397. libegl1:amd64 \
  398. libegl1:i386 \
  399. libgbm1:amd64 \
  400. libgbm1:i386 \
  401. libgl1:amd64 \
  402. libgl1:i386 \
  403. libgl1-mesa-dri:amd64 \
  404. libgl1-mesa-dri:i386 \
  405. libglx-mesa0:amd64 \
  406. libglx-mesa0:i386 \
  407. libvulkan1:amd64 \
  408. libvulkan1:i386 \
  409. xdg-desktop-portal \
  410. xdg-desktop-portal-gtk \
  411. && rm -f /etc/apt/sources.list.d/steam-bootstrap.list \
  412. && apt-get clean \
  413. && rm -rf \
  414. /var/lib/apt/lists/* \
  415. /var/cache/apt/*
  416. # =============================================================================
  417. # Non-snap Firefox
  418. # =============================================================================
  419. RUN install -d -m 0755 /etc/apt/keyrings \
  420. && curl -fsSL https://packages.mozilla.org/apt/repo-signing-key.gpg \
  421. -o /etc/apt/keyrings/packages.mozilla.org.asc \
  422. && echo "deb [signed-by=/etc/apt/keyrings/packages.mozilla.org.asc] https://packages.mozilla.org/apt mozilla main" \
  423. > /etc/apt/sources.list.d/mozilla.list \
  424. && printf '%s\n' \
  425. 'Package: *' \
  426. 'Pin: origin packages.mozilla.org' \
  427. 'Pin-Priority: 1000' \
  428. > /etc/apt/preferences.d/mozilla \
  429. && apt-get update \
  430. && apt-get install --no-install-recommends -y \
  431. firefox \
  432. firefox-l10n-fr \
  433. && apt-get clean
  434. # =============================================================================
  435. # NVIDIA 32-bit userspace
  436. #
  437. # The GPU Operator currently does not provide the compat32 libraries required
  438. # by 32-bit OpenGL applications and Proton/DXVK.
  439. #
  440. # Install the exact userspace version matching the host driver, then keep a
  441. # protected copy under /opt. The NVIDIA runtime can remove/mask the files in
  442. # /usr/lib/i386-linux-gnu when the pod starts; sunshine-entrypoint.sh restores
  443. # them afterwards.
  444. # =============================================================================
  445. RUN dpkg --add-architecture i386 \
  446. && apt-get update \
  447. && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
  448. "libnvidia-common-${NVIDIA_DRIVER_BRANCH}=${NVIDIA_DRIVER_PACKAGE_VERSION}" \
  449. "libnvidia-gpucomp-${NVIDIA_DRIVER_BRANCH}:i386=${NVIDIA_DRIVER_PACKAGE_VERSION}" \
  450. "libnvidia-decode-${NVIDIA_DRIVER_BRANCH}:i386=${NVIDIA_DRIVER_PACKAGE_VERSION}" \
  451. "libnvidia-compute-${NVIDIA_DRIVER_BRANCH}:i386=${NVIDIA_DRIVER_PACKAGE_VERSION}" \
  452. "libnvidia-gl-${NVIDIA_DRIVER_BRANCH}:i386=${NVIDIA_DRIVER_PACKAGE_VERSION}" \
  453. && mkdir -p /opt/nvidia-i386 \
  454. && for file in $( \
  455. dpkg -L \
  456. "libnvidia-gl-${NVIDIA_DRIVER_BRANCH}:i386" \
  457. "libnvidia-compute-${NVIDIA_DRIVER_BRANCH}:i386" \
  458. "libnvidia-decode-${NVIDIA_DRIVER_BRANCH}:i386" \
  459. "libnvidia-gpucomp-${NVIDIA_DRIVER_BRANCH}:i386" \
  460. | grep '^/usr/lib/i386-linux-gnu/' \
  461. | sort -u \
  462. ); do \
  463. if [[ -e "${file}" || -L "${file}" ]]; then \
  464. cp -a --parents "${file}" /opt/nvidia-i386/; \
  465. fi; \
  466. done \
  467. && test -e \
  468. /opt/nvidia-i386/usr/lib/i386-linux-gnu/libGLX_nvidia.so.0 \
  469. && test -e \
  470. "/opt/nvidia-i386/usr/lib/i386-linux-gnu/libnvidia-glcore.so.${NVIDIA_DRIVER_VERSION}" \
  471. && ldconfig \
  472. && apt-get clean \
  473. && rm -rf \
  474. /var/lib/apt/lists/* \
  475. /var/cache/apt/*
  476. # Keep APT package indexes available for Steam's dependency checker.
  477. RUN apt-get update \
  478. && apt-get clean
  479. # =============================================================================
  480. # Runtime scripts
  481. # =============================================================================
  482. COPY desktop-entrypoint.sh /etc/desktop-entrypoint.sh
  483. COPY sunshine-entrypoint.sh /etc/sunshine-entrypoint.sh
  484. COPY supervisord.conf /etc/supervisord.conf
  485. RUN sed -i 's/\r$//' \
  486. /etc/desktop-entrypoint.sh \
  487. /etc/sunshine-entrypoint.sh \
  488. /etc/supervisord.conf \
  489. && chmod 0755 \
  490. /etc/desktop-entrypoint.sh \
  491. /etc/sunshine-entrypoint.sh \
  492. && chmod 0644 \
  493. /etc/supervisord.conf
  494. # =============================================================================
  495. # Final filesystem permissions
  496. # =============================================================================
  497. RUN chown -R \
  498. "${USER_UID}:${USER_GID}" \
  499. "/home/${USER_NAME}" \
  500. /tmp/runtime-ubuntu
  501. # =============================================================================
  502. # Sanity checks
  503. # =============================================================================
  504. RUN command -v \
  505. steam \
  506. && command -v \
  507. nvidia-xconfig \
  508. && command -v \
  509. supervisord \
  510. && command -v \
  511. pipewire \
  512. && command -v \
  513. wireplumber \
  514. && command -v \
  515. Xorg \
  516. && command -v \
  517. xfce4-session \
  518. && test -x \
  519. /etc/sunshine-entrypoint.sh \
  520. && test -x \
  521. /etc/desktop-entrypoint.sh
  522. # =============================================================================
  523. # Runtime
  524. # =============================================================================
  525. USER 1000:1000
  526. WORKDIR /home/ubuntu
  527. STOPSIGNAL SIGTERM
  528. ENTRYPOINT ["/etc/sunshine-entrypoint.sh"]