From 3ed6442b4973c355d1fd4e831c8912403d8ea6f7 Mon Sep 17 00:00:00 2001 From: Simon Bruder Date: Thu, 9 May 2024 02:31:43 +0200 Subject: [PATCH] Update 3rd party rulesets Some did not build and were removed. This change also makes building much faster, as the build now caches NuGet packages and uses one stage per ruleset, so they can be built in parallel (by passing `--jobs N`). --- Dockerfile | 48 ++++++++++++++++++++++++++---------------------- README.md | 4 +++- build-ruleset.sh | 18 ++++++++++++++++++ 3 files changed, 47 insertions(+), 23 deletions(-) create mode 100755 build-ruleset.sh diff --git a/Dockerfile b/Dockerfile index caa2ee0..6799eef 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,3 +1,4 @@ +# Builder for base osu! FROM mcr.microsoft.com/dotnet/sdk:8.0 as builder ENV DOTNET_CLI_TELEMETRY_OPTOUT 1 @@ -8,7 +9,7 @@ RUN apt-get update \ ARG OSU_VERSION ENV OSU_VERSION=$OSU_VERSION -RUN echo "Downloading and building osu! ${OSU_VERSION}" >&2 \ +RUN --mount=type=cache,target=/root/.nuget/packages --mount=type=cache,target=/root/.local/share/NuGet/http-cache echo "Downloading and building osu! ${OSU_VERSION}" >&2 \ && git clone --depth=1 --single-branch -b ${OSU_VERSION} https://github.com/ppy/osu \ && cd osu \ && dotnet publish \ @@ -19,27 +20,25 @@ RUN echo "Downloading and building osu! ${OSU_VERSION}" >&2 \ -p:Version=${OSU_VERSION} \ osu.Desktop -RUN for ruleset in \ - "Bosu|https://github.com/EVAST9919/bosu" \ - "Hitokori|https://github.com/Flutterish/Hitokori" \ - "Karaoke|https://github.com/karaoke-dev/karaoke" \ - "Mvis|https://github.com/EVAST9919/lazer-m-vis" \ - "Rush|https://github.com/swoolcock/rush" \ - "Sentakki|https://github.com/LumpBloom7/sentakki" \ - "Swing|https://github.com/EVAST9919/lazer-swing" \ - "Tau|https://github.com/Altenhh/tau" \ - ; do \ - repo_url="$(echo $ruleset | cut -d'|' -f2)" \ - && assembly_name="osu.Game.Rulesets.$(echo $ruleset | cut -d'|' -f1)" \ - && git clone --depth=1 "$repo_url" ruleset \ - && cd ruleset \ - && dotnet build \ - -c Release \ - "$assembly_name" \ - && cp "${assembly_name}"/bin/Release/net*/"${assembly_name}".dll /opt/osu/ \ - && cd .. \ - && rm -rf ruleset \ - ; done +# Generic builder for rulesets (using onbuild and args) +FROM mcr.microsoft.com/dotnet/sdk:8.0 as builder-ruleset-generic + +COPY ./build-ruleset.sh /usr/local/bin/build-ruleset + +FROM builder-ruleset-generic as builder-swing +RUN --mount=type=cache,target=/root/.nuget/packages --mount=type=cache,target=/root/.local/share/NuGet/http-cache build-ruleset https://github.com/EVAST9919/lazer-swing + +FROM builder-ruleset-generic as builder-tau +RUN --mount=type=cache,target=/root/.nuget/packages --mount=type=cache,target=/root/.local/share/NuGet/http-cache build-ruleset https://github.com/Altenhh/tau + +FROM builder-ruleset-generic as builder-bosu +RUN --mount=type=cache,target=/root/.nuget/packages --mount=type=cache,target=/root/.local/share/NuGet/http-cache build-ruleset https://github.com/EVAST9919/bosu + +FROM builder-ruleset-generic as builder-rush +RUN --mount=type=cache,target=/root/.nuget/packages --mount=type=cache,target=/root/.local/share/NuGet/http-cache build-ruleset https://github.com/swoolcock/rush + +FROM builder-ruleset-generic as builder-sentakki +RUN --mount=type=cache,target=/root/.nuget/packages --mount=type=cache,target=/root/.local/share/NuGet/http-cache build-ruleset https://github.com/LumpBloom7/sentakki FROM mcr.microsoft.com/dotnet/runtime:8.0 @@ -53,6 +52,11 @@ RUN apt-get update \ && rm -rf /var/lib/apt/lists/* COPY --from=builder /opt/osu/ /opt/osu/ +COPY --from=builder-swing /dlls/*.dll /opt/osu/ +COPY --from=builder-tau /dlls/*.dll /opt/osu/ +COPY --from=builder-bosu /dlls/*.dll /opt/osu/ +COPY --from=builder-rush /dlls/*.dll /opt/osu/ +COPY --from=builder-sentakki /dlls/*.dll /opt/osu/ RUN adduser --disabled-password --gecos '' osu USER osu diff --git a/README.md b/README.md index 85de025..f225dcb 100644 --- a/README.md +++ b/README.md @@ -6,9 +6,11 @@ Using podman/buildah: - buildah build --format docker --layers -t osu --build-arg OSU_VERSION=2024.412.1 + buildah build --format docker --layers -t osu --build-arg OSU_VERSION=2024.412.1 --jobs 0 Change `2024.412.1` to the newest osu! version. +By changing `--jobs 0` to a positive integer N, +at most N build stages will be run in parallel. ### Running diff --git a/build-ruleset.sh b/build-ruleset.sh new file mode 100755 index 0000000..9ab3175 --- /dev/null +++ b/build-ruleset.sh @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +set -euo pipefail + +RULESET_URL="$1" + +git clone --depth=1 "${RULESET_URL}" ruleset +pushd ruleset +ASSEMBLY_NAME="$(basename "$(find . -iname '*.sln' -printf '%f\n' | head -n1)" .sln)" +dotnet build -c Release ${ASSEMBLY_NAME} +case "${ASSEMBLY_NAME}" in + # special build steps can be put here + *) + mkdir /dlls + mv ${ASSEMBLY_NAME}/bin/Release/net*/${ASSEMBLY_NAME}.dll /dlls/ + ;; +esac +popd +rm -rf ruleset