Dockerfile 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476
  1. # syntax=docker/dockerfile:1.7
  2. # =============================================================================
  3. # Versions
  4. # =============================================================================
  5. ARG SUNSHINE_VERSION=v2025.924.154138
  6. # Update these values whenever the NVIDIA GPU Operator driver changes.
  7. ARG NVIDIA_DRIVER_BRANCH=580
  8. ARG NVIDIA_DRIVER_VERSION=580.126.20
  9. ARG NVIDIA_DRIVER_PACKAGE_VERSION=580.126.20-1ubuntu1
  10. # =============================================================================
  11. # Sunshine package source
  12. # =============================================================================
  13. FROM ghcr.io/lizardbyte/sunshine:${SUNSHINE_VERSION}-ubuntu-24.04 AS sunshine
  14. # =============================================================================
  15. # Main image
  16. # =============================================================================
  17. FROM docker.io/library/ubuntu:24.04
  18. ARG NVIDIA_DRIVER_BRANCH
  19. ARG NVIDIA_DRIVER_VERSION
  20. ARG NVIDIA_DRIVER_PACKAGE_VERSION
  21. ARG USER_NAME=ubuntu
  22. ARG USER_UID=1000
  23. ARG USER_GID=1000
  24. ENV DEBIAN_FRONTEND=noninteractive \
  25. HOME=/home/ubuntu \
  26. USER=ubuntu \
  27. DISPLAY=:20 \
  28. DISPLAY_SIZEW=1920 \
  29. DISPLAY_SIZEH=1080 \
  30. DISPLAY_REFRESH=120 \
  31. DISPLAY_DPI=96 \
  32. DISPLAY_CDEPTH=24 \
  33. VIDEO_PORT=HDMI-0 \
  34. TZ=Europe/Paris \
  35. LANG=fr_FR.UTF-8 \
  36. LANGUAGE=fr_FR:fr \
  37. LC_ALL=fr_FR.UTF-8 \
  38. XDG_RUNTIME_DIR=/tmp/runtime-ubuntu \
  39. PIPEWIRE_RUNTIME_DIR=/tmp/runtime-ubuntu \
  40. PULSE_RUNTIME_PATH=/tmp/runtime-ubuntu/pulse \
  41. PULSE_SERVER=unix:/tmp/runtime-ubuntu/pulse/native \
  42. NVIDIA_VISIBLE_DEVICES=all \
  43. NVIDIA_DRIVER_CAPABILITIES=all \
  44. EXPECTED_NVIDIA_DRIVER_VERSION=${NVIDIA_DRIVER_VERSION} \
  45. NVIDIA_I386_PACKAGE_VERSION=${NVIDIA_DRIVER_PACKAGE_VERSION}
  46. SHELL ["/bin/bash", "-o", "pipefail", "-c"]
  47. USER root
  48. # =============================================================================
  49. # Base desktop / gaming environment
  50. # =============================================================================
  51. RUN dpkg --add-architecture i386 \
  52. && apt-get update \
  53. && apt-get install --no-install-recommends -y \
  54. btop fonts-noto-cjk fonts-ubuntu mousepad nano ristretto thunar \
  55. ubuntu-wallpapers \
  56. adwaita-icon-theme \
  57. elementary-xfce-icon-theme \
  58. greybird-gtk-theme \
  59. hicolor-icon-theme \
  60. humanity-icon-theme \
  61. keyboard-configuration \
  62. tango-icon-theme \
  63. xfce4-goodies \
  64. xfce4-notifyd \
  65. xfce4-pulseaudio-plugin \
  66. xfonts-base \
  67. xfonts-scalable \
  68. alsa-utils \
  69. ca-certificates \
  70. curl \
  71. dbus \
  72. dbus-user-session \
  73. dbus-x11 \
  74. file \
  75. fonts-dejavu \
  76. fonts-liberation \
  77. fonts-noto \
  78. fonts-noto-color-emoji \
  79. kmod \
  80. libasound2-plugins \
  81. libcap2-bin \
  82. libegl1 \
  83. libgbm1 \
  84. libgl1 \
  85. libglvnd0 \
  86. libglx0 \
  87. libpciaccess0 \
  88. libpulse0 \
  89. libvulkan1 \
  90. libx11-6 \
  91. libx11-xcb1 \
  92. libxdamage1 \
  93. libxext6 \
  94. libxfixes3 \
  95. libxinerama1 \
  96. libxrandr2 \
  97. libxss1 \
  98. libxtst6 \
  99. locales \
  100. mesa-utils \
  101. pciutils \
  102. pipewire \
  103. pipewire-pulse \
  104. procps \
  105. psmisc \
  106. pulseaudio-utils \
  107. sudo \
  108. supervisor \
  109. tzdata \
  110. udev \
  111. vulkan-tools \
  112. wireplumber \
  113. x11-utils \
  114. x11-xserver-utils \
  115. xauth \
  116. xcvt \
  117. xdg-user-dirs \
  118. xdg-utils \
  119. xfce4 \
  120. xfce4-terminal \
  121. xkb-data \
  122. xserver-xorg-core \
  123. xserver-xorg-input-libinput \
  124. xserver-xorg-legacy \
  125. xz-utils \
  126. && sed -i \
  127. -e 's/^# *fr_FR.UTF-8 UTF-8/fr_FR.UTF-8 UTF-8/' \
  128. -e 's/^# *en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' \
  129. /etc/locale.gen \
  130. && locale-gen \
  131. && apt-get clean \
  132. && rm -rf \
  133. /var/lib/apt/lists/* \
  134. /var/cache/apt/* \
  135. /var/cache/debconf/* \
  136. /tmp/* \
  137. /var/tmp/*
  138. # =============================================================================
  139. # Desktop user
  140. # =============================================================================
  141. RUN set -eux; \
  142. if ! getent group "${USER_GID}" >/dev/null; then \
  143. groupadd --gid "${USER_GID}" "${USER_NAME}"; \
  144. fi; \
  145. if ! id -u "${USER_NAME}" >/dev/null 2>&1; then \
  146. useradd \
  147. --uid "${USER_UID}" \
  148. --gid "${USER_GID}" \
  149. --create-home \
  150. --shell /bin/bash \
  151. "${USER_NAME}"; \
  152. else \
  153. usermod --shell /bin/bash "${USER_NAME}"; \
  154. fi; \
  155. for group in \
  156. audio \
  157. games \
  158. input \
  159. render \
  160. tty \
  161. video; \
  162. do \
  163. getent group "${group}" >/dev/null \
  164. && usermod -aG "${group}" "${USER_NAME}" \
  165. || true; \
  166. done; \
  167. echo "${USER_NAME} ALL=(ALL:ALL) NOPASSWD: ALL" \
  168. > "/etc/sudoers.d/${USER_NAME}"; \
  169. chmod 0440 "/etc/sudoers.d/${USER_NAME}"; \
  170. install \
  171. -d \
  172. -o "${USER_UID}" \
  173. -g "${USER_GID}" \
  174. -m 0700 \
  175. /tmp/runtime-ubuntu; \
  176. install \
  177. -d \
  178. -o "${USER_UID}" \
  179. -g "${USER_GID}" \
  180. /home/${USER_NAME}/.config/sunshine \
  181. /games
  182. # =============================================================================
  183. # NVIDIA repository + nvidia-xconfig
  184. #
  185. # Only the userspace Xorg configuration utility is installed here.
  186. # The kernel driver remains fully managed by the NVIDIA GPU Operator.
  187. # =============================================================================
  188. RUN curl -fsSLO \
  189. https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2404/x86_64/cuda-keyring_1.1-1_all.deb \
  190. && dpkg -i cuda-keyring_1.1-1_all.deb \
  191. && rm -f cuda-keyring_1.1-1_all.deb \
  192. && apt-get update \
  193. && apt-get install --no-install-recommends -y \
  194. "nvidia-xconfig=${NVIDIA_DRIVER_PACKAGE_VERSION}" \
  195. && nvidia-xconfig --version \
  196. && apt-get clean \
  197. && rm -rf \
  198. /var/lib/apt/lists/* \
  199. /var/cache/apt/*
  200. # =============================================================================
  201. # NVIDIA Xorg driver modules
  202. #
  203. # Extract only the Xorg-side NVIDIA modules matching the host driver.
  204. # Do not install the whole amd64 NVIDIA userspace stack with APT.
  205. # =============================================================================
  206. RUN cd /tmp \
  207. && apt-get update \
  208. && apt-get download \
  209. "xserver-xorg-video-nvidia-${NVIDIA_DRIVER_BRANCH}=${NVIDIA_DRIVER_PACKAGE_VERSION}" \
  210. && mkdir -p /tmp/nvidia-xorg \
  211. && dpkg-deb -x \
  212. "xserver-xorg-video-nvidia-${NVIDIA_DRIVER_BRANCH}_${NVIDIA_DRIVER_PACKAGE_VERSION}_amd64.deb" \
  213. /tmp/nvidia-xorg \
  214. && install -D -m 0755 \
  215. /tmp/nvidia-xorg/usr/lib/xorg/modules/drivers/nvidia_drv.so \
  216. /usr/lib/xorg/modules/drivers/nvidia_drv.so \
  217. && cp -a \
  218. /tmp/nvidia-xorg/usr/lib/xorg/modules/extensions/libglxserver_nvidia.so* \
  219. /usr/lib/xorg/modules/extensions/ \
  220. && rm -rf \
  221. /tmp/nvidia-xorg \
  222. /tmp/xserver-xorg-video-nvidia-*.deb \
  223. /var/lib/apt/lists/*
  224. # =============================================================================
  225. # NVIDIA GLVND / Vulkan configuration
  226. #
  227. # Actual 64-bit NVIDIA libraries are injected at runtime by the GPU Operator /
  228. # NVIDIA Container Toolkit.
  229. # =============================================================================
  230. RUN printf '%s\n' \
  231. '/usr/local/nvidia/lib' \
  232. '/usr/local/nvidia/lib64' \
  233. > /etc/ld.so.conf.d/nvidia.conf \
  234. && install -d -m 0755 \
  235. /etc/vulkan/icd.d \
  236. /usr/share/glvnd/egl_vendor.d \
  237. && cat > /etc/vulkan/icd.d/nvidia_icd.json <<'EOF'
  238. {
  239. "file_format_version": "1.0.0",
  240. "ICD": {
  241. "library_path": "libGLX_nvidia.so.0",
  242. "api_version": "1.3.0"
  243. }
  244. }
  245. EOF
  246. RUN cat > /usr/share/glvnd/egl_vendor.d/10_nvidia.json <<'EOF'
  247. {
  248. "file_format_version": "1.0.0",
  249. "ICD": {
  250. "library_path": "libEGL_nvidia.so.0"
  251. }
  252. }
  253. EOF
  254. # =============================================================================
  255. # Sunshine
  256. # =============================================================================
  257. COPY --from=sunshine /sunshine.deb /tmp/sunshine.deb
  258. RUN apt-get update \
  259. && apt-get install --no-install-recommends -y \
  260. /tmp/sunshine.deb \
  261. && setcap cap_sys_admin,cap_dac_override=ep \
  262. /usr/bin/sunshine-2025.924.154138 \
  263. && rm -f /tmp/sunshine.deb \
  264. && apt-get clean \
  265. && rm -rf \
  266. /var/lib/apt/lists/* \
  267. /var/cache/apt/*
  268. # =============================================================================
  269. # Steam + 32-bit Linux gaming runtime
  270. # =============================================================================
  271. RUN dpkg --add-architecture i386 \
  272. && apt-get update \
  273. && apt-get install --no-install-recommends -y \
  274. ca-certificates \
  275. curl \
  276. && curl -fsSL \
  277. https://repo.steampowered.com/steam/archive/stable/steam.gpg \
  278. -o /usr/share/keyrings/steam.gpg \
  279. && printf '%s\n' \
  280. 'deb [arch=amd64,i386 signed-by=/usr/share/keyrings/steam.gpg] https://repo.steampowered.com/steam/ stable steam' \
  281. > /etc/apt/sources.list.d/steam-bootstrap.list \
  282. && apt-get update \
  283. && apt-get install --no-install-recommends -y \
  284. steam-launcher \
  285. steam-libs-amd64 \
  286. steam-libs-i386 \
  287. libegl1:amd64 \
  288. libegl1:i386 \
  289. libgbm1:amd64 \
  290. libgbm1:i386 \
  291. libgl1:amd64 \
  292. libgl1:i386 \
  293. libgl1-mesa-dri:amd64 \
  294. libgl1-mesa-dri:i386 \
  295. libglx-mesa0:amd64 \
  296. libglx-mesa0:i386 \
  297. libvulkan1:amd64 \
  298. libvulkan1:i386 \
  299. xdg-desktop-portal \
  300. xdg-desktop-portal-gtk \
  301. && rm -f /etc/apt/sources.list.d/steam-bootstrap.list \
  302. && apt-get clean \
  303. && rm -rf \
  304. /var/lib/apt/lists/* \
  305. /var/cache/apt/*
  306. # =============================================================================
  307. # Non-snap Firefox
  308. # =============================================================================
  309. RUN install -d -m 0755 /etc/apt/keyrings \
  310. && curl -fsSL https://packages.mozilla.org/apt/repo-signing-key.gpg \
  311. -o /etc/apt/keyrings/packages.mozilla.org.asc \
  312. && echo "deb [signed-by=/etc/apt/keyrings/packages.mozilla.org.asc] https://packages.mozilla.org/apt mozilla main" \
  313. > /etc/apt/sources.list.d/mozilla.list \
  314. && printf '%s\n' \
  315. 'Package: *' \
  316. 'Pin: origin packages.mozilla.org' \
  317. 'Pin-Priority: 1000' \
  318. > /etc/apt/preferences.d/mozilla \
  319. && apt-get update \
  320. && apt-get install --no-install-recommends -y \
  321. firefox \
  322. firefox-l10n-fr \
  323. && apt-get clean
  324. # =============================================================================
  325. # NVIDIA 32-bit userspace
  326. #
  327. # The GPU Operator currently does not provide the compat32 libraries required
  328. # by 32-bit OpenGL applications and Proton/DXVK.
  329. #
  330. # Install the exact userspace version matching the host driver, then keep a
  331. # protected copy under /opt. The NVIDIA runtime can remove/mask the files in
  332. # /usr/lib/i386-linux-gnu when the pod starts; sunshine-entrypoint.sh restores
  333. # them afterwards.
  334. # =============================================================================
  335. RUN dpkg --add-architecture i386 \
  336. && apt-get update \
  337. && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
  338. "libnvidia-common-${NVIDIA_DRIVER_BRANCH}=${NVIDIA_DRIVER_PACKAGE_VERSION}" \
  339. "libnvidia-gpucomp-${NVIDIA_DRIVER_BRANCH}:i386=${NVIDIA_DRIVER_PACKAGE_VERSION}" \
  340. "libnvidia-decode-${NVIDIA_DRIVER_BRANCH}:i386=${NVIDIA_DRIVER_PACKAGE_VERSION}" \
  341. "libnvidia-compute-${NVIDIA_DRIVER_BRANCH}:i386=${NVIDIA_DRIVER_PACKAGE_VERSION}" \
  342. "libnvidia-gl-${NVIDIA_DRIVER_BRANCH}:i386=${NVIDIA_DRIVER_PACKAGE_VERSION}" \
  343. && mkdir -p /opt/nvidia-i386 \
  344. && for file in $( \
  345. dpkg -L \
  346. "libnvidia-gl-${NVIDIA_DRIVER_BRANCH}:i386" \
  347. "libnvidia-compute-${NVIDIA_DRIVER_BRANCH}:i386" \
  348. "libnvidia-decode-${NVIDIA_DRIVER_BRANCH}:i386" \
  349. "libnvidia-gpucomp-${NVIDIA_DRIVER_BRANCH}:i386" \
  350. | grep '^/usr/lib/i386-linux-gnu/' \
  351. | sort -u \
  352. ); do \
  353. if [[ -e "${file}" || -L "${file}" ]]; then \
  354. cp -a --parents "${file}" /opt/nvidia-i386/; \
  355. fi; \
  356. done \
  357. && test -e \
  358. /opt/nvidia-i386/usr/lib/i386-linux-gnu/libGLX_nvidia.so.0 \
  359. && test -e \
  360. "/opt/nvidia-i386/usr/lib/i386-linux-gnu/libnvidia-glcore.so.${NVIDIA_DRIVER_VERSION}" \
  361. && ldconfig \
  362. && apt-get clean \
  363. && rm -rf \
  364. /var/lib/apt/lists/* \
  365. /var/cache/apt/*
  366. # Keep APT package indexes available for Steam's dependency checker.
  367. RUN apt-get update \
  368. && apt-get clean
  369. # =============================================================================
  370. # Runtime scripts
  371. # =============================================================================
  372. COPY desktop-entrypoint.sh /etc/desktop-entrypoint.sh
  373. COPY sunshine-entrypoint.sh /etc/sunshine-entrypoint.sh
  374. COPY supervisord.conf /etc/supervisord.conf
  375. RUN sed -i 's/\r$//' \
  376. /etc/desktop-entrypoint.sh \
  377. /etc/sunshine-entrypoint.sh \
  378. /etc/supervisord.conf \
  379. && chmod 0755 \
  380. /etc/desktop-entrypoint.sh \
  381. /etc/sunshine-entrypoint.sh \
  382. && chmod 0644 \
  383. /etc/supervisord.conf
  384. # =============================================================================
  385. # Final filesystem permissions
  386. # =============================================================================
  387. RUN chown -R \
  388. "${USER_UID}:${USER_GID}" \
  389. "/home/${USER_NAME}" \
  390. /tmp/runtime-ubuntu
  391. # =============================================================================
  392. # Sanity checks
  393. # =============================================================================
  394. RUN command -v \
  395. steam \
  396. && command -v \
  397. nvidia-xconfig \
  398. && command -v \
  399. supervisord \
  400. && command -v \
  401. pipewire \
  402. && command -v \
  403. wireplumber \
  404. && command -v \
  405. Xorg \
  406. && command -v \
  407. xfce4-session \
  408. && test -x \
  409. /etc/sunshine-entrypoint.sh \
  410. && test -x \
  411. /etc/desktop-entrypoint.sh
  412. # =============================================================================
  413. # Runtime
  414. # =============================================================================
  415. USER 1000:1000
  416. WORKDIR /home/ubuntu
  417. STOPSIGNAL SIGTERM
  418. ENTRYPOINT ["/etc/sunshine-entrypoint.sh"]