Dockerfile 13 KB

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