build(Linux): Refactor Dockerfiles and build script for multi-stage, step-based builds (#4299)
This commit is contained in:
parent
2a3a4094ac
commit
9c1b8db5cd
5 changed files with 376 additions and 158 deletions
|
|
@ -17,26 +17,11 @@ pacman -Syu --disable-download-timeout --noconfirm
|
|||
pacman -Scc --noconfirm
|
||||
_DEPS
|
||||
|
||||
FROM sunshine-base AS sunshine-build
|
||||
|
||||
ARG BRANCH
|
||||
ARG BUILD_VERSION
|
||||
ARG COMMIT
|
||||
ARG CLONE_URL
|
||||
# note: BUILD_VERSION may be blank
|
||||
|
||||
ENV BRANCH=${BRANCH}
|
||||
ENV BUILD_VERSION=${BUILD_VERSION}
|
||||
ENV COMMIT=${COMMIT}
|
||||
ENV CLONE_URL=${CLONE_URL}
|
||||
|
||||
# PKGBUILD options
|
||||
ENV _use_cuda=true
|
||||
ENV _run_unit_tests=true
|
||||
ENV _support_headless_testing=true
|
||||
FROM sunshine-base AS sunshine-deps
|
||||
|
||||
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
|
||||
|
||||
# Install dependencies first - this layer will be cached
|
||||
RUN <<_SETUP
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
|
@ -60,6 +45,26 @@ pacman -Syu --disable-download-timeout --needed --noconfirm \
|
|||
pacman -Scc --noconfirm
|
||||
_SETUP
|
||||
|
||||
FROM sunshine-deps AS sunshine-build
|
||||
|
||||
ARG BRANCH
|
||||
ARG BUILD_VERSION
|
||||
ARG COMMIT
|
||||
ARG CLONE_URL
|
||||
# note: BUILD_VERSION may be blank
|
||||
|
||||
ENV BRANCH=${BRANCH}
|
||||
ENV BUILD_VERSION=${BUILD_VERSION}
|
||||
ENV COMMIT=${COMMIT}
|
||||
ENV CLONE_URL=${CLONE_URL}
|
||||
|
||||
# PKGBUILD options
|
||||
ENV _use_cuda=true
|
||||
ENV _run_unit_tests=true
|
||||
ENV _support_headless_testing=true
|
||||
|
||||
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
|
||||
|
||||
# Setup builder user
|
||||
USER builder
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -9,7 +9,28 @@ 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 first for better layer caching
|
||||
WORKDIR /build/sunshine/
|
||||
COPY --link scripts/linux_build.sh ./scripts/linux_build.sh
|
||||
|
||||
# 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 \
|
||||
--ubuntu-test-repo \
|
||||
--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 +41,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 \
|
||||
--step=cmake \
|
||||
--publisher-name='LizardByte' \
|
||||
--publisher-website='https://app.lizardbyte.dev' \
|
||||
--publisher-issue-url='https://app.lizardbyte.dev/support' \
|
||||
--sudo-off \
|
||||
--ubuntu-test-repo
|
||||
apt-get clean
|
||||
rm -rf /var/lib/apt/lists/*
|
||||
--sudo-off
|
||||
|
||||
./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
|
||||
|
|
|
|||
|
|
@ -9,7 +9,27 @@ 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 first for better layer caching
|
||||
WORKDIR /build/sunshine/
|
||||
COPY --link scripts/linux_build.sh ./scripts/linux_build.sh
|
||||
|
||||
# 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 \
|
||||
--sudo-off
|
||||
apt-get clean
|
||||
rm -rf /var/lib/apt/lists/*
|
||||
_DEPS
|
||||
|
||||
FROM sunshine-deps AS sunshine-build
|
||||
|
||||
ARG BRANCH
|
||||
ARG BUILD_VERSION
|
||||
|
|
@ -20,24 +40,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 \
|
||||
--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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue