|
| 1 | +# syntax=docker/dockerfile:1 |
| 2 | +# artifacts: true |
| 3 | +# platforms: linux/amd64,linux/arm64/v8 |
| 4 | +# platforms_pr: linux/amd64 |
| 5 | +# no-cache-filters: sunshine-base,artifacts,sunshine |
| 6 | +ARG BASE=ubuntu |
| 7 | +ARG TAG=26.04 |
| 8 | +FROM ${BASE}:${TAG} AS sunshine-base |
| 9 | + |
| 10 | +ENV DEBIAN_FRONTEND=noninteractive |
| 11 | + |
| 12 | +FROM sunshine-base AS sunshine-deps |
| 13 | + |
| 14 | +SHELL ["/bin/bash", "-o", "pipefail", "-c"] |
| 15 | + |
| 16 | +# Copy only the build script first for better layer caching |
| 17 | +WORKDIR /build/sunshine/ |
| 18 | +COPY --link scripts/linux_build.sh ./scripts/linux_build.sh |
| 19 | + |
| 20 | +# Install dependencies first - this layer will be cached |
| 21 | +RUN <<_DEPS |
| 22 | +#!/bin/bash |
| 23 | +set -e |
| 24 | +chmod +x ./scripts/linux_build.sh |
| 25 | +./scripts/linux_build.sh \ |
| 26 | + --step=deps \ |
| 27 | + --sudo-off |
| 28 | +apt-get clean |
| 29 | +rm -rf /var/lib/apt/lists/* |
| 30 | +_DEPS |
| 31 | + |
| 32 | +FROM sunshine-deps AS sunshine-build |
| 33 | + |
| 34 | +ARG BRANCH |
| 35 | +ARG BUILD_VERSION |
| 36 | +ARG COMMIT |
| 37 | +# note: BUILD_VERSION may be blank |
| 38 | + |
| 39 | +ENV BRANCH=${BRANCH} |
| 40 | +ENV BUILD_VERSION=${BUILD_VERSION} |
| 41 | +ENV COMMIT=${COMMIT} |
| 42 | + |
| 43 | +# Now copy the full repository |
| 44 | +COPY --link .. . |
| 45 | + |
| 46 | +# Configure, validate, build and package |
| 47 | +RUN <<_BUILD |
| 48 | +#!/bin/bash |
| 49 | +set -e |
| 50 | +./scripts/linux_build.sh \ |
| 51 | + --step=cmake \ |
| 52 | + --publisher-name='LizardByte' \ |
| 53 | + --publisher-website='https://app.lizardbyte.dev' \ |
| 54 | + --publisher-issue-url='https://app.lizardbyte.dev/support' \ |
| 55 | + --sudo-off |
| 56 | + |
| 57 | +./scripts/linux_build.sh \ |
| 58 | + --step=validation \ |
| 59 | + --sudo-off |
| 60 | + |
| 61 | +./scripts/linux_build.sh \ |
| 62 | + --step=build \ |
| 63 | + --sudo-off |
| 64 | + |
| 65 | +./scripts/linux_build.sh \ |
| 66 | + --step=package \ |
| 67 | + --sudo-off |
| 68 | +_BUILD |
| 69 | + |
| 70 | +# run tests |
| 71 | +WORKDIR /build/sunshine/build/tests |
| 72 | +RUN <<_TEST |
| 73 | +#!/bin/bash |
| 74 | +set -e |
| 75 | +export DISPLAY=:1 |
| 76 | +Xvfb ${DISPLAY} -screen 0 1024x768x24 & |
| 77 | +./test_sunshine --gtest_color=yes |
| 78 | +_TEST |
| 79 | + |
| 80 | +FROM sunshine-base AS sunshine |
| 81 | + |
| 82 | +ARG BASE |
| 83 | +ARG TAG |
| 84 | +ARG TARGETARCH |
| 85 | + |
| 86 | +# artifacts to be extracted in CI |
| 87 | +COPY --link --from=sunshine-build /build/sunshine/build/cpack_artifacts/Sunshine.deb /artifacts/sunshine-${BASE}-${TAG}-${TARGETARCH}.deb |
| 88 | + |
| 89 | +# copy deb from builder |
| 90 | +COPY --link --from=sunshine-build /build/sunshine/build/cpack_artifacts/Sunshine.deb /sunshine.deb |
| 91 | + |
| 92 | +# install sunshine |
| 93 | +RUN <<_INSTALL_SUNSHINE |
| 94 | +#!/bin/bash |
| 95 | +set -e |
| 96 | +apt-get update -y |
| 97 | +apt-get install -y --no-install-recommends /sunshine.deb |
| 98 | +apt-get clean |
| 99 | +rm -rf /var/lib/apt/lists/* |
| 100 | +_INSTALL_SUNSHINE |
| 101 | + |
| 102 | +# network setup |
| 103 | +EXPOSE 47984-47990/tcp |
| 104 | +EXPOSE 48010 |
| 105 | +EXPOSE 47998-48000/udp |
| 106 | + |
| 107 | +# setup user |
| 108 | +ARG PGID=1001 |
| 109 | +ENV PGID=${PGID} |
| 110 | +ARG PUID=1001 |
| 111 | +ENV PUID=${PUID} |
| 112 | +ENV TZ="UTC" |
| 113 | +ARG UNAME=lizard |
| 114 | +ENV UNAME=${UNAME} |
| 115 | + |
| 116 | +ENV HOME=/home/$UNAME |
| 117 | + |
| 118 | +# setup user |
| 119 | +RUN <<_SETUP_USER |
| 120 | +#!/bin/bash |
| 121 | +set -e |
| 122 | +groupadd -f -g "${PGID}" "${UNAME}" |
| 123 | +useradd -lm -d ${HOME} -s /bin/bash -g "${PGID}" -u "${PUID}" "${UNAME}" |
| 124 | +mkdir -p ${HOME}/.config/sunshine |
| 125 | +ln -s ${HOME}/.config/sunshine /config |
| 126 | +chown -R ${UNAME} ${HOME} |
| 127 | +_SETUP_USER |
| 128 | + |
| 129 | +USER ${UNAME} |
| 130 | +WORKDIR ${HOME} |
| 131 | + |
| 132 | +# entrypoint |
| 133 | +ENTRYPOINT ["/usr/bin/sunshine"] |
0 commit comments