11# syntax=docker/dockerfile:1.4
22# artifacts: true
33# platforms: linux/amd64,linux/arm64/v8
4- # platforms_pr: linux/amd64
4+ # platforms_pr: linux/arm64/v8
5+ # todo: add linux/amd64 back to PR platforms
56# no-cache-filters: sunshine-base,artifacts,sunshine
67ARG BASE=fedora
78ARG TAG=39
8- FROM ${BASE}:${TAG} AS sunshine-base
9+ FROM --platform=$BUILDPLATFORM ${BASE}:${TAG} AS sunshine-base
910
1011FROM sunshine-base as sunshine-build
1112
13+ # reused args from base
14+ ARG TAG
15+ ENV TAG=${TAG}
16+
1217ARG TARGETPLATFORM
1318RUN echo "target_platform: ${TARGETPLATFORM}"
1419
20+ # args from ci workflow
1521ARG BRANCH
1622ARG BUILD_VERSION
1723ARG COMMIT
@@ -22,25 +28,75 @@ ENV BUILD_VERSION=${BUILD_VERSION}
2228ENV COMMIT=${COMMIT}
2329
2430SHELL ["/bin/bash" , "-o" , "pipefail" , "-c" ]
25- # install dependencies
31+ # setup env
32+ WORKDIR /env
33+ RUN <<_ENV
34+ # !/bin/bash
35+ set -e
36+ case "${TARGETPLATFORM}" in
37+ linux/amd64)
38+ echo TARGETARCH=x86_64 >> ./env
39+ echo TUPLE=x86_64-linux-gnu >> ./env
40+ ;;
41+ linux/arm64)
42+ echo TARGETARCH=aarch64 >> ./env
43+ echo TUPLE=aarch64-linux-gnu >> ./env
44+ ;;
45+ *)
46+ echo "unsupported platform: ${TARGETPLATFORM}" ;
47+ exit 1
48+ ;;
49+ esac
50+ _ENV
51+
52+ # reset workdir
53+ WORKDIR /
54+
55+ # install build dependencies
2656# hadolint ignore=DL3041
27- RUN <<_DEPS
57+ # shellcheck source=/dev/null
58+ RUN <<_DEPS_A
2859# !/bin/bash
2960set -e
61+ source /env/env
62+
3063dnf -y update
31- dnf -y group install "Development Tools"
3264dnf -y install \
33- boost-devel-1.81.0* \
3465 cmake-3.27.* \
35- gcc-13.2.* \
36- gcc-c++-13.2.* \
37- git \
66+ gcc-"${TARGETARCH}" -linux-gnu-13.2.* \
67+ gcc-c++-"${TARGETARCH}" -linux-gnu-13.2.* \
68+ git-core \
69+ nodejs \
70+ pkgconf-pkg-config \
71+ rpm-build \
72+ wayland-devel \
73+ wget \
74+ which
75+ dnf clean all
76+ _DEPS_A
77+
78+ # install host dependencies
79+ # hadolint ignore=DL3041
80+ # shellcheck source=/dev/null
81+ RUN <<_DEPS_B
82+ # !/bin/bash
83+ set -e
84+ source /env/env
85+
86+ DNF=( dnf -y --installroot /mnt/cross --releasever "${TAG}" --forcearch "${TARGETARCH}" )
87+ "${DNF[@]}" install \
88+ filesystem
89+ "${DNF[@]}" --setopt=tsflags=noscripts install \
90+ $([[ "${TARGETARCH}" == x86_64 ]] && echo intel-mediasdk-devel) \
91+ boost-devel-1.81.0* \
92+ glibc-devel \
3893 libappindicator-gtk3-devel \
3994 libcap-devel \
4095 libcurl-devel \
4196 libdrm-devel \
4297 libevdev-devel \
4398 libnotify-devel \
99+ libstdc++-devel \
44100 libva-devel \
45101 libvdpau-devel \
46102 libX11-devel \
@@ -53,20 +109,13 @@ dnf -y install \
53109 libXtst-devel \
54110 mesa-libGL-devel \
55111 miniupnpc-devel \
56- nodejs \
57112 numactl-devel \
58113 openssl-devel \
59114 opus-devel \
60115 pulseaudio-libs-devel \
61- rpm-build \
62- wget \
63- which
64- if [[ "${TARGETPLATFORM}" == 'linux/amd64' ]]; then
65- dnf -y install intel-mediasdk-devel
66- fi
67- dnf clean all
68- rm -rf /var/cache/yum
69- _DEPS
116+ wayland-devel
117+ "${DNF[@]}" clean all
118+ _DEPS_B
70119
71120# todo - enable cuda once it's supported for gcc 13 and fedora 39
72121# # install cuda
@@ -101,12 +150,25 @@ WORKDIR /build/sunshine/build
101150# cmake and cpack
102151# todo - add cmake argument back in for cuda support "-DCMAKE_CUDA_COMPILER:PATH=/build/cuda/bin/nvcc \"
103152# todo - re-enable "DSUNSHINE_ENABLE_CUDA"
153+ # shellcheck source=/dev/null
104154RUN <<_MAKE
105155# !/bin/bash
106156set -e
157+ source /env/env
158+
159+ export \
160+ CXXFLAGS="-isystem $(echo /mnt/cross/usr/include/c++/[0-9]*/) -isystem $(echo /mnt/cross/usr/include/c++/[0-9]*/${TUPLE%%-*}-*/)" \
161+ LDFLAGS="-L$(echo /mnt/cross/usr/lib/gcc/${TUPLE%%-*}-*/[0-9]*/)" \
162+ PKG_CONFIG_LIBDIR=/mnt/cross/usr/lib64/pkgconfig:/mnt/cross/usr/share/pkgconfig \
163+ PKG_CONFIG_SYSROOT_DIR=/mnt/cross \
164+ PKG_CONFIG_SYSTEM_INCLUDE_PATH=/mnt/cross/usr/include \
165+ PKG_CONFIG_SYSTEM_LIBRARY_PATH=/mnt/cross/usr/lib64
166+
107167cmake \
168+ -DCMAKE_TOOLCHAIN_FILE=toolchain-${TARGETARCH}-linux-gnu.cmake \
108169 -DCMAKE_BUILD_TYPE=Release \
109170 -DCMAKE_INSTALL_PREFIX=/usr \
171+ -DCPACK_RPM_PACKAGE_ARCHITECTURE="${TARGETARCH}" \
110172 -DSUNSHINE_ASSETS_DIR=share/sunshine \
111173 -DSUNSHINE_EXECUTABLE_PATH=/usr/bin/sunshine \
112174 -DSUNSHINE_ENABLE_WAYLAND=ON \
@@ -124,7 +186,7 @@ ARG TAG
124186ARG TARGETARCH
125187COPY --link --from=sunshine-build /build/sunshine/build/cpack_artifacts/Sunshine.rpm /sunshine-${BASE}-${TAG}-${TARGETARCH}.rpm
126188
127- FROM sunshine-base as sunshine
189+ FROM ${BASE}:${TAG} AS sunshine
128190
129191# copy deb from builder
130192COPY --link --from=artifacts /sunshine*.rpm /sunshine.rpm
0 commit comments