mirror of
https://github.com/nestriness/nestri.git
synced 2025-12-12 08:45:38 +02:00
⚡ perf(runner): Reduce CI buildtimes (#174)
This is an effort to reduce build times, for the runner image --------- Co-authored-by: Kristian Ollikainen <14197772+DatCaptainHorse@users.noreply.github.com>
This commit is contained in:
@@ -2,173 +2,252 @@
|
||||
ARG BASE_IMAGE=docker.io/cachyos/cachyos:latest
|
||||
|
||||
#******************************************************************************
|
||||
# nestri-server-builder
|
||||
# base-builder
|
||||
#******************************************************************************
|
||||
FROM ${BASE_IMAGE} AS gst-builder
|
||||
WORKDIR /builder/
|
||||
FROM ${BASE_IMAGE} AS base-builder
|
||||
|
||||
# Grab build and rust packages #
|
||||
RUN pacman -Sy --noconfirm meson pkgconf cmake git gcc make rustup \
|
||||
gstreamer gst-plugins-base gst-plugins-good gst-plugin-rswebrtc
|
||||
|
||||
# Setup stable rust toolchain #
|
||||
RUN rustup default stable
|
||||
|
||||
#Copy the whole repo inside the build container
|
||||
# COPY ./ /builder/nestri/
|
||||
# Install mold linker and sccache upfront
|
||||
RUN pacman -Sy --noconfirm mold && \
|
||||
pacman -S --noconfirm rust && \
|
||||
cargo install -j $(nproc) --root /usr/local sccache
|
||||
|
||||
RUN --mount=type=cache,target=/usr/local/cargo/registry \
|
||||
CARGO_HOME=/usr/local/cargo \
|
||||
cargo install --locked cargo-chef
|
||||
|
||||
ENV ARTIFACTS=/artifacts
|
||||
RUN mkdir -p /artifacts
|
||||
|
||||
#******************************************************************************
|
||||
# nestri-server-builder
|
||||
#******************************************************************************
|
||||
# FROM base-builder AS nestri-server-builder
|
||||
# WORKDIR /builder/
|
||||
|
||||
RUN --mount=type=bind,target=/builder/nestri/,rw \
|
||||
--mount=type=cache,target=/builder/nestri/target/ \
|
||||
--mount=type=cache,target=/usr/local/cargo/git/db \
|
||||
--mount=type=cache,target=/usr/local/cargo/registry/ \
|
||||
cd /builder/nestri/packages/server/ \
|
||||
&& cargo build --release \
|
||||
&& cp /builder/nestri/target/release/nestri-server /artifacts/
|
||||
# RUN pacman -Sy --noconfirm meson pkgconf cmake git gcc make \
|
||||
# gstreamer gst-plugins-base gst-plugins-good gst-plugin-rswebrtc
|
||||
|
||||
#******************************************************************************
|
||||
# gstwayland-builder
|
||||
# nestri-server-planner
|
||||
#******************************************************************************
|
||||
FROM ${BASE_IMAGE} AS gstwayland-builder
|
||||
|
||||
# FROM nestri-server-builder AS nestri-server-planner
|
||||
# WORKDIR /builder/nestri/
|
||||
# COPY packages/server/Cargo.toml packages/server/Cargo.lock ./
|
||||
# RUN --mount=type=cache,target=/root/.cache/sccache \
|
||||
# --mount=type=cache,target=/usr/local/cargo/registry \
|
||||
# --mount=type=cache,target=/tmp \
|
||||
# export RUSTC_WRAPPER=/usr/local/bin/sccache && \
|
||||
# cargo chef prepare --recipe-path recipe.json
|
||||
|
||||
#******************************************************************************
|
||||
# nestri-server-cacher
|
||||
#******************************************************************************
|
||||
# FROM nestri-server-builder AS nestri-server-cacher
|
||||
# WORKDIR /builder/nestri/
|
||||
|
||||
# COPY --from=nestri-server-planner /builder/nestri/recipe.json .
|
||||
# RUN --mount=type=cache,target=/root/.cache/sccache \
|
||||
# --mount=type=cache,target=/usr/local/cargo/registry \
|
||||
# --mount=type=cache,target=/tmp \
|
||||
# export RUSTC_WRAPPER=/usr/local/bin/sccache && \
|
||||
# cargo chef cook --release --recipe-path recipe.json
|
||||
|
||||
#******************************************************************************
|
||||
# nestri-server-build
|
||||
#******************************************************************************
|
||||
# FROM nestri-server-builder AS nestri-server-build
|
||||
# WORKDIR /builder/nestri/
|
||||
|
||||
# COPY --from=nestri-server-cacher /builder/nestri/target target
|
||||
# COPY packages/server/ ./packages/server/
|
||||
|
||||
# RUN --mount=type=cache,target=/root/.cache/sccache \
|
||||
# --mount=type=cache,target=/usr/local/cargo/registry \
|
||||
# --mount=type=cache,target=/tmp \
|
||||
# export RUSTC_WRAPPER=/usr/local/bin/sccache && \
|
||||
# export CARGO_BUILD_JOBS=$(nproc) && \
|
||||
# export RUSTFLAGS="-C link-arg=-fuse-ld=mold -C target-cpu=native" && \
|
||||
# cargo build --release && \
|
||||
# cp target/release/nestri-server "$ARTIFACTS"
|
||||
|
||||
#******************************************************************************
|
||||
# gst-wayland-builder
|
||||
#******************************************************************************
|
||||
FROM base-builder AS gst-wayland-builder
|
||||
WORKDIR /builder/
|
||||
|
||||
# Grab build and rust packages #
|
||||
RUN pacman -Sy --noconfirm meson pkgconf cmake git gcc make rustup \
|
||||
libxkbcommon wayland gstreamer gst-plugins-base gst-plugins-good libinput
|
||||
RUN pacman -Sy --noconfirm meson pkgconf cmake git gcc make \
|
||||
libxkbcommon wayland gstreamer gst-plugins-base gst-plugins-good libinput
|
||||
|
||||
# Setup stable rust toolchain #
|
||||
RUN rustup default stable
|
||||
# Build required cargo-c package #
|
||||
RUN --mount=type=cache,target=/usr/local/cargo/git/db \
|
||||
--mount=type=cache,target=/usr/local/cargo/registry/ \
|
||||
--mount=type=cache,target=/root/.cargo/bin/ \
|
||||
cargo install cargo-c
|
||||
RUN --mount=type=cache,target=/usr/local/cargo/registry \
|
||||
CARGO_HOME=/usr/local/cargo \
|
||||
cargo install --locked 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
|
||||
|
||||
RUN mkdir -p /artifacts
|
||||
|
||||
#******************************************************************************
|
||||
# gst-wayland-planner
|
||||
#******************************************************************************
|
||||
FROM gst-wayland-builder AS gst-wayland-planner
|
||||
WORKDIR /builder/gst-wayland-display
|
||||
|
||||
RUN --mount=type=cache,target=/builder/gst-wayland-display/target/ \
|
||||
--mount=type=cache,target=/root/.cargo/bin/ \
|
||||
RUN --mount=type=cache,target=/root/.cache/sccache \
|
||||
--mount=type=cache,target=/tmp \
|
||||
--mount=type=cache,target=/usr/local/cargo/registry \
|
||||
--mount=type=cache,target=/builder/plugin/ \
|
||||
--mount=type=cache,target=/usr/local/cargo/git/db \
|
||||
--mount=type=cache,target=/usr/local/cargo/registry/ \
|
||||
cargo cinstall --prefix=/builder/plugin/ \
|
||||
&& cp -r /builder/plugin/ /artifacts/
|
||||
export RUSTC_WRAPPER=/usr/local/bin/sccache && \
|
||||
CARGO_HOME=/usr/local/cargo \
|
||||
cargo chef prepare --recipe-path recipe.json
|
||||
|
||||
#******************************************************************************
|
||||
# runtime
|
||||
# gst-wayland-cacher
|
||||
#******************************************************************************
|
||||
FROM gst-wayland-builder AS gst-wayland-cacher
|
||||
|
||||
COPY --from=gst-wayland-planner /builder/gst-wayland-display/recipe.json .
|
||||
|
||||
RUN --mount=type=cache,target=/root/.cache/sccache \
|
||||
--mount=type=cache,target=/usr/local/cargo/registry \
|
||||
--mount=type=cache,target=/builder/target \
|
||||
--mount=type=cache,target=/builder/plugin/ \
|
||||
--mount=type=cache,target=/tmp \
|
||||
export CARGO_TARGET_DIR=/builder/target \
|
||||
export RUSTC_WRAPPER=/usr/local/bin/sccache && \
|
||||
CARGO_HOME=/usr/local/cargo \
|
||||
cargo chef cook --release --recipe-path recipe.json
|
||||
|
||||
#******************************************************************************
|
||||
# gst-wayland-build
|
||||
#******************************************************************************
|
||||
|
||||
FROM gst-wayland-builder AS gst-wayland-build
|
||||
WORKDIR /builder/gst-wayland-display
|
||||
|
||||
COPY --from=gst-wayland-cacher /builder/ /builder/
|
||||
COPY . .
|
||||
|
||||
RUN --mount=type=cache,target=/root/.cache/sccache \
|
||||
--mount=type=cache,target=/usr/local/cargo/registry \
|
||||
--mount=type=cache,target=/builder/plugin/ \
|
||||
--mount=type=cache,target=/builder/target \
|
||||
export RUSTC_WRAPPER=/usr/local/bin/sccache \
|
||||
export CARGO_TARGET_DIR=/builder/target \
|
||||
export CARGO_BUILD_JOBS=$(nproc) \
|
||||
export RUSTFLAGS="-C link-arg=-fuse-ld=mold" && \
|
||||
CARGO_HOME=/usr/local/cargo \
|
||||
cargo cinstall --prefix=/builder/plugin/ --release && \
|
||||
cp -r /builder/plugin/ "$ARTIFACTS"
|
||||
|
||||
|
||||
#******************************************************************************
|
||||
# runtime
|
||||
#******************************************************************************
|
||||
FROM ${BASE_IMAGE} AS runtime
|
||||
|
||||
## Install Graphics, Media, and Audio packages ##
|
||||
RUN sed -i '/#\[multilib\]/,/#Include = \/etc\/pacman.d\/mirrorlist/ s/#//' /etc/pacman.conf && \
|
||||
sed -i "s/#Color/Color/" /etc/pacman.conf && \
|
||||
pacman --noconfirm -Syu archlinux-keyring && \
|
||||
dirmngr </dev/null > /dev/null 2>&1 && \
|
||||
# Install mesa-git before Steam for simplicity
|
||||
pacman --noconfirm -Sy mesa && \
|
||||
# Install Steam
|
||||
pacman --noconfirm -Sy steam steam-native-runtime && \
|
||||
# Clean up pacman cache
|
||||
paccache -rk1 && \
|
||||
rm -rf /usr/share/info/* && \
|
||||
rm -rf /usr/share/man/* && \
|
||||
rm -rf /usr/share/doc/
|
||||
# ## Install Graphics, Media, and Audio packages ##
|
||||
# RUN sed -i '/#\[multilib\]/,/#Include = \/etc\/pacman.d\/mirrorlist/ s/#//' /etc/pacman.conf && \
|
||||
# sed -i "s/#Color/Color/" /etc/pacman.conf && \
|
||||
# pacman --noconfirm -Syu archlinux-keyring && \
|
||||
# dirmngr </dev/null > /dev/null 2>&1 && \
|
||||
# # Install mesa-git before Steam for simplicity
|
||||
# pacman --noconfirm -Sy mesa && \
|
||||
# # Install Steam
|
||||
# pacman --noconfirm -Sy steam steam-native-runtime && \
|
||||
# # Clean up pacman cache
|
||||
# paccache -rk1 && \
|
||||
# rm -rf /usr/share/info/* && \
|
||||
# rm -rf /usr/share/man/* && \
|
||||
# rm -rf /usr/share/doc/
|
||||
|
||||
RUN pacman -Sy --noconfirm --needed \
|
||||
# Graphics packages
|
||||
sudo xorg-xwayland labwc wlr-randr mangohud \
|
||||
# GStreamer and plugins
|
||||
gstreamer gst-plugins-base gst-plugins-good \
|
||||
gst-plugins-bad gst-plugin-pipewire \
|
||||
gst-plugin-rswebrtc gst-plugin-rsrtp \
|
||||
# Audio packages
|
||||
pipewire pipewire-pulse pipewire-alsa wireplumber \
|
||||
# Non-latin fonts
|
||||
noto-fonts-cjk \
|
||||
# Other requirements
|
||||
supervisor jq chwd lshw pacman-contrib && \
|
||||
# Clean up pacman cache
|
||||
paccache -rk1 && \
|
||||
rm -rf /usr/share/info/* && \
|
||||
rm -rf /usr/share/man/* && \
|
||||
rm -rf /usr/share/doc/*
|
||||
# RUN pacman -Sy --noconfirm --needed \
|
||||
# # Graphics packages
|
||||
# sudo xorg-xwayland labwc wlr-randr mangohud \
|
||||
# # GStreamer and plugins
|
||||
# gstreamer gst-plugins-base gst-plugins-good \
|
||||
# gst-plugins-bad gst-plugin-pipewire \
|
||||
# gst-plugin-rswebrtc gst-plugin-rsrtp \
|
||||
# # Audio packages
|
||||
# pipewire pipewire-pulse pipewire-alsa wireplumber \
|
||||
# # Non-latin fonts
|
||||
# noto-fonts-cjk \
|
||||
# # Other requirements
|
||||
# supervisor jq chwd lshw pacman-contrib && \
|
||||
# # Clean up pacman cache
|
||||
# paccache -rk1 && \
|
||||
# rm -rf /usr/share/info/* && \
|
||||
# rm -rf /usr/share/man/* && \
|
||||
# rm -rf /usr/share/doc/*
|
||||
|
||||
#Install our backup manager
|
||||
ARG LUDUSAVI_VERSION="0.28.0"
|
||||
RUN pacman -Sy --noconfirm --needed wget &&\
|
||||
wget "https://github.com/mtkennerly/ludusavi/releases/download/v${LUDUSAVI_VERSION}/ludusavi-v${LUDUSAVI_VERSION}-linux.tar.gz" -O "ludusavi.tar.gz" &&\
|
||||
tar -xzvf ludusavi.tar.gz &&\
|
||||
mv ludusavi /usr/bin/ &&\
|
||||
#Clean up
|
||||
rm *.tar.gz
|
||||
# #Install our backup manager
|
||||
# ARG LUDUSAVI_VERSION="0.28.0"
|
||||
# RUN pacman -Sy --noconfirm --needed curl &&\
|
||||
# curl -fsSL -o ludusavi.tar.gz "https://github.com/mtkennerly/ludusavi/releases/download/v${LUDUSAVI_VERSION}/ludusavi-v${LUDUSAVI_VERSION}-linux.tar.gz" &&\
|
||||
# tar -xzvf ludusavi.tar.gz &&\
|
||||
# mv ludusavi /usr/bin/ &&\
|
||||
# #Clean up
|
||||
# rm *.tar.gz
|
||||
|
||||
# Regenerate locale
|
||||
RUN locale-gen
|
||||
# # Regenerate locale
|
||||
# RUN locale-gen
|
||||
|
||||
## User ##
|
||||
# Create and setup user #
|
||||
ENV USER="nestri" \
|
||||
UID=1000 \
|
||||
GID=1000 \
|
||||
USER_PWD="nestri1234"
|
||||
# ## User ##
|
||||
# # Create and setup user #
|
||||
# ENV USER="nestri" \
|
||||
# UID=1000 \
|
||||
# GID=1000 \
|
||||
# USER_PWD="nestri1234"
|
||||
|
||||
RUN mkdir -p /home/${USER} && \
|
||||
groupadd -g ${GID} ${USER} && \
|
||||
useradd -d /home/${USER} -u ${UID} -g ${GID} -s /bin/bash ${USER} && \
|
||||
chown -R ${USER}:${USER} /home/${USER} && \
|
||||
echo "${USER} ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers && \
|
||||
echo "${USER}:${USER_PWD}" | chpasswd
|
||||
# RUN mkdir -p /home/${USER} && \
|
||||
# groupadd -g ${GID} ${USER} && \
|
||||
# useradd -d /home/${USER} -u ${UID} -g ${GID} -s /bin/bash ${USER} && \
|
||||
# chown -R ${USER}:${USER} /home/${USER} && \
|
||||
# echo "${USER} ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers && \
|
||||
# echo "${USER}:${USER_PWD}" | chpasswd
|
||||
|
||||
# Run directory #
|
||||
RUN mkdir -p /run/user/${UID} && \
|
||||
chown ${USER}:${USER} /run/user/${UID}
|
||||
# # Run directory #
|
||||
# RUN mkdir -p /run/user/${UID} && \
|
||||
# chown ${USER}:${USER} /run/user/${UID}
|
||||
|
||||
# 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} && \
|
||||
usermod -aG seat root && usermod -aG seat ${USER}
|
||||
# # 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} && \
|
||||
# usermod -aG seat root && usermod -aG seat ${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 /artifacts/nestri-server /usr/bin/nestri-server
|
||||
# ## Copy files from builders ##
|
||||
# # this is done here at end to not trigger full rebuild on changes to builder
|
||||
# # nestri
|
||||
# COPY --from=nestri-server-build /artifacts/nestri-server /usr/bin/nestri-server
|
||||
# gstwayland
|
||||
COPY --from=gstwayland-builder /artifacts/plugin/include/libgstwaylanddisplay /usr/include/
|
||||
COPY --from=gstwayland-builder /artifacts/plugin/lib/*libgstwayland* /usr/lib/
|
||||
COPY --from=gstwayland-builder /artifacts/plugin/lib/gstreamer-1.0/libgstwayland* /usr/lib/gstreamer-1.0/
|
||||
COPY --from=gstwayland-builder /artifacts/plugin/lib/pkgconfig/gstwayland* /usr/lib/pkgconfig/
|
||||
COPY --from=gstwayland-builder /artifacts/plugin/lib/pkgconfig/libgstwayland* /usr/lib/pkgconfig/
|
||||
COPY --from=gst-wayland-build /artifacts/plugin/include/libgstwaylanddisplay /usr/include/
|
||||
COPY --from=gst-wayland-build /artifacts/plugin/lib/*libgstwayland* /usr/lib/
|
||||
COPY --from=gst-wayland-build /artifacts/plugin/lib/gstreamer-1.0/libgstwayland* /usr/lib/gstreamer-1.0/
|
||||
COPY --from=gst-wayland-build /artifacts/plugin/lib/pkgconfig/gstwayland* /usr/lib/pkgconfig/
|
||||
COPY --from=gst-wayland-build /artifacts/plugin/lib/pkgconfig/libgstwayland* /usr/lib/pkgconfig/
|
||||
|
||||
## Copy scripts ##
|
||||
COPY packages/scripts/ /etc/nestri/
|
||||
# Set scripts as executable #
|
||||
RUN chmod +x /etc/nestri/envs.sh /etc/nestri/entrypoint.sh /etc/nestri/entrypoint_nestri.sh
|
||||
# ## Copy scripts ##
|
||||
# COPY packages/scripts/ /etc/nestri/
|
||||
# # Set scripts as executable #
|
||||
# RUN chmod +x /etc/nestri/envs.sh /etc/nestri/entrypoint.sh /etc/nestri/entrypoint_nestri.sh
|
||||
|
||||
## Set runtime envs ##
|
||||
ENV XDG_RUNTIME_DIR=/run/user/${UID} \
|
||||
HOME=/home/${USER}
|
||||
# ## Set runtime envs ##
|
||||
# ENV XDG_RUNTIME_DIR=/run/user/${UID} \
|
||||
# HOME=/home/${USER}
|
||||
|
||||
# Required for NVIDIA.. they want to be special like that #
|
||||
ENV NVIDIA_DRIVER_CAPABILITIES=all
|
||||
ENV NVIDIA_VISIBLE_DEVICES=all
|
||||
# # Required for NVIDIA.. they want to be special like that #
|
||||
# ENV NVIDIA_DRIVER_CAPABILITIES=all
|
||||
# ENV NVIDIA_VISIBLE_DEVICES=all
|
||||
|
||||
# DBus run directory creation #
|
||||
RUN mkdir -p /run/dbus
|
||||
# # DBus run directory creation #
|
||||
# RUN mkdir -p /run/dbus
|
||||
|
||||
# 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
|
||||
# # 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/nestri/supervisord.conf"]
|
||||
# ENTRYPOINT ["supervisord", "-c", "/etc/nestri/supervisord.conf"]
|
||||
|
||||
Reference in New Issue
Block a user