diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 00000000000..fad61318b5b --- /dev/null +++ b/.dockerignore @@ -0,0 +1,11 @@ +# Remove all, we'll include only the necessary folders via ! +* + +!sunshine +!cmake +!assets +!scripts +!third-party +!CMakeLists.txt +!*.in +!LICENSE \ No newline at end of file diff --git a/scripts/Dockerfile-debian b/Dockerfile similarity index 51% rename from scripts/Dockerfile-debian rename to Dockerfile index fc77eb8e989..18180d11ecb 100644 --- a/scripts/Dockerfile-debian +++ b/Dockerfile @@ -1,6 +1,4 @@ -FROM debian:bullseye AS sunshine-debian - -# Debian Bullseye end of life is TBD +FROM debian:bullseye AS sunshine-build ARG DEBIAN_FRONTEND=noninteractive ARG TZ="Europe/London" @@ -11,7 +9,7 @@ RUN apt-get update -y && \ apt-get install -y \ build-essential \ cmake \ - git \ + rpm \ libavdevice-dev \ libboost-filesystem-dev \ libboost-log-dev \ @@ -31,10 +29,29 @@ RUN apt-get update -y && \ libxrandr-dev \ libxtst-dev \ nvidia-cuda-dev \ - nvidia-cuda-toolkit \ - && apt-get clean \ + nvidia-cuda-toolkit + +ADD . /root/sunshine/ +RUN /root/sunshine/scripts/build-sunshine.sh + +WORKDIR /root/sunshine-build +RUN cpack -G RPM +RUN cpack -G DEB + +################################################# +FROM debian:bullseye-slim AS sunshine + +COPY --from=sunshine-build /root/sunshine-build/Sunshine.deb /Sunshine.deb +COPY --from=sunshine-build /root/sunshine-build/Sunshine.rpm /Sunshine.rpm + +RUN apt-get update -y && \ + apt-get install -y -f /Sunshine.deb \ && rm -rf /var/lib/apt/lists/* -# Entrypoint -COPY build-private.sh /root/build.sh -ENTRYPOINT ["/root/build.sh", "-deb"] +# Port configuration taken from https://github.com/moonlight-stream/moonlight-docs/wiki/Setup-Guide#manual-port-forwarding-advanced +EXPOSE 47984-47990/tcp +EXPOSE 48010 +EXPOSE 48010/udp +EXPOSE 47998-48000/udp + +ENTRYPOINT ["/usr/bin/sunshine"] diff --git a/scripts/Dockerfile-fedora_33 b/scripts/Dockerfile-fedora_33 deleted file mode 100644 index 136058c3ec7..00000000000 --- a/scripts/Dockerfile-fedora_33 +++ /dev/null @@ -1,30 +0,0 @@ -FROM fedora:33 AS sunshine-fedora_33 - -# Fedora 33 end of life is November 2021 -# This file remains for reference only - -SHELL ["/bin/bash", "-o", "pipefail", "-c"] -RUN dnf -y update && \ - dnf -y group install "Development Tools" && \ - dnf -y install https://mirrors.rpmfusion.org/free/fedora/rpmfusion-free-release-$(rpm -E %fedora).noarch.rpm https://mirrors.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-$(rpm -E %fedora).noarch.rpm && \ - dnf -y install \ - boost-devel \ - boost-static.x86_64 \ - cmake \ - ffmpeg-devel \ - libevdev-devel \ - libxcb-devel \ - libX11-devel \ - libXfixes-devel \ - libXrandr-devel \ - libXtst-devel \ - openssl-devel \ - opus-devel \ - pulseaudio-libs-devel \ - rpm-build \ - && dnf clean all \ - && rm -rf /var/cache/yum - -# Entrypoint -COPY build-private.sh /root/build.sh -ENTRYPOINT ["/root/build.sh", "-rpm"] diff --git a/scripts/Dockerfile-fedora_35 b/scripts/Dockerfile-fedora_35 deleted file mode 100644 index 18b04377c14..00000000000 --- a/scripts/Dockerfile-fedora_35 +++ /dev/null @@ -1,34 +0,0 @@ -FROM fedora:35 AS sunshine-fedora_35 - -# Fedora 35 end of life is TBD - -SHELL ["/bin/bash", "-o", "pipefail", "-c"] -RUN dnf -y update && \ - dnf -y group install "Development Tools" && \ - dnf -y install https://mirrors.rpmfusion.org/free/fedora/rpmfusion-free-release-$(rpm -E %fedora).noarch.rpm https://mirrors.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-$(rpm -E %fedora).noarch.rpm && \ - dnf -y install \ - boost-devel \ - boost-static.x86_64 \ - cmake \ - ffmpeg-devel \ - gcc-c++ \ - libevdev-devel \ - libX11-devel \ - libxcb-devel \ - libXcursor-devel \ - libXfixes-devel \ - libXinerama-devel \ - libXi-devel \ - libXrandr-devel \ - libXtst-devel \ - mesa-libGL-devel \ - openssl-devel \ - opus-devel \ - pulseaudio-libs-devel \ - rpm-build \ - && dnf clean all \ - && rm -rf /var/cache/yum - -# Entrypoint -COPY build-private.sh /root/build.sh -ENTRYPOINT ["/root/build.sh", "-rpm"] diff --git a/scripts/Dockerfile-ubuntu_18_04 b/scripts/Dockerfile-ubuntu_18_04 deleted file mode 100644 index 6ad3e8c02ad..00000000000 --- a/scripts/Dockerfile-ubuntu_18_04 +++ /dev/null @@ -1,63 +0,0 @@ -FROM ubuntu:18.04 AS sunshine-ubuntu_18_04 - -# Ubuntu 18.04 end of life is April 2028 - -ARG DEBIAN_FRONTEND=noninteractive -ARG TZ="Europe/London" - -SHELL ["/bin/bash", "-o", "pipefail", "-c"] -RUN apt-get update -y && \ - apt-get install -y \ - software-properties-common \ - && add-apt-repository ppa:savoury1/graphics && \ - add-apt-repository ppa:savoury1/multimedia && \ - add-apt-repository ppa:savoury1/ffmpeg4 && \ - add-apt-repository ppa:savoury1/boost-defaults-1.71 && \ - add-apt-repository ppa:ubuntu-toolchain-r/test && \ - apt-get update -y && \ - apt-get install -y \ - build-essential \ - cmake \ - gcc-10 \ - git \ - g++-10 \ - libavdevice-dev \ - libboost-filesystem1.71-dev \ - libboost-log1.71-dev \ - libboost-regex1.71-dev \ - libboost-thread1.71-dev \ - libcap-dev \ - libdrm-dev \ - libevdev-dev \ - libpulse-dev \ - libopus-dev \ - libssl-dev \ - libwayland-dev \ - libx11-dev \ - libxcb-shm0-dev \ - libxcb-xfixes0-dev \ - libxcb1-dev \ - libxfixes-dev \ - libxrandr-dev \ - libxtst-dev \ - wget \ - && apt-get clean \ - && rm -rf /var/lib/apt/lists/* - -# Update gcc alias -RUN update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-10 100 --slave /usr/bin/g++ g++ /usr/bin/g++-10 - -# Install CuDA -RUN wget https://developer.download.nvidia.com/compute/cuda/11.4.2/local_installers/cuda_11.4.2_470.57.02_linux.run --progress=bar:force:noscroll -q --show-progress -O /root/cuda.run && chmod a+x /root/cuda.run -RUN /root/cuda.run --silent --toolkit --toolkitpath=/usr --no-opengl-libs --no-man-page --no-drm && rm /root/cuda.run - -# Install cmake -ADD https://cmake.org/files/v3.22/cmake-3.22.2-linux-x86_64.sh /cmake-3.22.2-linux-x86_64.sh -RUN mkdir /opt/cmake -RUN sh /cmake-3.22.2-linux-x86_64.sh --prefix=/opt/cmake --skip-license -RUN ln -s /opt/cmake/bin/cmake /usr/local/bin/cmake -RUN cmake --version - -# Entrypoint -COPY build-private.sh /root/build.sh -ENTRYPOINT ["/root/build.sh", "-deb"] diff --git a/scripts/Dockerfile-ubuntu_20_04 b/scripts/Dockerfile-ubuntu_20_04 deleted file mode 100644 index 44e897a7586..00000000000 --- a/scripts/Dockerfile-ubuntu_20_04 +++ /dev/null @@ -1,46 +0,0 @@ -FROM ubuntu:20.04 AS sunshine-ubuntu_20_04 - -# Ubuntu 20.04 end of life is April 2030 - -ARG DEBIAN_FRONTEND=noninteractive -ARG TZ="Europe/London" - -SHELL ["/bin/bash", "-o", "pipefail", "-c"] -RUN apt-get update -y && \ - apt-get install -y \ - build-essential \ - cmake \ - git \ - g++-10 \ - libavdevice-dev \ - libboost-filesystem-dev \ - libboost-log-dev \ - libboost-thread-dev \ - libcap-dev \ - libdrm-dev \ - libevdev-dev \ - libpulse-dev \ - libopus-dev \ - libssl-dev \ - libwayland-dev \ - libx11-dev \ - libxcb-shm0-dev \ - libxcb-xfixes0-dev \ - libxcb1-dev \ - libxfixes-dev \ - libxrandr-dev \ - libxtst-dev \ - wget \ - && apt-get clean \ - && rm -rf /var/lib/apt/lists/* - -# Update gcc alias -RUN update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-10 100 --slave /usr/bin/g++ g++ /usr/bin/g++-10 - -# Install CuDA -RUN wget https://developer.download.nvidia.com/compute/cuda/11.4.2/local_installers/cuda_11.4.2_470.57.02_linux.run --progress=bar:force:noscroll -q --show-progress -O /root/cuda.run && chmod a+x /root/cuda.run -RUN /root/cuda.run --silent --toolkit --toolkitpath=/usr --no-opengl-libs --no-man-page --no-drm && rm /root/cuda.run - -# Entrypoint -COPY build-private.sh /root/build.sh -ENTRYPOINT ["/root/build.sh", "-deb"] diff --git a/scripts/Dockerfile-ubuntu_21_04 b/scripts/Dockerfile-ubuntu_21_04 deleted file mode 100644 index 012845a5b69..00000000000 --- a/scripts/Dockerfile-ubuntu_21_04 +++ /dev/null @@ -1,40 +0,0 @@ -FROM ubuntu:21.04 AS sunshine-ubuntu_21_04 - -# Ubuntu 21.04 end of life is January 2022 -# This file remains for reference only - -ARG DEBIAN_FRONTEND=noninteractive -ARG TZ="Europe/London" - -SHELL ["/bin/bash", "-o", "pipefail", "-c"] -RUN apt-get update -y && \ - apt-get install -y \ - build-essential \ - cmake \ - git \ - libavdevice-dev \ - libboost-thread-dev \ - libboost-filesystem-dev \ - libboost-log-dev \ - libcap-dev \ - libdrm-dev \ - libevdev-dev \ - libpulse-dev \ - libopus-dev \ - libssl-dev \ - libwayland-dev \ - libx11-dev \ - libxcb-shm0-dev \ - libxcb-xfixes0-dev \ - libxcb1-dev \ - libxfixes-dev \ - libxrandr-dev \ - libxtst-dev \ - nvidia-cuda-dev \ - nvidia-cuda-toolkit \ - && apt-get clean \ - && rm -rf /var/lib/apt/lists/* - -# Entrypoint -COPY build-private.sh /root/build.sh -ENTRYPOINT ["/root/build.sh", "-deb"] diff --git a/scripts/Dockerfile-ubuntu_21_10 b/scripts/Dockerfile-ubuntu_21_10 deleted file mode 100644 index 6be49dbe0cb..00000000000 --- a/scripts/Dockerfile-ubuntu_21_10 +++ /dev/null @@ -1,39 +0,0 @@ -FROM ubuntu:21.10 AS sunshine-ubuntu_21_10 - -# Ubuntu 21.10 end of life is July 2022 - -ARG DEBIAN_FRONTEND=noninteractive -ARG TZ="Europe/London" - -SHELL ["/bin/bash", "-o", "pipefail", "-c"] -RUN apt-get update -y && \ - apt-get install -y \ - build-essential \ - cmake \ - git \ - libavdevice-dev \ - libboost-filesystem-dev \ - libboost-log-dev \ - libboost-thread-dev \ - libcap-dev \ - libdrm-dev \ - libevdev-dev \ - libpulse-dev \ - libopus-dev \ - libssl-dev \ - libwayland-dev \ - libx11-dev \ - libxcb-shm0-dev \ - libxcb-xfixes0-dev \ - libxcb1-dev \ - libxfixes-dev \ - libxrandr-dev \ - libxtst-dev \ - nvidia-cuda-dev \ - nvidia-cuda-toolkit \ - && apt-get clean \ - && rm -rf /var/lib/apt/lists/* - -# Entrypoint -COPY build-private.sh /root/build.sh -ENTRYPOINT ["/root/build.sh", "-deb"] diff --git a/scripts/build-container.sh b/scripts/build-container.sh deleted file mode 100755 index 5da4784aef2..00000000000 --- a/scripts/build-container.sh +++ /dev/null @@ -1,179 +0,0 @@ -#!/bin/bash -e -set -e - -usage() { - echo "Usage: $0 [OPTIONS]" - echo " -c: command --> default [build]" - echo " | delete --> Delete the container, Dockerfile isn't mandatory" - echo " | build --> Build the container, Dockerfile is mandatory" - echo " | compile --> Builds the container, then compiles it. Dockerfile is mandatory" - echo "" - echo " -s: path: The path to the source for compilation" - echo " -n: name: Docker container name --> default [sunshine]" - echo " --> all: Build/Compile/Delete all available docker containers" - echo " -f: Dockerfile: The name of the docker file" -} - -# Attempt to turn relative paths into absolute paths -absolute_path() { - RELATIVE_PATH=$1 - if which realpath >/dev/null 2>/dev/null - then - RELATIVE_PATH=$(realpath $RELATIVE_PATH) - else - echo "Warning: realpath is not installed on your system, ensure [$1] is absolute" - fi - - RETURN=$RELATIVE_PATH -} - -CONTAINER_NAME=sunshine -COMMAND=BUILD - -build_container() { - CONTAINER_NAME=$1 - DOCKER_FILE=$2 - - if [ ! -f "$DOCKER_FILE" ] - then - echo "Error: $DOCKER_FILE doesn't exist" - exit 7 - fi - - echo "docker build . -t $CONTAINER_NAME -f $DOCKER_FILE" - docker build . -t "$CONTAINER_NAME" -f "$DOCKER_FILE" -} - -delete() { - CONTAINER_NAME_UPPER=$(echo "$CONTAINER_NAME" | tr '[:lower:]' '[:upper:]') - if [ "$CONTAINER_NAME_UPPER" = "ALL" ] - then - shopt -s nullglob - for file in $(find . -maxdepth 1 -iname "Dockerfile-*" -type f) - do - CURRENT_CONTAINER="sunshine-$(echo $file | cut -c 14-)" - - if docker inspect "$CURRENT_CONTAINER" > /dev/null 2> /dev/null - then - echo "docker rmi $CURRENT_CONTAINER" - docker rmi "$CURRENT_CONTAINER" - fi - done - shopt -u nullglob #revert nullglob back to it's normal default state - else - if docker inspect "$CONTAINER_NAME" > /dev/null 2> /dev/null - then - echo "docker rmi $CONTAINER_NAME" - docker rmi $CONTAINER_NAME - fi - fi -} - -build() { - CONTAINER_NAME_UPPER=$(echo "$CONTAINER_NAME" | tr '[:lower:]' '[:upper:]') - if [ "$CONTAINER_NAME_UPPER" = "ALL" ] - then - shopt -s nullglob - for file in $(find . -maxdepth 1 -iname "Dockerfile-*" -type f) - do - CURRENT_CONTAINER="sunshine-$(echo $file | cut -c 14-)" - build_container "$CURRENT_CONTAINER" "$file" - done - shopt -u nullglob #revert nullglob back to it's normal default state - else - if [[ -z "$DOCKER_FILE" ]] - then - echo "Error: if container name isn't equal to 'all', you need to specify the Dockerfile" - exit 6 - fi - - build_container "$CONTAINER_NAME" "$DOCKER_FILE" - fi -} - -abort() { - echo "$1" - exit 10 -} - -compile() { - CONTAINER_NAME_UPPER=$(echo "$CONTAINER_NAME" | tr '[:lower:]' '[:upper:]') - if [ "$CONTAINER_NAME_UPPER" = "ALL" ] - then - shopt -s nullglob - - # If any docker container doesn't exist, we cannot compile all of them - for file in $(find . -maxdepth 1 -iname "Dockerfile-*" -type f) - do - CURRENT_CONTAINER="sunshine-$(echo $file | cut -c 14-)" - - # If container doesn't exist --> abort. - docker inspect "$CURRENT_CONTAINER" > /dev/null 2> /dev/null || abort "Error: container image [$CURRENT_CONTAINER] doesn't exist" - done - - for file in $(find . -maxdepth 1 -iname "Dockerfile-*" -type f) - do - CURRENT_CONTAINER="sunshine-$(echo $file | cut -c 14-)" - - echo "$PWD/build-sunshine.sh -p -n $CURRENT_CONTAINER $SUNSHINE_SOURCES" - "$PWD/build-sunshine.sh" -p -n "$CURRENT_CONTAINER" $SUNSHINE_SOURCES - done - shopt -u nullglob #revert nullglob back to it's normal default state - else - # If container exists - if docker inspect "$CONTAINER_NAME" > /dev/null 2> /dev/null - then - echo "$PWD/build-sunshine.sh -p -n $CONTAINER_NAME $SUNSHINE_SOURCES" - "$PWD/build-sunshine.sh" -p -n "$CONTAINER_NAME" $SUNSHINE_SOURCES - else - echo "Error: container image [$CONTAINER_NAME] doesn't exist" - exit 9 - fi - fi -} - -while getopts ":c:hn:f:s:" arg; do - case ${arg} in - s) - SUNSHINE_SOURCES="-s $OPTARG" - ;; - c) - COMMAND=$(echo $OPTARG | tr '[:lower:]' '[:upper:]') - ;; - n) - echo "Container name: $OPTARG" - CONTAINER_NAME="$OPTARG" - ;; - f) - echo "Using Dockerfile [$OPTARG]" - DOCKER_FILE="$OPTARG" - ;; - h) - usage - exit 0 - ;; - esac -done - -echo "$0 set to $(echo $COMMAND | tr '[:upper:]' '[:lower:]')" - -if [ "$COMMAND" = "BUILD" ] -then - echo "Start building..." - delete - build - echo "Done." -elif [ "$COMMAND" = "COMPILE" ] -then - echo "Start compiling..." - compile - echo "Done." -elif [ "$COMMAND" = "DELETE" ] -then - echo "Start deleting..." - delete - echo "Done." -else - echo "Unknown command [$(echo $COMMAND | tr '[:upper:]' '[:lower:]')]" - exit 4 -fi diff --git a/scripts/build-private.sh b/scripts/build-private.sh deleted file mode 100755 index 93d18748899..00000000000 --- a/scripts/build-private.sh +++ /dev/null @@ -1,48 +0,0 @@ -#!/bin/bash -e -set -e - -CMAKE_BUILD_TYPE="${CMAKE_BUILD_TYPE:-Release}" -SUNSHINE_EXECUTABLE_PATH="${SUNSHINE_EXECUTABLE_PATH:-/usr/bin/sunshine}" -SUNSHINE_ASSETS_DIR="${SUNSHINE_ASSETS_DIR:-/etc/sunshine}" - - -SUNSHINE_ROOT="${SUNSHINE_ROOT:-/root/sunshine}" -SUNSHINE_TAG="${SUNSHINE_TAG:-master}" -SUNSHINE_GIT_URL="${SUNSHINE_GIT_URL:-https://github.com/sunshinestream/sunshine.git}" - - -SUNSHINE_ENABLE_WAYLAND=${SUNSHINE_ENABLE_WAYLAND:-ON} -SUNSHINE_ENABLE_X11=${SUNSHINE_ENABLE_X11:-ON} -SUNSHINE_ENABLE_DRM=${SUNSHINE_ENABLE_DRM:-ON} -SUNSHINE_ENABLE_CUDA=${SUNSHINE_ENABLE_CUDA:-ON} - -# For debugging, it would be usefull to have the sources on the host. -if [[ ! -d "$SUNSHINE_ROOT" ]] -then - git clone --depth 1 --branch "$SUNSHINE_TAG" "$SUNSHINE_GIT_URL" --recurse-submodules "$SUNSHINE_ROOT" -fi - -if [[ ! -d /root/sunshine-build ]] -then - mkdir -p /root/sunshine-build -fi -cd /root/sunshine-build - -cmake "-DCMAKE_BUILD_TYPE=$CMAKE_BUILD_TYPE" "-DSUNSHINE_EXECUTABLE_PATH=$SUNSHINE_EXECUTABLE_PATH" "-DSUNSHINE_ASSETS_DIR=$SUNSHINE_ASSETS_DIR" "-DSUNSHINE_ENABLE_WAYLAND=$SUNSHINE_ENABLE_WAYLAND" "-DSUNSHINE_ENABLE_X11=$SUNSHINE_ENABLE_X11" "-DSUNSHINE_ENABLE_DRM=$SUNSHINE_ENABLE_DRM" "-DSUNSHINE_ENABLE_CUDA=$SUNSHINE_ENABLE_CUDA" "$SUNSHINE_ROOT" - -make -j ${nproc} - -# Get preferred package format -if [ "$1" == "-rpm" ] -then - echo "Packaging in .rpm format." - ./gen-rpm -d -elif [ "$1" == "-deb" ] -then - echo "Packaging in .deb format." - ./gen-deb -else - echo "Preferred packaging not specified." - echo "Use -deb or -rpm to specify preferred package format." - exit 1 -fi diff --git a/scripts/build-sunshine.sh b/scripts/build-sunshine.sh index 5be8280823d..cce610a9645 100755 --- a/scripts/build-sunshine.sh +++ b/scripts/build-sunshine.sh @@ -1,132 +1,29 @@ #!/bin/bash -e set -e -usage() { - echo "Usage: $0" - echo " -d: Generate a debug build" - echo " -p: Generate a linux package" - echo " -e: Extension of package... i.e. 'deb', 'rpm' --> default [deb]" - echo " -u: The input device is not a TTY" - echo " -n name: Docker container name --> default [sunshine]" - echo " -s path/to/sources/sunshine: Use local sources instead of a git repository" - echo " -c path/to/cmake/binary/dir: Store cmake output on host OS" -} - -# Attempt to turn relative paths into absolute paths -absolute_path() { - RELATIVE_PATH=$1 - if which realpath >/dev/null 2>/dev/null - then - RELATIVE_PATH=$(realpath $RELATIVE_PATH) - else - echo "Warning: realpath is not installed on your system, ensure [$1] is absolute" - fi - - RETURN=$RELATIVE_PATH -} - -CMAKE_BUILD_TYPE="-e CMAKE_BUILD_TYPE=Release" -SUNSHINE_PACKAGE_BUILD=OFF -SUNSHINE_PACKAGE_EXTENSION=deb -SUNSHINE_GIT_URL=https://github.com/sunshinestream/sunshine.git -CONTAINER_NAME=sunshine - -# Docker will fail if ctrl+c is passed through and the input is not a tty -DOCKER_INTERACTIVE=-ti - -while getopts ":dpuhc:e:s:n:" arg; do - case ${arg} in - u) - echo "Input device is not a TTY" - USERNAME="$USER" - unset DOCKER_INTERACTIVE - ;; - d) - echo "Creating debug build" - CMAKE_BUILD_TYPE="-e CMAKE_BUILD_TYPE=Debug" - ;; - p) - echo "Creating package build" - SUNSHINE_PACKAGE_BUILD=ON - SUNSHINE_ASSETS_DIR="-e SUNSHINE_ASSETS_DIR=/etc/sunshine" - SUNSHINE_EXECUTABLE_PATH="-e SUNSHINE_EXECUTABLE_PATH=/usr/bin/sunshine" - ;; - e) - echo "Defining package extension: $OPTARG" - if [ "$OPTARG" == "deb" ] - then - SUNSHINE_PACKAGE_EXTENSION=$OPTARG - echo "Package extension: deb" - elif [ "$OPTARG" == "rpm" ] - then - SUNSHINE_PACKAGE_EXTENSION=$OPTARG - echo "Package extension: rpm" - else - echo "Package extension not supported: $OPTARG" - echo "Falling back to default package extension: $SUNSHINE_PACKAGE_EXTENSION" - fi - ;; - s) - absolute_path "$OPTARG" - OPTARG="$RETURN" - echo "Using sources from $OPTARG" - SUNSHINE_ROOT="-v $OPTARG:/root/sunshine" - ;; - c) - [ "$USERNAME" == "" ] && USERNAME=$(logname) - - absolute_path "$OPTARG" - OPTARG="$RETURN" - - echo "Using $OPTARG as cmake binary dir" - if [[ ! -d $OPTARG ]] - then - echo "cmake binary dir doesn't exist, a new one will be created." - mkdir -p "$OPTARG" - [ "$USERNAME" == "$USER"] || chown $USERNAME:$USERNAME "$OPTARG" - fi - - CMAKE_ROOT="-v $OPTARG:/root/sunshine-build" - ;; - n) - echo "Container name: $OPTARG" - CONTAINER_NAME=$OPTARG - ;; - h) - usage - exit 0 - ;; - esac -done - -[ "$USERNAME" = "" ] && USERNAME=$(logname) - -BUILD_DIR="$PWD/$CONTAINER_NAME-build" -[ "$SUNSHINE_ASSETS_DIR" = "" ] && SUNSHINE_ASSETS_DIR="-e SUNSHINE_ASSETS_DIR=$BUILD_DIR/assets" -[ "$SUNSHINE_EXECUTABLE_PATH" = "" ] && SUNSHINE_EXECUTABLE_PATH="-e SUNSHINE_EXECUTABLE_PATH=$BUILD_DIR/sunshine" - -echo "docker run $DOCKER_INTERACTIVE --privileged $SUNSHINE_ROOT $CMAKE_ROOT $SUNSHINE_ASSETS_DIR $SUNSHINE_EXECUTABLE_PATH $CMAKE_BUILD_TYPE --name $CONTAINER_NAME $CONTAINER_NAME" -docker run $DOCKER_INTERACTIVE --privileged $SUNSHINE_ROOT $CMAKE_ROOT $SUNSHINE_ASSETS_DIR $SUNSHINE_EXECUTABLE_PATH $CMAKE_BUILD_TYPE --name $CONTAINER_NAME $CONTAINER_NAME - -exit_code=$? - -if [ $exit_code -eq 0 ] -then - mkdir -p $BUILD_DIR - case $SUNSHINE_PACKAGE_BUILD in - ON) - echo "Downloading package to: $BUILD_DIR/$CONTAINER_NAME.$SUNSHINE_PACKAGE_EXTENSION" - docker cp $CONTAINER_NAME:/root/sunshine-build/package-$SUNSHINE_PACKAGE_EXTENSION/sunshine.$SUNSHINE_PACKAGE_EXTENSION "$BUILD_DIR/$CONTAINER_NAME.$SUNSHINE_PACKAGE_EXTENSION" - ;; - *) - echo "Downloading binary and assets to: $BUILD_DIR" - docker cp $CONTAINER_NAME:/root/sunshine/assets "$BUILD_DIR" - docker cp $CONTAINER_NAME:/root/sunshine-build/sunshine "$BUILD_DIR" - ;; - esac - echo "chown --recursive $USERNAME:$USERNAME $BUILD_DIR" - chown --recursive $USERNAME:$USERNAME "$BUILD_DIR" +CMAKE_BUILD_TYPE="${CMAKE_BUILD_TYPE:-Release}" +SUNSHINE_EXECUTABLE_PATH="${SUNSHINE_EXECUTABLE_PATH:-/usr/bin/sunshine}" +SUNSHINE_ROOT="${SUNSHINE_ROOT:-/root/sunshine}" +SUNSHINE_CONFIG_DIR="${SUNSHINE_CONFIG_DIR:-/etc/sunshine}" + +SUNSHINE_ENABLE_WAYLAND=${SUNSHINE_ENABLE_WAYLAND:-ON} +SUNSHINE_ENABLE_X11=${SUNSHINE_ENABLE_X11:-ON} +SUNSHINE_ENABLE_DRM=${SUNSHINE_ENABLE_DRM:-ON} +SUNSHINE_ENABLE_CUDA=${SUNSHINE_ENABLE_CUDA:-ON} + +if [[ ! -d /root/sunshine-build ]]; then + mkdir -p /root/sunshine-build fi - -echo "Removing docker container $CONTAINER_NAME" -docker rm $CONTAINER_NAME +cd /root/sunshine-build + +cmake \ + "-DCMAKE_BUILD_TYPE=$CMAKE_BUILD_TYPE" \ + "-DSUNSHINE_EXECUTABLE_PATH=$SUNSHINE_EXECUTABLE_PATH" \ + "-DSUNSHINE_ENABLE_WAYLAND=$SUNSHINE_ENABLE_WAYLAND" \ + "-DSUNSHINE_ENABLE_X11=$SUNSHINE_ENABLE_X11" \ + "-DSUNSHINE_ENABLE_DRM=$SUNSHINE_ENABLE_DRM" \ + "-DSUNSHINE_ENABLE_CUDA=$SUNSHINE_ENABLE_CUDA" \ + "-DSUNSHINE_CONFIG_DIR=$SUNSHINE_CONFIG_DIR" \ + "$SUNSHINE_ROOT" + +make -j ${nproc}