2023-02-13 20:27:51 +00:00
|
|
|
# syntax=docker/dockerfile:1.4
|
|
|
|
# artifacts: true
|
|
|
|
# platforms: linux/amd64
|
|
|
|
# archlinux does not have an arm64 base image
|
2023-08-18 01:49:59 +00:00
|
|
|
# no-cache-filters: artifacts,sunshine
|
2023-02-13 20:27:51 +00:00
|
|
|
ARG BASE=archlinux
|
|
|
|
ARG TAG=base-devel
|
|
|
|
FROM ${BASE}:${TAG} AS sunshine-base
|
|
|
|
|
|
|
|
# install dependencies
|
|
|
|
RUN <<_DEPS
|
|
|
|
#!/bin/bash
|
|
|
|
set -e
|
2023-08-26 01:19:44 +00:00
|
|
|
pacman -Syu --disable-download-timeout --needed --noconfirm \
|
2023-02-20 20:03:03 +00:00
|
|
|
archlinux-keyring
|
2023-02-13 20:27:51 +00:00
|
|
|
_DEPS
|
|
|
|
|
|
|
|
# Setup builder user, arch prevents running makepkg as root
|
|
|
|
RUN useradd -m builder && \
|
|
|
|
echo 'builder ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers
|
2023-02-20 20:03:03 +00:00
|
|
|
# makepkg is used in sunshine-build and uploader build stages
|
2023-02-13 20:27:51 +00:00
|
|
|
|
|
|
|
FROM sunshine-base as sunshine-build
|
|
|
|
|
2023-03-09 23:13:57 +00:00
|
|
|
ARG BRANCH
|
2023-02-13 20:27:51 +00:00
|
|
|
ARG BUILD_VERSION
|
|
|
|
ARG COMMIT
|
|
|
|
ARG CLONE_URL
|
|
|
|
# note: BUILD_VERSION may be blank
|
|
|
|
|
2023-03-09 23:13:57 +00:00
|
|
|
ENV BRANCH=${BRANCH}
|
|
|
|
ENV BUILD_VERSION=${BUILD_VERSION}
|
|
|
|
ENV COMMIT=${COMMIT}
|
|
|
|
|
2023-02-13 20:27:51 +00:00
|
|
|
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
|
|
|
|
# install dependencies
|
2024-03-09 17:18:39 +00:00
|
|
|
# cuda is an optional build-time dependency for PKGBUILD
|
2023-02-13 20:27:51 +00:00
|
|
|
RUN <<_DEPS
|
|
|
|
#!/bin/bash
|
|
|
|
set -e
|
2023-08-18 01:49:59 +00:00
|
|
|
pacman -Syu --disable-download-timeout --needed --noconfirm \
|
2023-02-13 20:27:51 +00:00
|
|
|
base-devel \
|
|
|
|
cmake \
|
2023-02-20 20:03:03 +00:00
|
|
|
cuda \
|
2023-03-09 23:13:57 +00:00
|
|
|
git \
|
2024-03-24 23:52:24 +00:00
|
|
|
namcap \
|
|
|
|
xorg-server-xvfb
|
2023-02-13 20:27:51 +00:00
|
|
|
_DEPS
|
|
|
|
|
|
|
|
# Setup builder user
|
|
|
|
USER builder
|
|
|
|
|
|
|
|
# copy repository
|
|
|
|
WORKDIR /build/sunshine/
|
2023-02-20 20:03:03 +00:00
|
|
|
COPY --link .. .
|
2023-02-13 20:27:51 +00:00
|
|
|
|
|
|
|
# setup build directory
|
|
|
|
WORKDIR /build/sunshine/build
|
|
|
|
|
|
|
|
# configure PKGBUILD file
|
|
|
|
RUN <<_MAKE
|
|
|
|
#!/bin/bash
|
|
|
|
set -e
|
|
|
|
if [[ "${BUILD_VERSION}" == '' ]]; then
|
|
|
|
sub_version=".r${COMMIT}"
|
|
|
|
else
|
|
|
|
sub_version=""
|
|
|
|
fi
|
|
|
|
cmake \
|
2023-09-05 00:16:30 +00:00
|
|
|
-DSUNSHINE_CONFIGURE_PKGBUILD=ON \
|
2023-02-13 20:27:51 +00:00
|
|
|
-DSUNSHINE_SUB_VERSION="${sub_version}" \
|
|
|
|
-DGITHUB_CLONE_URL="${CLONE_URL}" \
|
2023-09-12 18:07:47 +00:00
|
|
|
-DGITHUB_BRANCH=${BRANCH} \
|
|
|
|
-DGITHUB_BUILD_VERSION=${BUILD_VERSION} \
|
2023-02-13 20:27:51 +00:00
|
|
|
-DGITHUB_COMMIT="${COMMIT}" \
|
|
|
|
-DSUNSHINE_CONFIGURE_ONLY=ON \
|
|
|
|
/build/sunshine
|
|
|
|
_MAKE
|
|
|
|
|
|
|
|
WORKDIR /build/sunshine/pkg
|
|
|
|
RUN mv /build/sunshine/build/PKGBUILD .
|
2024-03-09 17:55:22 +00:00
|
|
|
RUN mv /build/sunshine/build/sunshine.install .
|
2023-02-13 20:27:51 +00:00
|
|
|
|
|
|
|
# namcap and build PKGBUILD file
|
|
|
|
RUN <<_PKGBUILD
|
|
|
|
#!/bin/bash
|
|
|
|
set -e
|
2024-03-24 23:52:24 +00:00
|
|
|
export DISPLAY=:1
|
|
|
|
Xvfb ${DISPLAY} -screen 0 1024x768x24 &
|
2023-02-13 20:27:51 +00:00
|
|
|
namcap -i PKGBUILD
|
|
|
|
makepkg -si --noconfirm
|
2024-03-05 03:15:37 +00:00
|
|
|
rm -f /build/sunshine/pkg/sunshine-debug*.pkg.tar.zst
|
2023-02-13 20:27:51 +00:00
|
|
|
ls -a
|
|
|
|
_PKGBUILD
|
|
|
|
|
|
|
|
FROM scratch as artifacts
|
|
|
|
|
2023-02-20 20:03:03 +00:00
|
|
|
COPY --link --from=sunshine-build /build/sunshine/pkg/sunshine*.pkg.tar.zst /sunshine.pkg.tar.zst
|
2023-02-13 20:27:51 +00:00
|
|
|
|
|
|
|
FROM sunshine-base as sunshine
|
|
|
|
|
2023-02-20 20:03:03 +00:00
|
|
|
# copy from uploader instead of artifacts or uploader stage will not run
|
|
|
|
COPY --link --from=artifacts /sunshine.pkg.tar.zst /
|
2023-02-13 20:27:51 +00:00
|
|
|
|
|
|
|
# install sunshine
|
|
|
|
RUN <<_INSTALL_SUNSHINE
|
|
|
|
#!/bin/bash
|
|
|
|
set -e
|
2023-08-26 01:19:44 +00:00
|
|
|
# update keyring to prevent cached keyring errors
|
|
|
|
pacman -Syu --disable-download-timeout --needed --noconfirm \
|
|
|
|
archlinux-keyring
|
2023-08-18 01:49:59 +00:00
|
|
|
pacman -U --disable-download-timeout --needed --noconfirm \
|
2023-02-13 20:27:51 +00:00
|
|
|
/sunshine.pkg.tar.zst
|
|
|
|
_INSTALL_SUNSHINE
|
|
|
|
|
|
|
|
# network setup
|
|
|
|
EXPOSE 47984-47990/tcp
|
|
|
|
EXPOSE 48010
|
|
|
|
EXPOSE 47998-48000/udp
|
|
|
|
|
|
|
|
# setup user
|
|
|
|
ARG PGID=1000
|
|
|
|
ENV PGID=${PGID}
|
|
|
|
ARG PUID=1000
|
|
|
|
ENV PUID=${PUID}
|
|
|
|
ENV TZ="UTC"
|
|
|
|
ARG UNAME=lizard
|
|
|
|
ENV UNAME=${UNAME}
|
|
|
|
|
|
|
|
ENV HOME=/home/$UNAME
|
|
|
|
|
|
|
|
# setup user
|
|
|
|
RUN <<_SETUP_USER
|
|
|
|
#!/bin/bash
|
|
|
|
set -e
|
2023-02-20 20:03:03 +00:00
|
|
|
# first delete the builder user
|
2023-02-13 20:27:51 +00:00
|
|
|
userdel -r builder
|
|
|
|
|
|
|
|
# then create the lizard user
|
|
|
|
groupadd -f -g "${PGID}" "${UNAME}"
|
2023-04-07 22:14:50 +00:00
|
|
|
useradd -lm -d ${HOME} -s /bin/bash -g "${PGID}" -u "${PUID}" "${UNAME}"
|
2023-02-13 20:27:51 +00:00
|
|
|
mkdir -p ${HOME}/.config/sunshine
|
|
|
|
ln -s ${HOME}/.config/sunshine /config
|
|
|
|
chown -R ${UNAME} ${HOME}
|
|
|
|
_SETUP_USER
|
|
|
|
|
|
|
|
USER ${UNAME}
|
|
|
|
WORKDIR ${HOME}
|
|
|
|
|
|
|
|
# entrypoint
|
|
|
|
ENTRYPOINT ["/usr/bin/sunshine"]
|