From 72e487faece716d5acf2d65838f37ae8b8871d16 Mon Sep 17 00:00:00 2001 From: Wanjohi <71614375+wanjohiryan@users.noreply.github.com> Date: Mon, 1 Apr 2024 19:25:54 +0000 Subject: [PATCH 1/2] feat(server): Add Vulkan and Xwayland support --- .dev/x11.sh | 13 ++++++++++ server.Dockerfile | 66 ++++++++++++++++++++++++++++++++++++++++++++--- test.Dockerfile | 8 ++++++ 3 files changed, 84 insertions(+), 3 deletions(-) create mode 100644 .dev/x11.sh create mode 100644 test.Dockerfile diff --git a/.dev/x11.sh b/.dev/x11.sh new file mode 100644 index 00000000..9831c393 --- /dev/null +++ b/.dev/x11.sh @@ -0,0 +1,13 @@ +#This fixes the error where x11-apps in docker cannot seem to access the hosts DISPLAY server + # Error: No protocol specified + # Error: Can't open display: :10.0 +#https://askubuntu.com/a/1470341 //Run it on host OS +xhost +Local:* +xhost + +#Fun fact Weston won't run if you do not have Wayland running on the host (i have yet to try running with Xwayland inside the container) +#Run weston using your host's X11 display server +weston --backend=x11-backend.so + +#Run inside the terminal of the weston you just created... cool right? +weston --backend=wayland-backend.so \ No newline at end of file diff --git a/server.Dockerfile b/server.Dockerfile index 0ded026a..27998a0c 100644 --- a/server.Dockerfile +++ b/server.Dockerfile @@ -29,10 +29,10 @@ ENV LANG=en_US.UTF-8 \ LANGUAGE=en_US:en \ LC_ALL=en_US.UTF-8 -COPY .scripts/ /usr/bin/netris/ +# COPY .scripts/ /usr/bin/netris/ -RUN ls -la /usr/bin/netris \ - && chmod +x /usr/bin/netris/proton +# RUN ls -la /usr/bin/netris \ +# && chmod +x /usr/bin/netris/proton # Expose NVIDIA libraries and paths ENV PATH=/usr/local/nvidia/bin:${PATH} \ @@ -44,6 +44,66 @@ ENV PATH=/usr/local/nvidia/bin:${PATH} \ # Disable VSYNC for NVIDIA GPUs __GL_SYNC_TO_VBLANK=0 +ENV XDG_RUNTIME_DIR=/run/user/1000/ \ + # DISPLAY=:0 \ + WAYLAND_DISPLAY=wayland-0 \ + PUID=0 \ + PGID=0 \ + UNAME="root" + +RUN apt-get update -y \ + && apt-get install -y --no-install-recommends \ + libwayland-server0 \ + libwayland-client0 \ + xwayland \ + xdg-user-dirs \ + xdg-utils \ + #Vulkan + mesa-vulkan-drivers \ + mesa-vulkan-drivers:i386 \ + libvulkan-dev \ + libvulkan-dev:i386 \ + vulkan-tools \ + # Install OpenGL libraries + libglvnd0 \ + libglvnd0:i386 \ + libgl1 \ + libgl1:i386 \ + libglx0 \ + libglx0:i386 \ + libegl1 \ + libegl1:i386 \ + libgles2 \ + libgles2:i386 \ + libglu1 \ + libglu1:i386 \ + libsm6 \ + libsm6:i386 \ + && rm -rf /var/lib/apt/lists/* \ + && echo "/usr/local/nvidia/lib" >> /etc/ld.so.conf.d/nvidia.conf \ + && echo "/usr/local/nvidia/lib64" >> /etc/ld.so.conf.d/nvidia.conf \ + # Configure Vulkan manually + && VULKAN_API_VERSION=$(dpkg -s libvulkan1 | grep -oP 'Version: [0-9|\.]+' | grep -oP '[0-9]+(\.[0-9]+)(\.[0-9]+)') \ + && mkdir -pm755 /etc/vulkan/icd.d/ \ + && echo "{\n\ + \"file_format_version\" : \"1.0.0\",\n\ + \"ICD\": {\n\ + \"library_path\": \"libGLX_nvidia.so.0\",\n\ + \"api_version\" : \"${VULKAN_API_VERSION}\"\n\ + }\n\ + }" > /etc/vulkan/icd.d/nvidia_icd.json \ + # Configure EGL manually + && mkdir -pm755 /usr/share/glvnd/egl_vendor.d/ \ + && echo "{\n\ + \"file_format_version\" : \"1.0.0\",\n\ + \"ICD\": {\n\ + \"library_path\": \"libEGL_nvidia.so.0\"\n\ + }\n\ + }" > /usr/share/glvnd/egl_vendor.d/10_nvidia.json \ + # Prepare the XDG_RUNTIME_DIR for wayland + && mkdir -p ${XDG_RUNTIME_DIR} && chmod 0700 ${XDG_RUNTIME_DIR} + + #Install proton # RUN /usr/bin/netris/proton -i diff --git a/test.Dockerfile b/test.Dockerfile new file mode 100644 index 00000000..cf7b1958 --- /dev/null +++ b/test.Dockerfile @@ -0,0 +1,8 @@ +FROM ubuntu:20.04 as runtime + +ARG DEBIAN_FRONTEND=noninteractive + +RUN apt update && \ + apt install -y x11-apps + +CMD /usr/bin/xclock \ No newline at end of file From f9e32c2a1bc9a057092dc022c333f0ef83d1dbfb Mon Sep 17 00:00:00 2001 From: Wanjohi <71614375+wanjohiryan@users.noreply.github.com> Date: Mon, 1 Apr 2024 19:26:32 +0000 Subject: [PATCH 2/2] fix: delete test dockerfile --- test.Dockerfile | 8 -------- 1 file changed, 8 deletions(-) delete mode 100644 test.Dockerfile diff --git a/test.Dockerfile b/test.Dockerfile deleted file mode 100644 index cf7b1958..00000000 --- a/test.Dockerfile +++ /dev/null @@ -1,8 +0,0 @@ -FROM ubuntu:20.04 as runtime - -ARG DEBIAN_FRONTEND=noninteractive - -RUN apt update && \ - apt install -y x11-apps - -CMD /usr/bin/xclock \ No newline at end of file