🐛 fix(server): Test out in the wild (#20)

## Description

**What(what issue does this code solve/what feature does it add):**

**How(how does it solve it):**

## Required Checklist:

- [ ] I have added any necessary documentation and comments in my code
(where appropriate)
- [ ] I have added tests to make sure my code runs in all contexts

## Further comments
This commit is contained in:
Wanjohi
2024-04-16 01:49:06 +03:00
committed by GitHub
parent e7f5666d7a
commit 66f7ba200f
4 changed files with 393 additions and 151 deletions

View File

@@ -1,135 +1,56 @@
#This contains all the necessary libs for the server to work.
#NOTE: KEEP THIS IMAGE AS LEAN AS POSSIBLE.
FROM ghcr.io/wanjohiryan/netris/recorder:nightly as recorder
FROM ghcr.io/wanjohiryan/netris/base:nightly
FROM ghcr.io/wanjohiryan/netris/ffmpeg:nightly
ENV TZ=UTC \
SIZEW=1920 \
SIZEH=1080 \
REFRESH=60 \
DPI=96 \
CDEPTH=24 \
VIDEO_PORT=DFP
ENV DEBIAN_FRONTEND=noninteractive \
TIMEZONE=Africa/Nairobi
#Install base libs
RUN apt update && \
dpkg --add-architecture i386 && \
apt install -y \
software-properties-common \
curl \
libcap2-bin \
apt-transport-https \
apt-utils \
wget \
git \
jq \
locales \
&& rm -rf /var/lib/apt/lists/* \
&& locale-gen en_US.UTF-8
#Set language variables
ENV LANG=en_US.UTF-8 \
LANGUAGE=en_US:en \
LC_ALL=en_US.UTF-8
# Expose NVIDIA libraries and paths
ENV PATH=/usr/local/nvidia/bin:${PATH} \
LD_LIBRARY_PATH=/usr/lib/x86_64-linux-gnu:/usr/lib/i386-linux-gnu${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}:/usr/local/nvidia/lib:/usr/local/nvidia/lib64 \
# Make all NVIDIA GPUs visible by default
NVIDIA_VISIBLE_DEVICES=all \
# All NVIDIA driver capabilities should preferably be used, check `NVIDIA_DRIVER_CAPABILITIES` inside the container if things do not work
NVIDIA_DRIVER_CAPABILITIES=all \
# Disable VSYNC
__GL_SYNC_TO_VBLANK=0
ENV XDG_RUNTIME_DIR=/tmp/runtime-user \
# DISPLAY=:0 \
WAYLAND_DISPLAY=wayland-0 \
PUID=0 \
PGID=0 \
HOME="/root" \
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 Mangohud, gamemode and gamescope
#Install Mangohud and gamescope
RUN apt-get update -y \
&& add-apt-repository -y multiverse \
&& apt-get install -y --no-install-recommends \
flatpak \
mangohud \
gamescope \
&& rm -rf /var/lib/apt/lists/*
#Install pulseaudio
RUN apt-get update -y \
&& apt-get install -y --no-install-recommends \
alsa-utils \
libasound2 \
libasound2-plugins \
pulseaudio \
&& rm -rf /var/lib/apt/lists/*
COPY .scripts/ /usr/bin/netris/
#Install wine
ARG WINE_BRANCH=staging
RUN mkdir -pm755 /etc/apt/keyrings && curl -fsSL -o /etc/apt/keyrings/winehq-archive.key "https://dl.winehq.org/wine-builds/winehq.key" \
&& curl -fsSL -o "/etc/apt/sources.list.d/winehq-$(grep UBUNTU_CODENAME= /etc/os-release | cut -d= -f2 | tr -d '\"').sources" "https://dl.winehq.org/wine-builds/ubuntu/dists/$(grep UBUNTU_CODENAME= /etc/os-release | cut -d= -f2 | tr -d '\"')/winehq-$(grep UBUNTU_CODENAME= /etc/os-release | cut -d= -f2 | tr -d '\"').sources" \
&& apt-get update && apt-get install --install-recommends -y winehq-${WINE_BRANCH}
#Install Proton
COPY .scripts/proton /usr/bin/netris/
RUN chmod +x /usr/bin/netris/proton \
&& /usr/bin/netris/proton -i
ARG USERNAME=netris
# Create user and assign adequate groups
RUN apt-get update && apt-get install --no-install-recommends -y \
sudo \
tzdata \
&& rm -rf /var/lib/apt/lists/* \
&& groupadd -g 1000 $USERNAME \
&& useradd -ms /bin/bash $USERNAME -u 1000 -g 1000 \
&& usermod -a -G adm,audio,cdrom,dialout,dip,fax,floppy,input,lp,lpadmin,plugdev,pulse-access,render,scanner,ssl-cert,sudo,tape,tty,video,voice $USERNAME \
&& echo "${USERNAME} ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers \
&& chown $USERNAME:$USERNAME /home/$USERNAME \
&& ln -snf "/usr/share/zoneinfo/$TZ" /etc/localtime && echo "$TZ" > /etc/timezone
COPY warp /usr/bin/netris/
RUN ls -la /usr/bin/netris \
&& chmod +x /usr/bin/netris/proton /usr/bin/netris/entrypoint.sh /usr/bin/netris/warp
RUN chmod +x /usr/bin/netris/warp
COPY .scripts/entrypoint.sh .scripts/supervisord.conf /etc/netris/
RUN chmod 755 /etc/supervisord.conf /etc/entrypoint.sh
#Install proton
RUN /usr/bin/netris/proton -i
USER 1000
ENV SHELL=/bin/bash \
USER=${USERNAME}
ENV TINI_VERSION v0.19.0
ADD https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini /tini
RUN chmod +x /tini
ENTRYPOINT ["/tini", "--"]
WORKDIR /home/${USERNAME}
COPY --from=recorder /usr/bin/gpu-screen-recorder /usr/bin/gpu-screen-recorder
COPY --from=recorder /usr/bin/gsr-kms-server /usr/bin/gsr-kms-server
CMD [ "/usr/bin/netris/entrypoint.sh" ]
ENTRYPOINT ["/usr/bin/supervisord"]