diff --git a/.scripts/entrypoint.sh b/.scripts/entrypoint.sh index c788aa58..bef55752 100644 --- a/.scripts/entrypoint.sh +++ b/.scripts/entrypoint.sh @@ -1,28 +1,115 @@ #!/bin/bash +trap "echo TRAPed signal" HUP INT QUIT TERM -# Attempt to set capabilities -# Gotten from https://git.dec05eba.com/gpu-screen-recorder/tree/install.sh -#TODO: remove this -# setcap 'cap_sys_admin+ep' /usr/bin/gsr-kms-server -# setcap 'cap_sys_nice+ep' /usr/bin/gpu-screen-recorder +# Create and modify permissions of XDG_RUNTIME_DIR +sudo -u user mkdir -pm700 /tmp/runtime-netris +sudo chown user:user /tmp/runtime-netris +sudo -u user chmod 700 /tmp/runtime-netris +# Make user directory owned by the user in case it is not +sudo chown netris:netris /home/netris || sudo chown netris:netris /home/user/* || { echo "Failed to change user directory permissions. There may be permission issues."; } +# Remove directories to make sure the desktop environment starts +sudo rm -rf /tmp/.X* ~/.cache +# Change time zone from environment variable +sudo ln -snf "/usr/share/zoneinfo/$TZ" /etc/localtime && echo "$TZ" | sudo tee /etc/timezone >/dev/null +# Add gamescope directory +export PATH="${PATH:+${PATH}:}/usr/local/games:/usr/games" -#Start dbus -/etc/init.d/dbus start +# This symbolic link enables running Xorg inside a container with `-sharevts` +sudo ln -snf /dev/ptmx /dev/tty7 +# Start DBus without systemd +sudo /etc/init.d/dbus start -#Start Pulseaudio Reference: https://github.com/wanjohiryan/warp/blob/ad9cd38d21f0ac4332e64358e219b48e01871870/docker/nvidia/entrypoint.sh#L38 -/usr/bin/pulseaudio -k >/dev/null 2>&1 || /usr/bin/pulseaudio --system --verbose --log-target=stderr -D --realtime=true --disallow-exit -L 'module-native-protocol-tcp auth-ip-acl=127.0.0.0/8 port=4713 auth-anonymous=1' -pacmd load-module module-virtual-sink sink_name=vsink -pacmd set-default-sink vsink -pacmd set-default-source vsink.monitor +# Install NVIDIA userspace driver components including X graphic libraries +if ! command -v nvidia-xconfig &>/dev/null; then + # Driver version is provided by the kernel through the container toolkit + export DRIVER_ARCH="$(dpkg --print-architecture | sed -e 's/arm64/aarch64/' -e 's/armhf/32bit-ARM/' -e 's/i.*86/x86/' -e 's/amd64/x86_64/' -e 's/unknown/x86_64/')" + export DRIVER_VERSION="$(head -n1 /dev/null +fi +if grep -Fxq "allowed_users=console" /etc/X11/Xwrapper.config; then + sudo sed -i "s/allowed_users=console/allowed_users=anybody/;$ a needs_root_rights=yes" /etc/X11/Xwrapper.config +fi -#FIXME: +# Remove existing Xorg configuration +if [ -f "/etc/X11/xorg.conf" ]; then + sudo rm -f "/etc/X11/xorg.conf" +fi -#Mangohud [Works] -# Mangohud errors: Selected GPU 0: Tesla T4, type: DiscreteGpu [2024-04-14 23:52:57.098] [MANGOHUD] [error] [loader_nvctrl.cpp:39] Failed to open 64bit libXNVCtrl.so.0: libXNVCtrl.so.0: cannot open shared object file: No such file or directory [2024-04-14 23:52:57.098] [MANGOHUD] [error] [nvctrl.cpp:45] XNVCtrl loader failed to load -# gpu-screen-recorder [Fails]: #/usr/games/gamescope -w 1920 -h 1080 -W 3440 -H 1440 -r 60 -f -F fsr -- mangohud vkcubeNo CAP_SYS_NICE, falling back to regular-priority compute and threads.Performance will be affected.wlserver: [backend/headless/backend.c:68] Creating headless backendvulkan: selecting physical device 'Tesla T4': queue family 2vulkan: physical device does not support DRM format modifiersvulkan: physical device has no render nodeFailed to initialize Vulkan -# TODO: replace gpu-screen-recorder with shadow-cast (has better documentation) \ No newline at end of file +# Get first GPU device if all devices are available or $(NVIDIA_VISIBLE_DEVICES) is not set +if [ "$NVIDIA_VISIBLE_DEVICES" == "all" ] || [ -z "$NVIDIA_VISIBLE_DEVICES" ]; then + export GPU_SELECT="$(sudo nvidia-smi --query-gpu=uuid --format=csv | sed -n 2p)" +# Get first GPU device out of the visible devices in other situations +else + export GPU_SELECT="$(sudo nvidia-smi --id=$(echo "$NVIDIA_VISIBLE_DEVICES" | cut -d ',' -f1) --query-gpu=uuid --format=csv | sed -n 2p)" + if [ -z "$GPU_SELECT" ]; then + export GPU_SELECT="$(sudo nvidia-smi --query-gpu=uuid --format=csv | sed -n 2p)" + fi +fi + +if [ -z "$GPU_SELECT" ]; then + echo "No NVIDIA GPUs detected or nvidia-container-toolkit not configured. Exiting." + exit 1 +fi + +# Setting `VIDEO_PORT` to none disables RANDR/XRANDR, do not set this if using datacenter GPUs +if [ "${VIDEO_PORT,,}" = "none" ]; then + export CONNECTED_MONITOR="--use-display-device=None" +# The X server is otherwise deliberately set to a specific video port despite not being plugged to enable RANDR/XRANDR, monitor will display the screen if plugged to the specific port +else + export CONNECTED_MONITOR="--connected-monitor=${VIDEO_PORT}" +fi + +# Bus ID from nvidia-smi is in hexadecimal format and should be converted to decimal format (including the domain) which Xorg understands, required because nvidia-xconfig doesn't work as intended in a container +HEX_ID="$(sudo nvidia-smi --query-gpu=pci.bus_id --id="$GPU_SELECT" --format=csv | sed -n 2p)" +IFS=":." ARR_ID=("$HEX_ID") +unset IFS +BUS_ID="PCI:$((16#${ARR_ID[1]}))@$((16#${ARR_ID[0]})):$((16#${ARR_ID[2]})):$((16#${ARR_ID[3]}))" +# A custom modeline should be generated because there is no monitor to fetch this information normally +export MODELINE="$(cvt -r "${SIZEW}" "${SIZEH}" "${REFRESH}" | sed -n 2p)" +# Generate /etc/X11/xorg.conf with nvidia-xconfig +sudo nvidia-xconfig --virtual="${SIZEW}x${SIZEH}" --depth="$CDEPTH" --mode="$(echo "$MODELINE" | awk '{print $2}' | tr -d '\"')" --allow-empty-initial-configuration --no-probe-all-gpus --busid="$BUS_ID" --include-implicit-metamodes --mode-debug --no-sli --no-base-mosaic --only-one-x-screen ${CONNECTED_MONITOR} +# Guarantee that the X server starts without a monitor by adding more options to the configuration +sudo sed -i '/Driver\s\+"nvidia"/a\ Option "ModeValidation" "NoMaxPClkCheck,NoEdidMaxPClkCheck,NoMaxSizeCheck,NoHorizSyncCheck,NoVertRefreshCheck,NoVirtualSizeCheck,NoExtendedGpuCapabilitiesCheck,NoTotalSizeCheck,NoDualLinkDVICheck,NoDisplayPortBandwidthCheck,AllowNon3DVisionModes,AllowNonHDMI3DModes,AllowNonEdidModes,NoEdidHDMI2Check,AllowDpInterlaced"' /etc/X11/xorg.conf +# Add custom generated modeline to the configuration +sudo sed -i '/Section\s\+"Monitor"/a\ '"$MODELINE" /etc/X11/xorg.conf +# Prevent interference between GPUs, add this to the host or other containers running Xorg as well +echo -e "Section \"ServerFlags\"\n Option \"AutoAddGPU\" \"false\"\nEndSection" | sudo tee -a /etc/X11/xorg.conf >/dev/null + +# Default display is :0 across the container +export DISPLAY=":0" +# Run Xorg server with required extensions +/usr/bin/Xorg vt7 -noreset -novtswitch -sharevts -dpi "${DPI}" +extension "COMPOSITE" +extension "DAMAGE" +extension "GLX" +extension "RANDR" +extension "RENDER" +extension "MIT-SHM" +extension "XFIXES" +extension "XTEST" "${DISPLAY}" & + +# Wait for X11 to start +echo "Waiting for X socket" + until [ -S "/tmp/.X11-unix/X${DISPLAY/:/}" ]; do sleep 1; done +echo "X socket is ready" + +echo "Session Running. Press [Return] to exit." +read diff --git a/.scripts/supervisord.conf b/.scripts/supervisord.conf new file mode 100644 index 00000000..9b12c64c --- /dev/null +++ b/.scripts/supervisord.conf @@ -0,0 +1,28 @@ +[supervisord] +user=netris +nodaemon=true +loglevel=info +logfile=/tmp/supervisord.log +pidfile=/tmp/supervisord.pid + +[program:entrypoint] +command=/usr/bin/netris/entrypoint.sh +logfile=/tmp/entrypoint.log +pidfile=/tmp/entrypoint.pid +stopsignal=INT +autostart=true +autorestart=true +redirect_stderr=true +priority=1 + +[program:pulseaudio] +user=netris +command=bash -c "until [ -S \"/tmp/.X11-unix/X${DISPLAY/:/}\" ]; do sleep 1; done; sudo /usr/bin/pulseaudio -k >/dev/null 2>&1 || sudo /usr/bin/pulseaudio --system --verbose --log-target=stderr --realtime=true --disallow-exit -L 'module-native-protocol-tcp auth-ip-acl=127.0.0.0/8 port=4713 auth-anonymous=1'" +environment=DISPLAY=":0" +logfile=/tmp/pulseaudio.log +pidfile=/tmp/pulseaudio.pid +stopsignal=INT +autostart=true +autorestart=true +redirect_stderr=true +priority=10 \ No newline at end of file diff --git a/base.Dockerfile b/base.Dockerfile index 4b888301..265e8513 100644 --- a/base.Dockerfile +++ b/base.Dockerfile @@ -2,11 +2,205 @@ # From https://git.dec05eba.com/gpu-screen-recorder FROM ubuntu:23.10 -ENV DEBIAN_FRONTEND=noninteractive +ENV DEBIAN_FRONTEND=noninteractive \ + TIMEZONE=Africa/Nairobi \ + XDG_RUNTIME_DIR=/tmp/runtime-netris \ + DISPLAY=:0 \ + PULSE_SERVER=unix:/run/pulse/native + # WAYLAND_DISPLAY=wayland-0 -# To run /usr/bin/gpu-screen-recorder. -# Add this to your runtime -# docker run --rm --cap-add SYS_ADMIN --cap-add SYS_NICE netris/gpu-screen-recorder +# Install fundamental packages +RUN apt-get clean \ + && apt-get update \ + && apt-get upgrade -y \ + && apt-get install --no-install-recommends -y \ + apt-transport-https \ + apt-utils \ + build-essential \ + ca-certificates \ + curl \ + gnupg \ + locales \ + make \ + software-properties-common \ + wget \ + && rm -rf /var/lib/apt/lists/* \ + && locale-gen en_US.UTF-8 + +# Set locales +ENV LANG=en_US.UTF-8 \ + LANGUAGE=en_US:en \ + LC_ALL=en_US.UTF-8 + +# Install operating system libraries or packages +RUN dpkg --add-architecture i386 \ + && apt-get update \ + && apt-get install --no-install-recommends -y \ + alsa-base \ + alsa-utils \ + cups-browsed \ + cups-bsd \ + cups-common \ + cups-filters \ + printer-driver-cups-pdf \ + file \ + bzip2 \ + gzip \ + xz-utils \ + unar \ + rar \ + unrar \ + zip \ + unzip \ + zstd \ + gcc \ + git \ + jq \ + python3 \ + python3-cups \ + python3-numpy \ + ssl-cert \ + nano \ + vim \ + htop \ + fakeroot \ + fonts-dejavu \ + fonts-freefont-ttf \ + fonts-hack \ + fonts-liberation \ + fonts-noto \ + fonts-noto-cjk \ + fonts-noto-cjk-extra \ + fonts-noto-color-emoji \ + fonts-noto-extra \ + fonts-noto-ui-extra \ + fonts-noto-hinted \ + fonts-noto-mono \ + fonts-noto-unhinted \ + fonts-opensymbol \ + fonts-symbola \ + fonts-ubuntu \ + lame \ + less \ + libavcodec-extra \ + libpulse0 \ + pulseaudio \ + supervisor \ + net-tools \ + packagekit-tools \ + pkg-config \ + mesa-utils \ + va-driver-all \ + va-driver-all:i386 \ + i965-va-driver-shaders \ + i965-va-driver-shaders:i386 \ + intel-media-va-driver-non-free \ + intel-media-va-driver-non-free:i386 \ + libva2 \ + libva2:i386 \ + vainfo \ + vdpau-driver-all \ + vdpau-driver-all:i386 \ + vdpauinfo \ + mesa-vulkan-drivers \ + mesa-vulkan-drivers:i386 \ + libvulkan-dev \ + libvulkan-dev:i386 \ + vulkan-tools \ + ocl-icd-libopencl1 \ + clinfo \ + dbus-user-session \ + dbus-x11 \ + libdbus-c++-1-0v5 \ + xkb-data \ + xauth \ + xbitmaps \ + xdg-user-dirs \ + xdg-utils \ + xfonts-base \ + xfonts-scalable \ + xinit \ + xsettingsd \ + libxrandr-dev \ + x11-xkb-utils \ + x11-xserver-utils \ + x11-utils \ + x11-apps \ + xserver-xorg-input-all \ + xserver-xorg-input-wacom \ + xserver-xorg-video-all \ + xserver-xorg-video-intel \ + xserver-xorg-video-qxl \ + # Install OpenGL libraries + libxau6 \ + libxau6:i386 \ + libxdmcp6 \ + libxdmcp6:i386 \ + libxcb1 \ + libxcb1:i386 \ + libxext6 \ + libxext6:i386 \ + libx11-6 \ + libx11-6:i386 \ + libxv1 \ + libxv1:i386 \ + libxtst6 \ + libxtst6:i386 \ + libglvnd0 \ + libglvnd0:i386 \ + libgl1 \ + libgl1:i386 \ + libglx0 \ + libglx0:i386 \ + libegl1 \ + libegl1:i386 \ + libgles2 \ + libgles2:i386 \ + libglu1 \ + libglu1:i386 \ + libsm6 \ + libsm6:i386 \ + mesa-utils \ + mesa-utils-extra \ + && 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 OpenCL manually + && mkdir -pm755 /etc/OpenCL/vendors \ + && echo "libnvidia-opencl.so.1" > /etc/OpenCL/vendors/nvidia.icd \ + # 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 + +# Expose NVIDIA libraries and paths +ENV PATH=/usr/local/nvidia/bin${PATH:+:${PATH}} \ + LD_LIBRARY_PATH=${LD_LIBRARY_PATH:+${LD_LIBRARY_PATH}:}/usr/local/nvidia/lib:/usr/local/nvidia/lib64 \ + XDG_SESSION_TYPE=x11 \ + # Enable AppImage execution in containers + APPIMAGE_EXTRACT_AND_RUN=1 + +ENV \ + # 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 for NVIDIA GPUs + __GL_SYNC_TO_VBLANK=0 #Build and install gpu-screen-recorder RUN apt-get update -y \ @@ -51,17 +245,17 @@ RUN apt-get update -y \ libwayland-egl-backend-dev \ wayland-protocols \ && rm -rf /var/lib/apt/lists/* \ - #Install Cuda - && cd /tmp && curl -fsSL -o nvidia_cuda_nvrtc_linux_x86_64.whl "https://developer.download.nvidia.com/compute/redist/nvidia-cuda-nvrtc/nvidia_cuda_nvrtc-11.0.221-cp36-cp36m-linux_x86_64.whl" \ + #Install Nvrtc + && NVRTC_VERSION="11.0.221" \ + && cd /tmp && curl -fsSL -o nvidia_cuda_nvrtc_linux_x86_64.whl "https://developer.download.nvidia.com/compute/redist/nvidia-cuda-nvrtc/nvidia_cuda_nvrtc-${NVRTC_VERSION}-cp36-cp36m-linux_x86_64.whl" \ && unzip -joq -d ./nvrtc nvidia_cuda_nvrtc_linux_x86_64.whl && cd nvrtc && chmod 755 libnvrtc* \ && find . -maxdepth 1 -type f -name "*libnvrtc.so.*" -exec sh -c 'ln -snf $(basename {}) libnvrtc.so' \; \ && mkdir -p /usr/local/nvidia/lib && mv -f libnvrtc* /usr/local/nvidia/lib \ - && echo "/usr/local/nvidia/lib" >> /etc/ld.so.conf.d/nvidia.conf && echo "/usr/local/nvidia/lib64" >> /etc/ld.so.conf.d/nvidia.conf \ && git clone https://repo.dec05eba.com/gpu-screen-recorder && cd gpu-screen-recorder \ && chmod +x ./build.sh ./install.sh \ && ./install.sh -#Try building +#Try building shadow-cast RUN git clone https://github.com/gmbeard/shadow-cast && cd shadow-cast \ && mkdir ./build && cd ./build \ && cmake -DCMAKE_CXX_FLAGS="-Wno-error=unused-result" -DCMAKE_C_FLAGS="-Wno-error=unused-result" .. \ @@ -77,5 +271,17 @@ RUN apt-get update -y; \ apt-get upgrade -y && apt-get dist-upgrade -y; \ apt-get install ffmpeg -y; \ # - # Log out the ffmpeg version - ffmpeg -version \ No newline at end of file + # Log the ffmpeg version + ffmpeg -version + +# Install Xorg and NVIDIA driver installer dependencies +RUN apt-get update \ + && apt-get install --no-install-recommends -y \ + kmod \ + libc6-dev \ + libc6:i386 \ + libpci3 \ + libelf-dev \ + pkg-config \ + xorg \ + && rm -rf /var/lib/apt/lists/* \ No newline at end of file diff --git a/server.Dockerfile b/server.Dockerfile index b0c5bb0d..bf80630d 100644 --- a/server.Dockerfile +++ b/server.Dockerfile @@ -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" ] \ No newline at end of file +ENTRYPOINT ["/usr/bin/supervisord"] \ No newline at end of file