Dockerfile 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413
  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-xconfig
  171. #
  172. # We only extract the userspace utility. No kernel driver or DKMS is installed
  173. # in the image; those remain managed by the NVIDIA GPU Operator.
  174. # =============================================================================
  175. RUN cd /tmp \
  176. && curl -fsSLO \
  177. "https://international.download.nvidia.com/XFree86/Linux-x86_64/${NVIDIA_DRIVER_VERSION}/NVIDIA-Linux-x86_64-${NVIDIA_DRIVER_VERSION}.run" \
  178. && sh \
  179. "NVIDIA-Linux-x86_64-${NVIDIA_DRIVER_VERSION}.run" \
  180. -x \
  181. && install \
  182. -m 0755 \
  183. "/tmp/NVIDIA-Linux-x86_64-${NVIDIA_DRIVER_VERSION}/nvidia-xconfig" \
  184. /usr/local/bin/nvidia-xconfig \
  185. && rm -rf /tmp/NVIDIA-Linux-* \
  186. && nvidia-xconfig --version
  187. # =============================================================================
  188. # NVIDIA GLVND / Vulkan configuration
  189. #
  190. # Actual 64-bit NVIDIA libraries are injected at runtime by the GPU Operator /
  191. # NVIDIA Container Toolkit.
  192. # =============================================================================
  193. RUN printf '%s\n' \
  194. '/usr/local/nvidia/lib' \
  195. '/usr/local/nvidia/lib64' \
  196. > /etc/ld.so.conf.d/nvidia.conf \
  197. && install -d -m 0755 \
  198. /etc/vulkan/icd.d \
  199. /usr/share/glvnd/egl_vendor.d \
  200. && cat > /etc/vulkan/icd.d/nvidia_icd.json <<'EOF'
  201. {
  202. "file_format_version": "1.0.0",
  203. "ICD": {
  204. "library_path": "libGLX_nvidia.so.0",
  205. "api_version": "1.3.0"
  206. }
  207. }
  208. EOF
  209. RUN cat > /usr/share/glvnd/egl_vendor.d/10_nvidia.json <<'EOF'
  210. {
  211. "file_format_version": "1.0.0",
  212. "ICD": {
  213. "library_path": "libEGL_nvidia.so.0"
  214. }
  215. }
  216. EOF
  217. # =============================================================================
  218. # Sunshine
  219. # =============================================================================
  220. COPY --from=sunshine /sunshine.deb /tmp/sunshine.deb
  221. RUN apt-get update \
  222. && apt-get install --no-install-recommends -y \
  223. /tmp/sunshine.deb \
  224. && rm -f /tmp/sunshine.deb \
  225. && apt-get clean \
  226. && rm -rf \
  227. /var/lib/apt/lists/* \
  228. /var/cache/apt/*
  229. # =============================================================================
  230. # Steam + 32-bit Linux gaming runtime
  231. # =============================================================================
  232. RUN dpkg --add-architecture i386 \
  233. && apt-get update \
  234. && apt-get install --no-install-recommends -y \
  235. ca-certificates \
  236. curl \
  237. && curl -fsSL \
  238. https://repo.steampowered.com/steam/archive/stable/steam.gpg \
  239. -o /usr/share/keyrings/steam.gpg \
  240. && printf '%s\n' \
  241. 'deb [arch=amd64,i386 signed-by=/usr/share/keyrings/steam.gpg] https://repo.steampowered.com/steam/ stable steam' \
  242. > /etc/apt/sources.list.d/steam-bootstrap.list \
  243. && apt-get update \
  244. && apt-get install --no-install-recommends -y \
  245. steam-launcher \
  246. steam-libs-amd64 \
  247. steam-libs-i386 \
  248. libegl1:amd64 \
  249. libegl1:i386 \
  250. libgbm1:amd64 \
  251. libgbm1:i386 \
  252. libgl1:amd64 \
  253. libgl1:i386 \
  254. libgl1-mesa-dri:amd64 \
  255. libgl1-mesa-dri:i386 \
  256. libglx-mesa0:amd64 \
  257. libglx-mesa0:i386 \
  258. libvulkan1:amd64 \
  259. libvulkan1:i386 \
  260. && rm -f /etc/apt/sources.list.d/steam-bootstrap.list \
  261. && apt-get clean \
  262. && rm -rf \
  263. /var/lib/apt/lists/* \
  264. /var/cache/apt/*
  265. # =============================================================================
  266. # NVIDIA 32-bit userspace
  267. #
  268. # The GPU Operator currently does not provide the compat32 libraries required
  269. # by 32-bit OpenGL applications and Proton/DXVK.
  270. #
  271. # Install the exact userspace version matching the host driver, then keep a
  272. # protected copy under /opt. The NVIDIA runtime can remove/mask the files in
  273. # /usr/lib/i386-linux-gnu when the pod starts; sunshine-entrypoint.sh restores
  274. # them afterwards.
  275. # =============================================================================
  276. RUN curl -fsSLO \
  277. https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2404/x86_64/cuda-keyring_1.1-1_all.deb \
  278. && dpkg -i cuda-keyring_1.1-1_all.deb \
  279. && rm -f cuda-keyring_1.1-1_all.deb \
  280. && dpkg --add-architecture i386 \
  281. && apt-get update \
  282. && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
  283. "libnvidia-common-${NVIDIA_DRIVER_BRANCH}=${NVIDIA_DRIVER_PACKAGE_VERSION}" \
  284. "libnvidia-gpucomp-${NVIDIA_DRIVER_BRANCH}:i386=${NVIDIA_DRIVER_PACKAGE_VERSION}" \
  285. "libnvidia-decode-${NVIDIA_DRIVER_BRANCH}:i386=${NVIDIA_DRIVER_PACKAGE_VERSION}" \
  286. "libnvidia-compute-${NVIDIA_DRIVER_BRANCH}:i386=${NVIDIA_DRIVER_PACKAGE_VERSION}" \
  287. "libnvidia-gl-${NVIDIA_DRIVER_BRANCH}:i386=${NVIDIA_DRIVER_PACKAGE_VERSION}" \
  288. && mkdir -p /opt/nvidia-i386 \
  289. && for file in $( \
  290. dpkg -L \
  291. "libnvidia-gl-${NVIDIA_DRIVER_BRANCH}:i386" \
  292. "libnvidia-compute-${NVIDIA_DRIVER_BRANCH}:i386" \
  293. "libnvidia-decode-${NVIDIA_DRIVER_BRANCH}:i386" \
  294. "libnvidia-gpucomp-${NVIDIA_DRIVER_BRANCH}:i386" \
  295. | grep '^/usr/lib/i386-linux-gnu/' \
  296. | sort -u \
  297. ); do \
  298. if [[ -e "${file}" || -L "${file}" ]]; then \
  299. cp -a --parents "${file}" /opt/nvidia-i386/; \
  300. fi; \
  301. done \
  302. && test -e \
  303. /opt/nvidia-i386/usr/lib/i386-linux-gnu/libGLX_nvidia.so.0 \
  304. && test -e \
  305. "/opt/nvidia-i386/usr/lib/i386-linux-gnu/libnvidia-glcore.so.${NVIDIA_DRIVER_VERSION}" \
  306. && ldconfig \
  307. && apt-get clean \
  308. && rm -rf \
  309. /var/lib/apt/lists/* \
  310. /var/cache/apt/*
  311. # =============================================================================
  312. # Runtime scripts
  313. # =============================================================================
  314. COPY desktop-entrypoint.sh /etc/desktop-entrypoint.sh
  315. COPY sunshine-entrypoint.sh /etc/sunshine-entrypoint.sh
  316. COPY supervisord.conf /etc/supervisor/supervisord.conf
  317. RUN sed -i 's/\r$//' \
  318. /etc/desktop-entrypoint.sh \
  319. /etc/sunshine-entrypoint.sh \
  320. /etc/supervisor/supervisord.conf \
  321. && chmod 0755 \
  322. /etc/desktop-entrypoint.sh \
  323. /etc/sunshine-entrypoint.sh \
  324. && chmod 0644 \
  325. /etc/supervisor/supervisord.conf
  326. # =============================================================================
  327. # Final filesystem permissions
  328. # =============================================================================
  329. RUN chown -R \
  330. "${USER_UID}:${USER_GID}" \
  331. "/home/${USER_NAME}" \
  332. /tmp/runtime-ubuntu
  333. # =============================================================================
  334. # Sanity checks
  335. # =============================================================================
  336. RUN command -v \
  337. steam \
  338. && command -v \
  339. nvidia-xconfig \
  340. && command -v \
  341. supervisord \
  342. && command -v \
  343. pipewire \
  344. && command -v \
  345. wireplumber \
  346. && command -v \
  347. Xorg \
  348. && command -v \
  349. xfce4-session \
  350. && test -x \
  351. /etc/sunshine-entrypoint.sh \
  352. && test -x \
  353. /etc/desktop-entrypoint.sh
  354. # =============================================================================
  355. # Runtime
  356. # =============================================================================
  357. USER 1000:1000
  358. WORKDIR /home/ubuntu
  359. STOPSIGNAL SIGTERM
  360. ENTRYPOINT ["/etc/sunshine-entrypoint.sh"]