Dockerfile 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454
  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 firefox \
  55. gir1.2-wp-0.5 \
  56. ubuntu-wallpapers \
  57. adwaita-icon-theme \
  58. elementary-xfce-icon-theme \
  59. greybird-gtk-theme \
  60. hicolor-icon-theme \
  61. humanity-icon-theme \
  62. keyboard-configuration \
  63. tango-icon-theme \
  64. xfce4-goodies \
  65. xfce4-notifyd \
  66. xfce4-pulseaudio-plugin \
  67. xfonts-base \
  68. xfonts-scalable \
  69. alsa-utils \
  70. ca-certificates \
  71. curl \
  72. dbus \
  73. dbus-user-session \
  74. dbus-x11 \
  75. file \
  76. fonts-dejavu \
  77. fonts-liberation \
  78. fonts-noto \
  79. fonts-noto-color-emoji \
  80. kmod \
  81. libasound2-plugins \
  82. libcap2-bin \
  83. libegl1 \
  84. libgbm1 \
  85. libgl1 \
  86. libglvnd0 \
  87. libglx0 \
  88. libpciaccess0 \
  89. libpulse0 \
  90. libvulkan1 \
  91. libx11-6 \
  92. libx11-xcb1 \
  93. libxdamage1 \
  94. libxext6 \
  95. libxfixes3 \
  96. libxinerama1 \
  97. libxrandr2 \
  98. libxss1 \
  99. libxtst6 \
  100. locales \
  101. mesa-utils \
  102. pciutils \
  103. pipewire \
  104. pipewire-pulse \
  105. procps \
  106. psmisc \
  107. pulseaudio-utils \
  108. sudo \
  109. supervisor \
  110. tzdata \
  111. udev \
  112. vulkan-tools \
  113. wireplumber \
  114. x11-utils \
  115. x11-xserver-utils \
  116. xauth \
  117. xcvt \
  118. xdg-user-dirs \
  119. xdg-utils \
  120. xfce4 \
  121. xfce4-terminal \
  122. xkb-data \
  123. xserver-xorg-core \
  124. xserver-xorg-input-libinput \
  125. xserver-xorg-legacy \
  126. xz-utils \
  127. && sed -i \
  128. -e 's/^# *fr_FR.UTF-8 UTF-8/fr_FR.UTF-8 UTF-8/' \
  129. -e 's/^# *en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' \
  130. /etc/locale.gen \
  131. && locale-gen \
  132. && apt-get clean \
  133. && rm -rf \
  134. /var/lib/apt/lists/* \
  135. /var/cache/apt/* \
  136. /var/cache/debconf/* \
  137. /tmp/* \
  138. /var/tmp/*
  139. # =============================================================================
  140. # Desktop user
  141. # =============================================================================
  142. RUN set -eux; \
  143. if ! getent group "${USER_GID}" >/dev/null; then \
  144. groupadd --gid "${USER_GID}" "${USER_NAME}"; \
  145. fi; \
  146. if ! id -u "${USER_NAME}" >/dev/null 2>&1; then \
  147. useradd \
  148. --uid "${USER_UID}" \
  149. --gid "${USER_GID}" \
  150. --create-home \
  151. --shell /bin/bash \
  152. "${USER_NAME}"; \
  153. else \
  154. usermod --shell /bin/bash "${USER_NAME}"; \
  155. fi; \
  156. for group in \
  157. audio \
  158. games \
  159. input \
  160. render \
  161. sudo \
  162. tty \
  163. video; \
  164. do \
  165. getent group "${group}" >/dev/null \
  166. && usermod -aG "${group}" "${USER_NAME}" \
  167. || true; \
  168. done; \
  169. echo "${USER_NAME} ALL=(ALL:ALL) NOPASSWD: ALL" \
  170. > "/etc/sudoers.d/${USER_NAME}"; \
  171. chmod 0440 "/etc/sudoers.d/${USER_NAME}"; \
  172. install \
  173. -d \
  174. -o "${USER_UID}" \
  175. -g "${USER_GID}" \
  176. -m 0700 \
  177. /tmp/runtime-ubuntu; \
  178. install \
  179. -d \
  180. -o "${USER_UID}" \
  181. -g "${USER_GID}" \
  182. /home/${USER_NAME}/.config/sunshine \
  183. /games
  184. # =============================================================================
  185. # NVIDIA repository + nvidia-xconfig
  186. #
  187. # Only the userspace Xorg configuration utility is installed here.
  188. # The kernel driver remains fully managed by the NVIDIA GPU Operator.
  189. # =============================================================================
  190. RUN curl -fsSLO \
  191. https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2404/x86_64/cuda-keyring_1.1-1_all.deb \
  192. && dpkg -i cuda-keyring_1.1-1_all.deb \
  193. && rm -f cuda-keyring_1.1-1_all.deb \
  194. && apt-get update \
  195. && apt-get install --no-install-recommends -y \
  196. "nvidia-xconfig=${NVIDIA_DRIVER_PACKAGE_VERSION}" \
  197. && nvidia-xconfig --version \
  198. && apt-get clean \
  199. && rm -rf \
  200. /var/lib/apt/lists/* \
  201. /var/cache/apt/*
  202. # =============================================================================
  203. # NVIDIA Xorg driver modules
  204. #
  205. # Extract only the Xorg-side NVIDIA modules matching the host driver.
  206. # Do not install the whole amd64 NVIDIA userspace stack with APT.
  207. # =============================================================================
  208. RUN cd /tmp \
  209. && apt-get update \
  210. && apt-get download \
  211. "xserver-xorg-video-nvidia-${NVIDIA_DRIVER_BRANCH}=${NVIDIA_DRIVER_PACKAGE_VERSION}" \
  212. && mkdir -p /tmp/nvidia-xorg \
  213. && dpkg-deb -x \
  214. "xserver-xorg-video-nvidia-${NVIDIA_DRIVER_BRANCH}_${NVIDIA_DRIVER_PACKAGE_VERSION}_amd64.deb" \
  215. /tmp/nvidia-xorg \
  216. && install -D -m 0755 \
  217. /tmp/nvidia-xorg/usr/lib/xorg/modules/drivers/nvidia_drv.so \
  218. /usr/lib/xorg/modules/drivers/nvidia_drv.so \
  219. && cp -a \
  220. /tmp/nvidia-xorg/usr/lib/xorg/modules/extensions/libglxserver_nvidia.so* \
  221. /usr/lib/xorg/modules/extensions/ \
  222. && rm -rf \
  223. /tmp/nvidia-xorg \
  224. /tmp/xserver-xorg-video-nvidia-*.deb \
  225. /var/lib/apt/lists/*
  226. # =============================================================================
  227. # NVIDIA GLVND / Vulkan configuration
  228. #
  229. # Actual 64-bit NVIDIA libraries are injected at runtime by the GPU Operator /
  230. # NVIDIA Container Toolkit.
  231. # =============================================================================
  232. RUN printf '%s\n' \
  233. '/usr/local/nvidia/lib' \
  234. '/usr/local/nvidia/lib64' \
  235. > /etc/ld.so.conf.d/nvidia.conf \
  236. && install -d -m 0755 \
  237. /etc/vulkan/icd.d \
  238. /usr/share/glvnd/egl_vendor.d \
  239. && cat > /etc/vulkan/icd.d/nvidia_icd.json <<'EOF'
  240. {
  241. "file_format_version": "1.0.0",
  242. "ICD": {
  243. "library_path": "libGLX_nvidia.so.0",
  244. "api_version": "1.3.0"
  245. }
  246. }
  247. EOF
  248. RUN cat > /usr/share/glvnd/egl_vendor.d/10_nvidia.json <<'EOF'
  249. {
  250. "file_format_version": "1.0.0",
  251. "ICD": {
  252. "library_path": "libEGL_nvidia.so.0"
  253. }
  254. }
  255. EOF
  256. # =============================================================================
  257. # Sunshine
  258. # =============================================================================
  259. COPY --from=sunshine /sunshine.deb /tmp/sunshine.deb
  260. RUN apt-get update \
  261. && apt-get install --no-install-recommends -y \
  262. /tmp/sunshine.deb \
  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. && rm -f /etc/apt/sources.list.d/steam-bootstrap.list \
  300. && apt-get clean \
  301. && rm -rf \
  302. /var/lib/apt/lists/* \
  303. /var/cache/apt/*
  304. # =============================================================================
  305. # NVIDIA 32-bit userspace
  306. #
  307. # The GPU Operator currently does not provide the compat32 libraries required
  308. # by 32-bit OpenGL applications and Proton/DXVK.
  309. #
  310. # Install the exact userspace version matching the host driver, then keep a
  311. # protected copy under /opt. The NVIDIA runtime can remove/mask the files in
  312. # /usr/lib/i386-linux-gnu when the pod starts; sunshine-entrypoint.sh restores
  313. # them afterwards.
  314. # =============================================================================
  315. RUN dpkg --add-architecture i386 \
  316. && apt-get update \
  317. && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
  318. "libnvidia-common-${NVIDIA_DRIVER_BRANCH}=${NVIDIA_DRIVER_PACKAGE_VERSION}" \
  319. "libnvidia-gpucomp-${NVIDIA_DRIVER_BRANCH}:i386=${NVIDIA_DRIVER_PACKAGE_VERSION}" \
  320. "libnvidia-decode-${NVIDIA_DRIVER_BRANCH}:i386=${NVIDIA_DRIVER_PACKAGE_VERSION}" \
  321. "libnvidia-compute-${NVIDIA_DRIVER_BRANCH}:i386=${NVIDIA_DRIVER_PACKAGE_VERSION}" \
  322. "libnvidia-gl-${NVIDIA_DRIVER_BRANCH}:i386=${NVIDIA_DRIVER_PACKAGE_VERSION}" \
  323. && mkdir -p /opt/nvidia-i386 \
  324. && for file in $( \
  325. dpkg -L \
  326. "libnvidia-gl-${NVIDIA_DRIVER_BRANCH}:i386" \
  327. "libnvidia-compute-${NVIDIA_DRIVER_BRANCH}:i386" \
  328. "libnvidia-decode-${NVIDIA_DRIVER_BRANCH}:i386" \
  329. "libnvidia-gpucomp-${NVIDIA_DRIVER_BRANCH}:i386" \
  330. | grep '^/usr/lib/i386-linux-gnu/' \
  331. | sort -u \
  332. ); do \
  333. if [[ -e "${file}" || -L "${file}" ]]; then \
  334. cp -a --parents "${file}" /opt/nvidia-i386/; \
  335. fi; \
  336. done \
  337. && test -e \
  338. /opt/nvidia-i386/usr/lib/i386-linux-gnu/libGLX_nvidia.so.0 \
  339. && test -e \
  340. "/opt/nvidia-i386/usr/lib/i386-linux-gnu/libnvidia-glcore.so.${NVIDIA_DRIVER_VERSION}" \
  341. && ldconfig \
  342. && apt-get clean \
  343. && rm -rf \
  344. /var/lib/apt/lists/* \
  345. /var/cache/apt/*
  346. # Keep APT package indexes available for Steam's dependency checker.
  347. RUN apt-get update \
  348. && apt-get clean
  349. # =============================================================================
  350. # Runtime scripts
  351. # =============================================================================
  352. COPY desktop-entrypoint.sh /etc/desktop-entrypoint.sh
  353. COPY sunshine-entrypoint.sh /etc/sunshine-entrypoint.sh
  354. COPY supervisord.conf /etc/supervisord.conf
  355. RUN sed -i 's/\r$//' \
  356. /etc/desktop-entrypoint.sh \
  357. /etc/sunshine-entrypoint.sh \
  358. /etc/supervisord.conf \
  359. && chmod 0755 \
  360. /etc/desktop-entrypoint.sh \
  361. /etc/sunshine-entrypoint.sh \
  362. && chmod 0644 \
  363. /etc/supervisord.conf
  364. # =============================================================================
  365. # Final filesystem permissions
  366. # =============================================================================
  367. RUN chown -R \
  368. "${USER_UID}:${USER_GID}" \
  369. "/home/${USER_NAME}" \
  370. /tmp/runtime-ubuntu
  371. # =============================================================================
  372. # Sanity checks
  373. # =============================================================================
  374. RUN command -v \
  375. steam \
  376. && command -v \
  377. nvidia-xconfig \
  378. && command -v \
  379. supervisord \
  380. && command -v \
  381. pipewire \
  382. && command -v \
  383. wireplumber \
  384. && command -v \
  385. Xorg \
  386. && command -v \
  387. xfce4-session \
  388. && test -x \
  389. /etc/sunshine-entrypoint.sh \
  390. && test -x \
  391. /etc/desktop-entrypoint.sh
  392. # =============================================================================
  393. # Runtime
  394. # =============================================================================
  395. USER 1000:1000
  396. WORKDIR /home/ubuntu
  397. STOPSIGNAL SIGTERM
  398. ENTRYPOINT ["/etc/sunshine-entrypoint.sh"]