build(Linux): Refactor Dockerfiles and build script for multi-stage, step-based builds (#4299)

This commit is contained in:
ReenigneArcher
2025-09-25 08:35:02 -04:00
committed by GitHub
parent 2a3a4094ac
commit 9c1b8db5cd
5 changed files with 376 additions and 158 deletions

View File

@@ -9,7 +9,29 @@ FROM ${BASE}:${TAG} AS sunshine-base
ENV DEBIAN_FRONTEND=noninteractive
FROM sunshine-base AS sunshine-build
FROM sunshine-base AS sunshine-deps
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
# Copy only the build script and necessary files first for better layer caching
WORKDIR /build/sunshine/
COPY --link scripts/linux_build.sh ./scripts/linux_build.sh
COPY --link packaging/linux/patches/ ./packaging/linux/patches/
# Install dependencies first - this layer will be cached
RUN <<_DEPS
#!/bin/bash
set -e
chmod +x ./scripts/linux_build.sh
./scripts/linux_build.sh \
--step=deps \
--cuda-patches \
--sudo-off
apt-get clean
rm -rf /var/lib/apt/lists/*
_DEPS
FROM sunshine-deps AS sunshine-build
ARG BRANCH
ARG BUILD_VERSION
@@ -20,25 +42,31 @@ ENV BRANCH=${BRANCH}
ENV BUILD_VERSION=${BUILD_VERSION}
ENV COMMIT=${COMMIT}
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
# copy repository
WORKDIR /build/sunshine/
# Now copy the full repository
COPY --link .. .
# cmake and cpack
# Configure, validate, build and package
RUN <<_BUILD
#!/bin/bash
set -e
chmod +x ./scripts/linux_build.sh
./scripts/linux_build.sh \
--cuda-patches \
--step=cmake \
--publisher-name='LizardByte' \
--publisher-website='https://app.lizardbyte.dev' \
--publisher-issue-url='https://app.lizardbyte.dev/support' \
--sudo-off
apt-get clean
rm -rf /var/lib/apt/lists/*
./scripts/linux_build.sh \
--step=validation \
--sudo-off
./scripts/linux_build.sh \
--step=build \
--sudo-off
./scripts/linux_build.sh \
--step=package \
--sudo-off
_BUILD
# run tests