# Container build arguments # ARG BASE_IMAGE=docker.io/cachyos/cachyos-v3:latest #****************************************************************************** # gst-builder #****************************************************************************** FROM ${BASE_IMAGE} AS gst-builder WORKDIR /builder/ # Grab build and rust packages # RUN pacman -Syu --noconfirm meson pkgconf cmake git gcc make rustup \ gstreamer gst-plugins-base gst-plugins-good # Setup stable rust toolchain # RUN rustup default stable # Clone nestri source # RUN git clone -b feat/stream https://github.com/nestriness/nestri.git # Build nestri # RUN cd nestri/packages/server/ && \ cargo build --release #****************************************************************************** # gstwayland-builder #****************************************************************************** FROM ${BASE_IMAGE} AS gstwayland-builder WORKDIR /builder/ # Grab build and rust packages # RUN pacman -Syu --noconfirm meson pkgconf cmake git gcc make rustup \ libxkbcommon wayland gstreamer gst-plugins-base gst-plugins-good libinput # Setup stable rust toolchain # RUN rustup default stable # Build required cargo-c package # RUN cargo install cargo-c # Clone gst plugin source # RUN git clone https://github.com/games-on-whales/gst-wayland-display.git # Build gst plugin # RUN mkdir plugin && \ cd gst-wayland-display && \ cargo cinstall --prefix=/builder/plugin/ #****************************************************************************** # runtime #****************************************************************************** FROM ${BASE_IMAGE} AS runtime ## Nestri Env Variables ## ENV NESTRI_PARAMS="" ENV RESOLUTION="1280x720" ## Install Graphics, Media, and Audio packages ## RUN pacman -Syu --noconfirm --needed \ # Graphics packages sudo mesa mesa-utils xorg-xwayland labwc wlr-randr mangohud \ # Vulkan drivers vulkan-intel vulkan-radeon nvidia-utils \ # Media encoding packages vpl-gpu-rt intel-media-driver libva-utils \ # GStreamer plugins gstreamer gst-plugins-base gst-plugins-good \ gst-plugin-va gst-plugins-bad gst-plugin-fmp4 \ gst-plugin-qsv gst-plugin-pipewire gst-plugin-rswebrtc \ gst-plugins-ugly gst-plugin-rsrtp \ # Audio packages pipewire pipewire-pulse pipewire-alsa wireplumber \ # Other requirements supervisor \ # Custom umu-launcher && \ # Clean up pacman cache and unnecessary files pacman -Scc --noconfirm && \ rm -rf /var/cache/pacman/pkg/* /tmp/* /var/tmp/* && \ # Optionally clean documentation, man pages, and locales find /usr/share/locale -mindepth 1 -maxdepth 1 ! -name "en*" -exec rm -rf {} + && \ rm -rf /usr/share/doc /usr/share/man /usr/share/info ## User ## # Create and setup user # ENV USER="nestri" \ UID=99 \ GID=100 \ USER_PASSWORD="nestri1234" \ USER_HOME="/home/nestri" RUN mkdir -p ${USER_HOME} && \ useradd -d ${USER_HOME} -u ${UID} -s /bin/bash ${USER} && \ chown -R ${USER} ${USER_HOME} && \ echo "${USER} ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers && \ echo "${USER}:${USER_PASSWORD}" | chpasswd # Run directory # RUN mkdir -p /run/user/${UID} && \ chown ${USER}:${USER} /run/user/${UID} # Home config directory # RUN mkdir -p ${USER_HOME}/.config && \ chown ${USER}:${USER} ${USER_HOME}/.config # Groups # RUN usermod -aG input root && usermod -aG input ${USER} && \ usermod -aG video root && usermod -aG video ${USER} && \ usermod -aG render root && usermod -aG render ${USER} ## Copy files from builders ## # this is done here at end to not trigger full rebuild on changes to builder # nestri COPY --from=gst-builder /builder/nestri/target/release/nestri-server /usr/bin/nestri-server # gstwayland COPY --from=gstwayland-builder /builder/plugin/include/libgstwaylanddisplay /usr/include/ COPY --from=gstwayland-builder /builder/plugin/lib/*libgstwayland* /usr/lib/ COPY --from=gstwayland-builder /builder/plugin/lib/gstreamer-1.0/libgstwayland* /usr/lib/gstreamer-1.0/ COPY --from=gstwayland-builder /builder/plugin/lib/pkgconfig/gstwayland* /usr/lib/pkgconfig/ COPY --from=gstwayland-builder /builder/plugin/lib/pkgconfig/libgstwayland* /usr/lib/pkgconfig/ ## Copy scripts ## COPY packages/scripts/ /etc/nestri/ ## Startup ## # Setup supervisor # RUN <<-EOF echo -e " [supervisord] user=root nodaemon=true loglevel=info logfile=/tmp/supervisord.log [program:dbus] user=root command=dbus-daemon --system --nofork --nopidfile logfile=/tmp/dbus.log autoerestart=true autostart=true startretries=3 priority=1 [program:seatd] user=root command=seatd logfile=/tmp/seatd.log autoerestart=true autostart=true startretries=3 priority=2 [program:pipewire] user=nestri command=dbus-launch pipewire environment=XDG_RUNTIME_DIR=\"/run/user/${UID}\",HOME=\"${USER_HOME}\" logfile=/tmp/pipewire.log autoerestart=true autostart=true startretries=3 priority=10 [program:pipewire-pulse] user=nestri command=dbus-launch pipewire-pulse environment=XDG_RUNTIME_DIR=\"/run/user/${UID}\",HOME=\"${USER_HOME}\" logfile=/tmp/pipewire-pulse.log autoerestart=true autostart=true startretries=3 priority=20 [program:wireplumber] user=nestri command=dbus-launch wireplumber environment=XDG_RUNTIME_DIR=\"/run/user/${UID}\",HOME=\"${USER_HOME}\" logfile=/tmp/wireplumber.log autoerestart=true autostart=true startretries=3 priority=30 [program:nestri-server] user=nestri command=sh -c 'nestri-server \$NESTRI_PARAMS' environment=XDG_RUNTIME_DIR=\"/run/user/${UID}\",HOME=\"${USER_HOME}\" logfile=/tmp/nestri-server.log autoerestart=true autostart=true startretries=3 priority=50 [program:labwc] user=nestri command=sh -c 'sleep 4 && rm -rf /tmp/.X11-unix && mkdir -p /tmp/.X11-unix && chown nestri:nestri /tmp/.X11-unix && labwc' environment=XDG_RUNTIME_DIR=\"/run/user/${UID}\",HOME=\"${USER_HOME}\",WAYLAND_DISPLAY=\"wayland-1\",WLR_BACKENDS=\"wayland\",WLR_RENDERER=\"vulkan\" logfile=/tmp/labwc.log autoerestart=true autostart=true startretries=5 priority=60 [program:wlrrandr] user=nestri command=sh -c 'sleep 6 && wlr-randr --output WL-1 --custom-mode \$RESOLUTION && read -n 1' environment=XDG_RUNTIME_DIR=\"/run/user/${UID}\",HOME=\"${USER_HOME}\",WAYLAND_DISPLAY=\"wayland-0\" logfile=/tmp/wlrrandr.log autoerestart=true autostart=true startretries=10 priority=70 " | tee /etc/supervisord.conf EOF # Wireplumber disable suspend # # Remove suspend node RUN sed -z -i 's/{[[:space:]]*name = node\/suspend-node\.lua,[[:space:]]*type = script\/lua[[:space:]]*provides = hooks\.node\.suspend[[:space:]]*}[[:space:]]*//g' /usr/share/wireplumber/wireplumber.conf # Remove "hooks.node.suspend" want RUN sed -i '/wants = \[/{s/hooks\.node\.suspend\s*//; s/,\s*\]/]/}' /usr/share/wireplumber/wireplumber.conf ENTRYPOINT ["supervisord", "-c", "/etc/supervisord.conf"]