Dockerfile 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604
  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. mate-themes \
  237. neofetch \
  238. wmctrl \
  239. && sed -i \
  240. -e 's/^# *fr_FR.UTF-8 UTF-8/fr_FR.UTF-8 UTF-8/' \
  241. -e 's/^# *en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' \
  242. /etc/locale.gen \
  243. && locale-gen \
  244. && apt-get clean \
  245. && rm -rf \
  246. /var/lib/apt/lists/* \
  247. /var/cache/apt/* \
  248. /var/cache/debconf/* \
  249. /tmp/* \
  250. /var/tmp/*
  251. # =============================================================================
  252. # Desktop user
  253. # =============================================================================
  254. RUN set -eux; \
  255. if ! getent group "${USER_GID}" >/dev/null; then \
  256. groupadd --gid "${USER_GID}" "${USER_NAME}"; \
  257. fi; \
  258. if ! id -u "${USER_NAME}" >/dev/null 2>&1; then \
  259. useradd \
  260. --uid "${USER_UID}" \
  261. --gid "${USER_GID}" \
  262. --create-home \
  263. --shell /bin/bash \
  264. "${USER_NAME}"; \
  265. else \
  266. usermod --shell /bin/bash "${USER_NAME}"; \
  267. fi; \
  268. for group in \
  269. audio \
  270. games \
  271. input \
  272. render \
  273. tty \
  274. video; \
  275. do \
  276. getent group "${group}" >/dev/null \
  277. && usermod -aG "${group}" "${USER_NAME}" \
  278. || true; \
  279. done; \
  280. echo "${USER_NAME} ALL=(ALL:ALL) NOPASSWD: ALL" \
  281. > "/etc/sudoers.d/${USER_NAME}"; \
  282. chmod 0440 "/etc/sudoers.d/${USER_NAME}"; \
  283. install \
  284. -d \
  285. -o "${USER_UID}" \
  286. -g "${USER_GID}" \
  287. -m 0700 \
  288. /tmp/runtime-ubuntu; \
  289. install \
  290. -d \
  291. -o "${USER_UID}" \
  292. -g "${USER_GID}" \
  293. /home/${USER_NAME}/.config/sunshine \
  294. /games
  295. # =============================================================================
  296. # NVIDIA repository + nvidia-xconfig
  297. #
  298. # Only the userspace Xorg configuration utility is installed here.
  299. # The kernel driver remains fully managed by the NVIDIA GPU Operator.
  300. # =============================================================================
  301. RUN curl -fsSLO \
  302. https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2404/x86_64/cuda-keyring_1.1-1_all.deb \
  303. && dpkg -i cuda-keyring_1.1-1_all.deb \
  304. && rm -f cuda-keyring_1.1-1_all.deb \
  305. && apt-get update \
  306. && apt-get install --no-install-recommends -y \
  307. "nvidia-xconfig=${NVIDIA_DRIVER_PACKAGE_VERSION}" \
  308. && nvidia-xconfig --version \
  309. && apt-get clean \
  310. && rm -rf \
  311. /var/lib/apt/lists/* \
  312. /var/cache/apt/*
  313. # =============================================================================
  314. # NVIDIA Xorg driver modules
  315. #
  316. # Extract only the Xorg-side NVIDIA modules matching the host driver.
  317. # Do not install the whole amd64 NVIDIA userspace stack with APT.
  318. # =============================================================================
  319. RUN cd /tmp \
  320. && apt-get update \
  321. && apt-get download \
  322. "xserver-xorg-video-nvidia-${NVIDIA_DRIVER_BRANCH}=${NVIDIA_DRIVER_PACKAGE_VERSION}" \
  323. && mkdir -p /tmp/nvidia-xorg \
  324. && dpkg-deb -x \
  325. "xserver-xorg-video-nvidia-${NVIDIA_DRIVER_BRANCH}_${NVIDIA_DRIVER_PACKAGE_VERSION}_amd64.deb" \
  326. /tmp/nvidia-xorg \
  327. && install -D -m 0755 \
  328. /tmp/nvidia-xorg/usr/lib/xorg/modules/drivers/nvidia_drv.so \
  329. /usr/lib/xorg/modules/drivers/nvidia_drv.so \
  330. && cp -a \
  331. /tmp/nvidia-xorg/usr/lib/xorg/modules/extensions/libglxserver_nvidia.so* \
  332. /usr/lib/xorg/modules/extensions/ \
  333. && rm -rf \
  334. /tmp/nvidia-xorg \
  335. /tmp/xserver-xorg-video-nvidia-*.deb \
  336. /var/lib/apt/lists/*
  337. # =============================================================================
  338. # NVIDIA GLVND / Vulkan configuration
  339. #
  340. # Actual 64-bit NVIDIA libraries are injected at runtime by the GPU Operator /
  341. # NVIDIA Container Toolkit.
  342. # =============================================================================
  343. RUN printf '%s\n' \
  344. '/usr/local/nvidia/lib' \
  345. '/usr/local/nvidia/lib64' \
  346. > /etc/ld.so.conf.d/nvidia.conf \
  347. && install -d -m 0755 \
  348. /etc/vulkan/icd.d \
  349. /usr/share/glvnd/egl_vendor.d \
  350. && cat > /etc/vulkan/icd.d/nvidia_icd.json <<'EOF'
  351. {
  352. "file_format_version": "1.0.0",
  353. "ICD": {
  354. "library_path": "libGLX_nvidia.so.0",
  355. "api_version": "1.3.0"
  356. }
  357. }
  358. EOF
  359. RUN cat > /usr/share/glvnd/egl_vendor.d/10_nvidia.json <<'EOF'
  360. {
  361. "file_format_version": "1.0.0",
  362. "ICD": {
  363. "library_path": "libEGL_nvidia.so.0"
  364. }
  365. }
  366. EOF
  367. # =============================================================================
  368. # Sunshine
  369. # =============================================================================
  370. COPY --from=sunshine-build /sunshine.deb /tmp/sunshine.deb
  371. RUN apt-get update \
  372. && apt-get install --no-install-recommends -y \
  373. /tmp/sunshine.deb \
  374. && setcap cap_sys_admin,cap_dac_override=ep \
  375. "$(command -v sunshine)" \
  376. && rm -f /tmp/sunshine.deb \
  377. && apt-get clean \
  378. && rm -rf \
  379. /var/lib/apt/lists/* \
  380. /var/cache/apt/*
  381. # =============================================================================
  382. # Steam + 32-bit Linux gaming runtime
  383. # =============================================================================
  384. RUN dpkg --add-architecture i386 \
  385. && apt-get update \
  386. && apt-get install --no-install-recommends -y \
  387. ca-certificates \
  388. curl \
  389. && curl -fsSL \
  390. https://repo.steampowered.com/steam/archive/stable/steam.gpg \
  391. -o /usr/share/keyrings/steam.gpg \
  392. && printf '%s\n' \
  393. 'deb [arch=amd64,i386 signed-by=/usr/share/keyrings/steam.gpg] https://repo.steampowered.com/steam/ stable steam' \
  394. > /etc/apt/sources.list.d/steam-bootstrap.list \
  395. && apt-get update \
  396. && apt-get install --no-install-recommends -y \
  397. steam-launcher \
  398. steam-libs-amd64 \
  399. steam-libs-i386 \
  400. libegl1:amd64 \
  401. libegl1:i386 \
  402. libgbm1:amd64 \
  403. libgbm1:i386 \
  404. libgl1:amd64 \
  405. libgl1:i386 \
  406. libgl1-mesa-dri:amd64 \
  407. libgl1-mesa-dri:i386 \
  408. libglx-mesa0:amd64 \
  409. libglx-mesa0:i386 \
  410. libvulkan1:amd64 \
  411. libvulkan1:i386 \
  412. xdg-desktop-portal \
  413. xdg-desktop-portal-gtk \
  414. && rm -f /etc/apt/sources.list.d/steam-bootstrap.list \
  415. && apt-get clean \
  416. && rm -rf \
  417. /var/lib/apt/lists/* \
  418. /var/cache/apt/*
  419. # =============================================================================
  420. # Non-snap Firefox
  421. # =============================================================================
  422. RUN install -d -m 0755 /etc/apt/keyrings \
  423. && curl -fsSL https://packages.mozilla.org/apt/repo-signing-key.gpg \
  424. -o /etc/apt/keyrings/packages.mozilla.org.asc \
  425. && echo "deb [signed-by=/etc/apt/keyrings/packages.mozilla.org.asc] https://packages.mozilla.org/apt mozilla main" \
  426. > /etc/apt/sources.list.d/mozilla.list \
  427. && printf '%s\n' \
  428. 'Package: *' \
  429. 'Pin: origin packages.mozilla.org' \
  430. 'Pin-Priority: 1000' \
  431. > /etc/apt/preferences.d/mozilla \
  432. && apt-get update \
  433. && apt-get install --no-install-recommends -y \
  434. firefox \
  435. firefox-l10n-fr \
  436. && apt-get clean
  437. # =============================================================================
  438. # NVIDIA 32-bit userspace
  439. #
  440. # The GPU Operator currently does not provide the compat32 libraries required
  441. # by 32-bit OpenGL applications and Proton/DXVK.
  442. #
  443. # Install the exact userspace version matching the host driver, then keep a
  444. # protected copy under /opt. The NVIDIA runtime can remove/mask the files in
  445. # /usr/lib/i386-linux-gnu when the pod starts; sunshine-entrypoint.sh restores
  446. # them afterwards.
  447. # =============================================================================
  448. RUN dpkg --add-architecture i386 \
  449. && apt-get update \
  450. && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
  451. "libnvidia-common-${NVIDIA_DRIVER_BRANCH}=${NVIDIA_DRIVER_PACKAGE_VERSION}" \
  452. "libnvidia-gpucomp-${NVIDIA_DRIVER_BRANCH}:i386=${NVIDIA_DRIVER_PACKAGE_VERSION}" \
  453. "libnvidia-decode-${NVIDIA_DRIVER_BRANCH}:i386=${NVIDIA_DRIVER_PACKAGE_VERSION}" \
  454. "libnvidia-compute-${NVIDIA_DRIVER_BRANCH}:i386=${NVIDIA_DRIVER_PACKAGE_VERSION}" \
  455. "libnvidia-gl-${NVIDIA_DRIVER_BRANCH}:i386=${NVIDIA_DRIVER_PACKAGE_VERSION}" \
  456. && mkdir -p /opt/nvidia-i386 \
  457. && for file in $( \
  458. dpkg -L \
  459. "libnvidia-gl-${NVIDIA_DRIVER_BRANCH}:i386" \
  460. "libnvidia-compute-${NVIDIA_DRIVER_BRANCH}:i386" \
  461. "libnvidia-decode-${NVIDIA_DRIVER_BRANCH}:i386" \
  462. "libnvidia-gpucomp-${NVIDIA_DRIVER_BRANCH}:i386" \
  463. | grep '^/usr/lib/i386-linux-gnu/' \
  464. | sort -u \
  465. ); do \
  466. if [[ -e "${file}" || -L "${file}" ]]; then \
  467. cp -a --parents "${file}" /opt/nvidia-i386/; \
  468. fi; \
  469. done \
  470. && test -e \
  471. /opt/nvidia-i386/usr/lib/i386-linux-gnu/libGLX_nvidia.so.0 \
  472. && test -e \
  473. "/opt/nvidia-i386/usr/lib/i386-linux-gnu/libnvidia-glcore.so.${NVIDIA_DRIVER_VERSION}" \
  474. && ldconfig \
  475. && apt-get clean \
  476. && rm -rf \
  477. /var/lib/apt/lists/* \
  478. /var/cache/apt/*
  479. # Keep APT package indexes available for Steam's dependency checker.
  480. RUN apt-get update \
  481. && apt-get clean
  482. # =============================================================================
  483. # Runtime scripts
  484. # =============================================================================
  485. COPY desktop-entrypoint.sh /etc/desktop-entrypoint.sh
  486. COPY sunshine-entrypoint.sh /etc/sunshine-entrypoint.sh
  487. COPY supervisord.conf /etc/supervisord.conf
  488. RUN sed -i 's/\r$//' \
  489. /etc/desktop-entrypoint.sh \
  490. /etc/sunshine-entrypoint.sh \
  491. /etc/supervisord.conf \
  492. && chmod 0755 \
  493. /etc/desktop-entrypoint.sh \
  494. /etc/sunshine-entrypoint.sh \
  495. && chmod 0644 \
  496. /etc/supervisord.conf
  497. # =============================================================================
  498. # Final filesystem permissions
  499. # =============================================================================
  500. RUN chown -R \
  501. "${USER_UID}:${USER_GID}" \
  502. "/home/${USER_NAME}" \
  503. /tmp/runtime-ubuntu
  504. # =============================================================================
  505. # Sanity checks
  506. # =============================================================================
  507. RUN command -v \
  508. steam \
  509. && command -v \
  510. nvidia-xconfig \
  511. && command -v \
  512. supervisord \
  513. && command -v \
  514. pipewire \
  515. && command -v \
  516. wireplumber \
  517. && command -v \
  518. Xorg \
  519. && command -v \
  520. xfce4-session \
  521. && test -x \
  522. /etc/sunshine-entrypoint.sh \
  523. && test -x \
  524. /etc/desktop-entrypoint.sh
  525. # =============================================================================
  526. # Runtime
  527. # =============================================================================
  528. USER 1000:1000
  529. WORKDIR /home/ubuntu
  530. STOPSIGNAL SIGTERM
  531. ENTRYPOINT ["/etc/sunshine-entrypoint.sh"]