From 7c2db9bb00141701c8e0d9deedb37b4583e67b58 Mon Sep 17 00:00:00 2001 From: Masu Baumgartner <68913099+Masu-Baumgartner@users.noreply.github.com> Date: Fri, 21 Jun 2024 19:54:59 +0200 Subject: [PATCH 01/20] Upgrade .net version of the docker image to 8 --- Moonlight/Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Moonlight/Dockerfile b/Moonlight/Dockerfile index b5f1c6b1..b2c6537a 100644 --- a/Moonlight/Dockerfile +++ b/Moonlight/Dockerfile @@ -1,9 +1,9 @@ -FROM mcr.microsoft.com/dotnet/aspnet:7.0 AS base +FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base WORKDIR /app EXPOSE 80 EXPOSE 443 -FROM mcr.microsoft.com/dotnet/sdk:7.0 AS build +FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build ARG BUILD_CONFIGURATION=Release WORKDIR /src COPY ["Moonlight/Moonlight.csproj", "Moonlight/"] From d9d17c834226b513a585f4149cc009a2e242f972 Mon Sep 17 00:00:00 2001 From: Masu Baumgartner <68913099+Masu-Baumgartner@users.noreply.github.com> Date: Sat, 22 Jun 2024 20:03:27 +0200 Subject: [PATCH 02/20] Allow changing of multipart form upload limit --- Moonlight/Core/CoreFeature.cs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Moonlight/Core/CoreFeature.cs b/Moonlight/Core/CoreFeature.cs index 7165ee44..dcd19184 100644 --- a/Moonlight/Core/CoreFeature.cs +++ b/Moonlight/Core/CoreFeature.cs @@ -25,6 +25,7 @@ using Moonlight.Core.Attributes; using Moonlight.Core.Http.Middleware; using Moonlight.Core.Implementations.ApiDefinition; using Swashbuckle.AspNetCore.SwaggerGen; +using Microsoft.AspNetCore.Http.Features; namespace Moonlight.Core; @@ -96,6 +97,12 @@ public class CoreFeature : MoonlightFeature options.Limits.MaxRequestBodySize = ByteSizeValue.FromMegaBytes(config.Http.UploadLimit).Bytes; }); + // Setup http upload limit in forms + context.Builder.Services.Configure(x => + { + x.MultipartBodyLengthLimit = ByteSizeValue.FromMegaBytes(config.Http.UploadLimit).Bytes; + }); + // Assets // - Javascript From 1525215757f592fec4eb143bc3f97a4b33c0c9f1 Mon Sep 17 00:00:00 2001 From: Marcel Baumgartner Date: Fri, 28 Jun 2024 11:36:45 +0200 Subject: [PATCH 03/20] Added versioning --- Moonlight/Core/Services/MoonlightService.cs | 40 +++++++++++++++++++ Moonlight/Core/UI/Views/Admin/Sys/Index.razor | 32 ++++++++++++--- Moonlight/Dockerfile | 14 +++++++ 3 files changed, 81 insertions(+), 5 deletions(-) diff --git a/Moonlight/Core/Services/MoonlightService.cs b/Moonlight/Core/Services/MoonlightService.cs index 3ffa5f84..8bfb2a1d 100644 --- a/Moonlight/Core/Services/MoonlightService.cs +++ b/Moonlight/Core/Services/MoonlightService.cs @@ -7,10 +7,50 @@ namespace Moonlight.Core.Services; [Singleton] public class MoonlightService { + public readonly string BuildChannel; + public readonly string BuildCommitHash; + public readonly string BuildName; + public readonly string BuildVersion; + public readonly bool IsDockerRun; + public WebApplication Application { get; set; } // Do NOT modify using a plugin private readonly DateTime StartTimestamp = DateTime.UtcNow; + public MoonlightService() + { + //TODO: Maybe extract to a method + + if (!File.Exists("version")) + { + BuildChannel = "N/A"; + BuildCommitHash = "N/A"; + BuildName = "N/A"; + BuildVersion = "N/A"; + IsDockerRun = false; + } + + var line = File.ReadAllText("version"); + var parts = line.Split(";"); + + if (parts.Length < 5) + { + BuildChannel = "N/A"; + BuildCommitHash = "N/A"; + BuildName = "N/A"; + BuildVersion = "N/A"; + IsDockerRun = false; + } + + BuildChannel = parts[0]; + BuildCommitHash = parts[1]; + BuildName = parts[2]; + BuildVersion = parts[3]; + IsDockerRun = parts[4] == "docker"; + + //TODO: Add log call + } + public async Task Restart() { Logger.Info("Restarting moonlight"); diff --git a/Moonlight/Core/UI/Views/Admin/Sys/Index.razor b/Moonlight/Core/UI/Views/Admin/Sys/Index.razor index 626f7467..5343daf5 100644 --- a/Moonlight/Core/UI/Views/Admin/Sys/Index.razor +++ b/Moonlight/Core/UI/Views/Admin/Sys/Index.razor @@ -29,9 +29,6 @@ -
- -
@{ var uptimeText = Formatter.FormatUptime(Uptime); @@ -40,7 +37,30 @@
- + @if (MoonlightService.IsDockerRun) + { + + } + else + { + + } +
+
+ @{ + var commitText = $"{MoonlightService.BuildCommitHash} (up-to-date)"; + } + + +
+
+ +
+
+ +
+
+
@@ -74,7 +94,9 @@ { await lazyLoader.SetText("Loading system statistics"); - OsName = await HostSystemHelper.GetOsName(); + if(!MoonlightService.IsDockerRun) + OsName = await HostSystemHelper.GetOsName(); + CpuUsage = await HostSystemHelper.GetCpuUsage(); MemoryUsage = await HostSystemHelper.GetMemoryUsage(); Uptime = await MoonlightService.GetUptime(); diff --git a/Moonlight/Dockerfile b/Moonlight/Dockerfile index b2c6537a..d6539dfb 100644 --- a/Moonlight/Dockerfile +++ b/Moonlight/Dockerfile @@ -17,6 +17,13 @@ ARG BUILD_CONFIGURATION=Release RUN dotnet publish "Moonlight.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false FROM base AS final + +# Define args +ARG BUILD_CHANNEL=unknown +ARG BUILD_COMMIT_HASH=unknown +ARG BUILD_NAME=unknown +ARG BUILD_VERSION=unknown + WORKDIR /app COPY --from=publish /app/publish . @@ -24,4 +31,11 @@ COPY --from=publish /app/publish . RUN mkdir -p /app/Assets COPY ./Moonlight/Assets ./Assets +# Ensure storage folder exists and is empty +RUN mkdir -p /app/storage +RUN rm -rf /app/storage/* + +# Version the build +RUN echo "$BUILD_CHANNEL;$BUILD_COMMIT_HASH;$BUILD_NAME;$BUILD_VERSION;docker" > /app/version + ENTRYPOINT ["dotnet", "Moonlight.dll"] From 650b993325a24a815851e558c9fcd7a88ae4a3b7 Mon Sep 17 00:00:00 2001 From: Marcel Baumgartner Date: Fri, 28 Jun 2024 11:37:09 +0200 Subject: [PATCH 04/20] Added github actions --- .github/workflows/development-build.yml | 33 +++++++++++++++++++++++++ .github/workflows/release-build.yml | 30 ++++++++++++++++++++++ 2 files changed, 63 insertions(+) create mode 100644 .github/workflows/development-build.yml create mode 100644 .github/workflows/release-build.yml diff --git a/.github/workflows/development-build.yml b/.github/workflows/development-build.yml new file mode 100644 index 00000000..dc03a183 --- /dev/null +++ b/.github/workflows/development-build.yml @@ -0,0 +1,33 @@ +name: Development Build + +on: + workflow_dispatch: + pull_request: + types: + - closed + branches: [ "v2" ] + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + - name: Login into docker hub + run: docker login -u ${{ secrets.DOCKER_USER }} -p ${{ secrets.DOCKER_PW }} + - name: Build and Push Docker image + uses: docker/build-push-action@v5 + with: + context: . + file: ./Moonlight/Dockerfile + push: true + tags: moonlightpanel/moonlight:dev + platforms: linux/amd64,linux/arm64 + build-args: | + "BUILD_CHANNEL=${GITHUB_REF#refs/heads/}" + "BUILD_COMMIT_HASH=${git rev-parse --short '$GITHUB_SHA'}" + "BUILD_NAME=devbuild ${date}" + "BUILD_VERSION=${git rev-parse --short '$GITHUB_SHA'}" + \ No newline at end of file diff --git a/.github/workflows/release-build.yml b/.github/workflows/release-build.yml new file mode 100644 index 00000000..e443b150 --- /dev/null +++ b/.github/workflows/release-build.yml @@ -0,0 +1,30 @@ +name: Release Build + +on: + workflow_dispatch: + release: + types: [ published ] + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + - name: Login into docker hub + run: docker login -u ${{ secrets.DOCKER_USER }} -p ${{ secrets.DOCKER_PW }} + - name: Build and Push Docker image + uses: docker/build-push-action@v5 + with: + context: . + file: ./Moonlight/Dockerfile + push: true + tags: moonlightpanel/moonlight:latest + platforms: linux/amd64,linux/arm64 + build-args: | + "BUILD_CHANNEL=${GITHUB_REF#refs/heads/}" + "BUILD_COMMIT_HASH=${git rev-parse --short '$GITHUB_SHA'}" + "BUILD_NAME=${{ github.event.release.name }}" + "BUILD_VERSION=${git rev-parse --short '$GITHUB_SHA'}" \ No newline at end of file From 9d9717df6124b1ce8f18aed332dbd12f63da71be Mon Sep 17 00:00:00 2001 From: Marcel Baumgartner Date: Fri, 28 Jun 2024 11:55:55 +0200 Subject: [PATCH 05/20] Upgraded build push action version. Changed ubuntu version --- .github/workflows/development-build.yml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/development-build.yml b/.github/workflows/development-build.yml index dc03a183..c2f5d71d 100644 --- a/.github/workflows/development-build.yml +++ b/.github/workflows/development-build.yml @@ -9,7 +9,7 @@ on: jobs: build: - runs-on: ubuntu-latest + runs-on: ubuntu-20.04 steps: - name: Checkout code uses: actions/checkout@v4 @@ -18,7 +18,7 @@ jobs: - name: Login into docker hub run: docker login -u ${{ secrets.DOCKER_USER }} -p ${{ secrets.DOCKER_PW }} - name: Build and Push Docker image - uses: docker/build-push-action@v5 + uses: docker/build-push-action@v6 with: context: . file: ./Moonlight/Dockerfile @@ -29,5 +29,4 @@ jobs: "BUILD_CHANNEL=${GITHUB_REF#refs/heads/}" "BUILD_COMMIT_HASH=${git rev-parse --short '$GITHUB_SHA'}" "BUILD_NAME=devbuild ${date}" - "BUILD_VERSION=${git rev-parse --short '$GITHUB_SHA'}" - \ No newline at end of file + "BUILD_VERSION=${git rev-parse --short '$GITHUB_SHA'}" \ No newline at end of file From f924bcfcc6479f79d2107a50cbea9bc6b4f58122 Mon Sep 17 00:00:00 2001 From: Masu Baumgartner <68913099+Masu-Baumgartner@users.noreply.github.com> Date: Fri, 28 Jun 2024 13:29:36 +0200 Subject: [PATCH 06/20] Updated development-build.yml --- .github/workflows/development-build.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/development-build.yml b/.github/workflows/development-build.yml index c2f5d71d..8c32632b 100644 --- a/.github/workflows/development-build.yml +++ b/.github/workflows/development-build.yml @@ -9,7 +9,7 @@ on: jobs: build: - runs-on: ubuntu-20.04 + runs-on: self-hosted steps: - name: Checkout code uses: actions/checkout@v4 @@ -29,4 +29,4 @@ jobs: "BUILD_CHANNEL=${GITHUB_REF#refs/heads/}" "BUILD_COMMIT_HASH=${git rev-parse --short '$GITHUB_SHA'}" "BUILD_NAME=devbuild ${date}" - "BUILD_VERSION=${git rev-parse --short '$GITHUB_SHA'}" \ No newline at end of file + "BUILD_VERSION=${git rev-parse --short '$GITHUB_SHA'}" From fcfbf5a01d96374f28f4e25c5c0907d4ba833fbc Mon Sep 17 00:00:00 2001 From: Marcel Baumgartner Date: Sat, 29 Jun 2024 19:03:04 +0200 Subject: [PATCH 07/20] Added missing return statement for file check --- Moonlight/Core/Services/MoonlightService.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/Moonlight/Core/Services/MoonlightService.cs b/Moonlight/Core/Services/MoonlightService.cs index 8bfb2a1d..0a85bdae 100644 --- a/Moonlight/Core/Services/MoonlightService.cs +++ b/Moonlight/Core/Services/MoonlightService.cs @@ -28,6 +28,7 @@ public class MoonlightService BuildName = "N/A"; BuildVersion = "N/A"; IsDockerRun = false; + return; } var line = File.ReadAllText("version"); From 83c40ec4179a726c8eb03eda1662c24d182d8b65 Mon Sep 17 00:00:00 2001 From: Marcel Baumgartner Date: Sat, 29 Jun 2024 19:05:41 +0200 Subject: [PATCH 08/20] Adjusted image conversion helper to be compatible with the latest egg changes --- .../Servers/Helpers/ImageConversionHelper.cs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/Moonlight/Features/Servers/Helpers/ImageConversionHelper.cs b/Moonlight/Features/Servers/Helpers/ImageConversionHelper.cs index 2bfb0df2..840f5e1b 100644 --- a/Moonlight/Features/Servers/Helpers/ImageConversionHelper.cs +++ b/Moonlight/Features/Servers/Helpers/ImageConversionHelper.cs @@ -274,7 +274,17 @@ public class ImageConversionHelper // Node Regex: As the online detection uses regex, we want to escape any special chars from egg imports // as eggs dont use regex and as such may contain characters which regex uses as meta characters. // Without this escaping, many startup detection strings wont work - result.OnlineDetection = Regex.Escape(startup["done"]?.Value() ?? "Online detection was missing"); + + // As pelican/pterodactyl changed their image format AGAIN, there needs to be the check below + var val = startup["done"]!; + string rawDone; + + if (val is JArray array) + rawDone = array.First().Value() ?? "Online detection was missing"; + else + rawDone = val.Value() ?? "Online detection was missing"; + + result.OnlineDetection = Regex.Escape(rawDone); // Docker images From d821ce43b5b3ae838febe0eac4e57973e6bcbc6e Mon Sep 17 00:00:00 2001 From: Marcel Baumgartner Date: Sun, 30 Jun 2024 00:54:08 +0200 Subject: [PATCH 09/20] Switched to github actions runner from self hosted --- .github/workflows/development-build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/development-build.yml b/.github/workflows/development-build.yml index 8c32632b..20f87211 100644 --- a/.github/workflows/development-build.yml +++ b/.github/workflows/development-build.yml @@ -9,7 +9,7 @@ on: jobs: build: - runs-on: self-hosted + runs-on: ubuntu-latest steps: - name: Checkout code uses: actions/checkout@v4 From 48e84e815bd2df33494c451d52d11d4a87158f55 Mon Sep 17 00:00:00 2001 From: Marcel Baumgartner Date: Sun, 30 Jun 2024 00:54:54 +0200 Subject: [PATCH 10/20] Fixed arm restore issue. Thanks microsoft for NOT documenting this in the correct issue --- Moonlight/Dockerfile | 6 +- Moonlight/Moonlight.csproj | 173 +++++++++++++++++++------------------ 2 files changed, 91 insertions(+), 88 deletions(-) diff --git a/Moonlight/Dockerfile b/Moonlight/Dockerfile index d6539dfb..7393e0f3 100644 --- a/Moonlight/Dockerfile +++ b/Moonlight/Dockerfile @@ -1,10 +1,12 @@ -FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base +FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/aspnet:8.0 AS base WORKDIR /app EXPOSE 80 EXPOSE 443 -FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build +FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:8.0 AS build + ARG BUILD_CONFIGURATION=Release + WORKDIR /src COPY ["Moonlight/Moonlight.csproj", "Moonlight/"] RUN dotnet restore "Moonlight/Moonlight.csproj" diff --git a/Moonlight/Moonlight.csproj b/Moonlight/Moonlight.csproj index 63a95038..a7a07a4c 100644 --- a/Moonlight/Moonlight.csproj +++ b/Moonlight/Moonlight.csproj @@ -5,100 +5,101 @@ enable enable Linux + linux-arm64;linux-x64;win-x64 - - .dockerignore - - - true - PreserveNewest - - - true - PreserveNewest - - - true - PreserveNewest - - - true - PreserveNewest - - - true - PreserveNewest - - - true - PreserveNewest - - - true - PreserveNewest - - - true - PreserveNewest - - - true - PreserveNewest - + + .dockerignore + + + true + PreserveNewest + + + true + PreserveNewest + + + true + PreserveNewest + + + true + PreserveNewest + + + true + PreserveNewest + + + true + PreserveNewest + + + true + PreserveNewest + + + true + PreserveNewest + + + true + PreserveNewest + - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - - - - - - - + + + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + + + + From c6d88fe7bf963da56a05aaf1691c41893751ee86 Mon Sep 17 00:00:00 2001 From: Marcel Baumgartner Date: Sun, 30 Jun 2024 01:51:20 +0200 Subject: [PATCH 11/20] Improved version detecting --- Moonlight/Core/Services/MoonlightService.cs | 50 +++++++++---------- Moonlight/Core/UI/Views/Admin/Sys/Index.razor | 2 +- 2 files changed, 24 insertions(+), 28 deletions(-) diff --git a/Moonlight/Core/Services/MoonlightService.cs b/Moonlight/Core/Services/MoonlightService.cs index 0a85bdae..7b434c1c 100644 --- a/Moonlight/Core/Services/MoonlightService.cs +++ b/Moonlight/Core/Services/MoonlightService.cs @@ -19,35 +19,31 @@ public class MoonlightService public MoonlightService() { - //TODO: Maybe extract to a method - - if (!File.Exists("version")) - { - BuildChannel = "N/A"; - BuildCommitHash = "N/A"; - BuildName = "N/A"; - BuildVersion = "N/A"; - IsDockerRun = false; - return; - } + //TODO: Maybe extract to a method to make this a bit cleaner - var line = File.ReadAllText("version"); - var parts = line.Split(";"); + if (File.Exists("version")) + { + var line = File.ReadAllText("version"); + line = line.Trim(); + + var parts = line.Split(";"); - if (parts.Length < 5) - { - BuildChannel = "N/A"; - BuildCommitHash = "N/A"; - BuildName = "N/A"; - BuildVersion = "N/A"; - IsDockerRun = false; - } - - BuildChannel = parts[0]; - BuildCommitHash = parts[1]; - BuildName = parts[2]; - BuildVersion = parts[3]; - IsDockerRun = parts[4] == "docker"; + if (parts.Length >= 5) + { + BuildChannel = parts[0]; + BuildCommitHash = parts[1]; + BuildName = parts[2]; + BuildVersion = parts[3]; + IsDockerRun = parts[4] == "docker"; + return; + } + } + + BuildChannel = "N/A"; + BuildCommitHash = "N/A"; + BuildName = "N/A"; + BuildVersion = "N/A"; + IsDockerRun = false; //TODO: Add log call } diff --git a/Moonlight/Core/UI/Views/Admin/Sys/Index.razor b/Moonlight/Core/UI/Views/Admin/Sys/Index.razor index 5343daf5..ea40262c 100644 --- a/Moonlight/Core/UI/Views/Admin/Sys/Index.razor +++ b/Moonlight/Core/UI/Views/Admin/Sys/Index.razor @@ -48,7 +48,7 @@
@{ - var commitText = $"{MoonlightService.BuildCommitHash} (up-to-date)"; + var commitText = $"{MoonlightService.BuildCommitHash}"; // TODO: Add update check (possible during startup, with error handling etc) } From a8bb2aa0005db8d3be9731455dd85ed189094390 Mon Sep 17 00:00:00 2001 From: Marcel Baumgartner Date: Sun, 30 Jun 2024 01:51:40 +0200 Subject: [PATCH 12/20] Updated git ignore to include new theme path --- .gitignore | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 1cd56bb8..a0eda3a6 100644 --- a/.gitignore +++ b/.gitignore @@ -399,6 +399,6 @@ FodyWeavers.xsd storage/ .idea/.idea.Moonlight/.idea/dataSources.xml -Moonlight/wwwroot/css/theme.css -Moonlight/wwwroot/css/theme.css.map +Moonlight/Assets/Core/css/theme.css +Moonlight/Assets/Core/css/theme.css.map .idea/.idea.Moonlight/.idea/discord.xml From caa7bb2af6952c9ed569bbbad2e7e913dffedda7 Mon Sep 17 00:00:00 2001 From: Marcel Baumgartner Date: Sun, 30 Jun 2024 01:52:00 +0200 Subject: [PATCH 13/20] Moved theme to asset api --- Moonlight/Core/CoreFeature.cs | 1 + Moonlight/Moonlight.csproj | 1 - Moonlight/Pages/_Host.cshtml | 5 ----- Moonlight/Styles/build.bat | 2 +- 4 files changed, 2 insertions(+), 7 deletions(-) diff --git a/Moonlight/Core/CoreFeature.cs b/Moonlight/Core/CoreFeature.cs index dcd19184..e7ad9e81 100644 --- a/Moonlight/Core/CoreFeature.cs +++ b/Moonlight/Core/CoreFeature.cs @@ -114,6 +114,7 @@ public class CoreFeature : MoonlightFeature context.AddAsset("Core", "js/alerter.js"); // - Css + context.AddAsset("Core", "css/theme.css"); context.AddAsset("Core", "css/blazor.css"); context.AddAsset("Core", "css/boxicons.css"); context.AddAsset("Core", "css/sweetalert2dark.css"); diff --git a/Moonlight/Moonlight.csproj b/Moonlight/Moonlight.csproj index a7a07a4c..bfd080f9 100644 --- a/Moonlight/Moonlight.csproj +++ b/Moonlight/Moonlight.csproj @@ -77,7 +77,6 @@ - diff --git a/Moonlight/Pages/_Host.cshtml b/Moonlight/Pages/_Host.cshtml index b90a9547..bb49475b 100644 --- a/Moonlight/Pages/_Host.cshtml +++ b/Moonlight/Pages/_Host.cshtml @@ -28,11 +28,6 @@ } } - - - - - diff --git a/Moonlight/Styles/build.bat b/Moonlight/Styles/build.bat index 19e34edd..a2e79953 100644 --- a/Moonlight/Styles/build.bat +++ b/Moonlight/Styles/build.bat @@ -1,2 +1,2 @@ @echo off -sass style.scss ../wwwroot/css/theme.css \ No newline at end of file +sass style.scss ../Assets/Core/css/theme.css \ No newline at end of file From 52b3616de47ca5e99cc45d431c8c698ac0f407d2 Mon Sep 17 00:00:00 2001 From: Marcel Baumgartner Date: Sun, 30 Jun 2024 01:52:17 +0200 Subject: [PATCH 14/20] Included scss compiling using sass in the docker image --- Moonlight/Dockerfile | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Moonlight/Dockerfile b/Moonlight/Dockerfile index 7393e0f3..2eac138f 100644 --- a/Moonlight/Dockerfile +++ b/Moonlight/Dockerfile @@ -14,6 +14,16 @@ COPY . . WORKDIR "/src/Moonlight" RUN dotnet build "Moonlight.csproj" -c $BUILD_CONFIGURATION -o /app/build +# Install sass +RUN apt-get update +RUN apt-get install wget -y +RUN cat /etc/os-release +RUN wget -O /tmp/sass.tar.gz https://github.com/sass/dart-sass/releases/download/1.77.5/dart-sass-1.77.5-linux-x64.tar.gz +RUN tar -xf /tmp/sass.tar.gz -C /tmp +RUN chmod +x /tmp/dart-sass/sass +RUN mkdir -p /app/build/Assets/Core/css/ +RUN /tmp/dart-sass/sass /src/Moonlight/Styles/style.scss /app/build/Assets/Core/css/theme.css + FROM build AS publish ARG BUILD_CONFIGURATION=Release RUN dotnet publish "Moonlight.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false From a895372e1352adadbae6b210fb5bd34cfc075c6f Mon Sep 17 00:00:00 2001 From: Marcel Baumgartner Date: Sun, 30 Jun 2024 02:02:33 +0200 Subject: [PATCH 15/20] Corrected failing scss compiling --- Moonlight/Dockerfile | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Moonlight/Dockerfile b/Moonlight/Dockerfile index 2eac138f..4d659464 100644 --- a/Moonlight/Dockerfile +++ b/Moonlight/Dockerfile @@ -14,18 +14,17 @@ COPY . . WORKDIR "/src/Moonlight" RUN dotnet build "Moonlight.csproj" -c $BUILD_CONFIGURATION -o /app/build -# Install sass +FROM build AS publish +ARG BUILD_CONFIGURATION=Release + +# Install sass and compile styles RUN apt-get update RUN apt-get install wget -y -RUN cat /etc/os-release RUN wget -O /tmp/sass.tar.gz https://github.com/sass/dart-sass/releases/download/1.77.5/dart-sass-1.77.5-linux-x64.tar.gz RUN tar -xf /tmp/sass.tar.gz -C /tmp RUN chmod +x /tmp/dart-sass/sass -RUN mkdir -p /app/build/Assets/Core/css/ -RUN /tmp/dart-sass/sass /src/Moonlight/Styles/style.scss /app/build/Assets/Core/css/theme.css +RUN /tmp/dart-sass/sass /src/Moonlight/Styles/style.scss /app/publish/theme.css -FROM build AS publish -ARG BUILD_CONFIGURATION=Release RUN dotnet publish "Moonlight.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false FROM base AS final @@ -41,7 +40,8 @@ COPY --from=publish /app/publish . # Copy default assets RUN mkdir -p /app/Assets -COPY ./Moonlight/Assets ./Assets +COPY ./Moonlight/Assets /app/Assets +RUN mv /app/theme.css /app/Assets/Core/css/theme.css # Ensure storage folder exists and is empty RUN mkdir -p /app/storage From 2eac1b3c7862f5f855675b2f532775c25cf1a6d3 Mon Sep 17 00:00:00 2001 From: Marcel Baumgartner Date: Sun, 30 Jun 2024 02:16:12 +0200 Subject: [PATCH 16/20] Updated workflows --- .github/workflows/development-build.yml | 11 +++++++---- .github/workflows/release-build.yml | 17 +++++++++++------ 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/.github/workflows/development-build.yml b/.github/workflows/development-build.yml index 20f87211..5670ad92 100644 --- a/.github/workflows/development-build.yml +++ b/.github/workflows/development-build.yml @@ -11,6 +11,9 @@ jobs: build: runs-on: ubuntu-latest steps: + - name: Get current date + id: date + run: echo "::set-output name=date::$(date +'%Y-%m-%d')" - name: Checkout code uses: actions/checkout@v4 - name: Set up Docker Buildx @@ -26,7 +29,7 @@ jobs: tags: moonlightpanel/moonlight:dev platforms: linux/amd64,linux/arm64 build-args: | - "BUILD_CHANNEL=${GITHUB_REF#refs/heads/}" - "BUILD_COMMIT_HASH=${git rev-parse --short '$GITHUB_SHA'}" - "BUILD_NAME=devbuild ${date}" - "BUILD_VERSION=${git rev-parse --short '$GITHUB_SHA'}" + "BUILD_CHANNEL=${{github.ref_name}}" + "BUILD_COMMIT_HASH=${{github.sha}} + "BUILD_NAME=devbuild ${{steps.date.outputs.date}}" + "BUILD_VERSION=unknown" diff --git a/.github/workflows/release-build.yml b/.github/workflows/release-build.yml index e443b150..027b5c4e 100644 --- a/.github/workflows/release-build.yml +++ b/.github/workflows/release-build.yml @@ -2,8 +2,13 @@ name: Release Build on: workflow_dispatch: - release: - types: [ published ] + inputs: + codeName: + description: 'Code Name' + required: true + versionName: + description: 'Version Name' + required: true jobs: build: @@ -24,7 +29,7 @@ jobs: tags: moonlightpanel/moonlight:latest platforms: linux/amd64,linux/arm64 build-args: | - "BUILD_CHANNEL=${GITHUB_REF#refs/heads/}" - "BUILD_COMMIT_HASH=${git rev-parse --short '$GITHUB_SHA'}" - "BUILD_NAME=${{ github.event.release.name }}" - "BUILD_VERSION=${git rev-parse --short '$GITHUB_SHA'}" \ No newline at end of file + "BUILD_CHANNEL=${{github.ref_name}}" + "BUILD_COMMIT_HASH=${{github.sha}} + "BUILD_NAME=${{github.event.inputs.codeName}}" + "BUILD_VERSION=${{github.event.inputs.versionName}}" \ No newline at end of file From 4e1f1629a1dfe9b86eb28540cca7f4cae9283758 Mon Sep 17 00:00:00 2001 From: Marcel Baumgartner Date: Sun, 30 Jun 2024 02:22:47 +0200 Subject: [PATCH 17/20] Updated workflows (again) --- .github/workflows/development-build.yml | 9 +++------ .github/workflows/release-build.yml | 8 ++++---- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/.github/workflows/development-build.yml b/.github/workflows/development-build.yml index 5670ad92..002b1c63 100644 --- a/.github/workflows/development-build.yml +++ b/.github/workflows/development-build.yml @@ -11,9 +11,6 @@ jobs: build: runs-on: ubuntu-latest steps: - - name: Get current date - id: date - run: echo "::set-output name=date::$(date +'%Y-%m-%d')" - name: Checkout code uses: actions/checkout@v4 - name: Set up Docker Buildx @@ -29,7 +26,7 @@ jobs: tags: moonlightpanel/moonlight:dev platforms: linux/amd64,linux/arm64 build-args: | - "BUILD_CHANNEL=${{github.ref_name}}" - "BUILD_COMMIT_HASH=${{github.sha}} - "BUILD_NAME=devbuild ${{steps.date.outputs.date}}" + "BUILD_CHANNEL=${{ github.ref_name }}" + "BUILD_COMMIT_HASH=${{ github.sha }} + "BUILD_NAME=devbuild" "BUILD_VERSION=unknown" diff --git a/.github/workflows/release-build.yml b/.github/workflows/release-build.yml index 027b5c4e..51e24f49 100644 --- a/.github/workflows/release-build.yml +++ b/.github/workflows/release-build.yml @@ -29,7 +29,7 @@ jobs: tags: moonlightpanel/moonlight:latest platforms: linux/amd64,linux/arm64 build-args: | - "BUILD_CHANNEL=${{github.ref_name}}" - "BUILD_COMMIT_HASH=${{github.sha}} - "BUILD_NAME=${{github.event.inputs.codeName}}" - "BUILD_VERSION=${{github.event.inputs.versionName}}" \ No newline at end of file + "BUILD_CHANNEL=${{ github.ref_name }}" + "BUILD_COMMIT_HASH=${{ github.sha }} + "BUILD_NAME=${{ github.event.inputs.codeName }}" + "BUILD_VERSION=${{ github.event.inputs.versionName }}" \ No newline at end of file From 20b67eafe13f5b335f08ad3fdcfad2dcfd5f3bb7 Mon Sep 17 00:00:00 2001 From: Marcel Baumgartner Date: Sun, 30 Jun 2024 02:32:57 +0200 Subject: [PATCH 18/20] Fixed typo and added dates back to devbuild workflow --- .github/workflows/development-build.yml | 7 +++++-- .github/workflows/release-build.yml | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/.github/workflows/development-build.yml b/.github/workflows/development-build.yml index 002b1c63..badedd9d 100644 --- a/.github/workflows/development-build.yml +++ b/.github/workflows/development-build.yml @@ -11,6 +11,9 @@ jobs: build: runs-on: ubuntu-latest steps: + - name: Get current date + id: date + run: echo "::set-output name=date::$(date +'%Y-%m-%d')" - name: Checkout code uses: actions/checkout@v4 - name: Set up Docker Buildx @@ -27,6 +30,6 @@ jobs: platforms: linux/amd64,linux/arm64 build-args: | "BUILD_CHANNEL=${{ github.ref_name }}" - "BUILD_COMMIT_HASH=${{ github.sha }} - "BUILD_NAME=devbuild" + "BUILD_COMMIT_HASH=${{ github.sha }}" + "BUILD_NAME=devbuild ${{ steps.date.outputs.date }}" "BUILD_VERSION=unknown" diff --git a/.github/workflows/release-build.yml b/.github/workflows/release-build.yml index 51e24f49..bc57204f 100644 --- a/.github/workflows/release-build.yml +++ b/.github/workflows/release-build.yml @@ -30,6 +30,6 @@ jobs: platforms: linux/amd64,linux/arm64 build-args: | "BUILD_CHANNEL=${{ github.ref_name }}" - "BUILD_COMMIT_HASH=${{ github.sha }} + "BUILD_COMMIT_HASH=${{ github.sha }}" "BUILD_NAME=${{ github.event.inputs.codeName }}" "BUILD_VERSION=${{ github.event.inputs.versionName }}" \ No newline at end of file From 1cca9457ee21f19f65ee22cdf13f5b6179a38485 Mon Sep 17 00:00:00 2001 From: Marcel Baumgartner Date: Sun, 30 Jun 2024 02:35:35 +0200 Subject: [PATCH 19/20] Reduced commit hash string in ui --- Moonlight/Core/UI/Views/Admin/Sys/Index.razor | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Moonlight/Core/UI/Views/Admin/Sys/Index.razor b/Moonlight/Core/UI/Views/Admin/Sys/Index.razor index ea40262c..2b93873b 100644 --- a/Moonlight/Core/UI/Views/Admin/Sys/Index.razor +++ b/Moonlight/Core/UI/Views/Admin/Sys/Index.razor @@ -48,7 +48,7 @@
@{ - var commitText = $"{MoonlightService.BuildCommitHash}"; // TODO: Add update check (possible during startup, with error handling etc) + var commitText = $"{MoonlightService.BuildCommitHash.Substring(0, 6)}"; // TODO: Add update check (possible during startup, with error handling etc) } From 1eb63d7a8c1bc9860f878fa45a3d0fca6d942948 Mon Sep 17 00:00:00 2001 From: Marcel Baumgartner Date: Sun, 30 Jun 2024 02:47:48 +0200 Subject: [PATCH 20/20] Adjusted the length of the commit sha to look like on github --- Moonlight/Core/UI/Views/Admin/Sys/Index.razor | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Moonlight/Core/UI/Views/Admin/Sys/Index.razor b/Moonlight/Core/UI/Views/Admin/Sys/Index.razor index 2b93873b..0c88b743 100644 --- a/Moonlight/Core/UI/Views/Admin/Sys/Index.razor +++ b/Moonlight/Core/UI/Views/Admin/Sys/Index.razor @@ -48,7 +48,7 @@
@{ - var commitText = $"{MoonlightService.BuildCommitHash.Substring(0, 6)}"; // TODO: Add update check (possible during startup, with error handling etc) + var commitText = $"{MoonlightService.BuildCommitHash.Substring(0, 7)}"; // TODO: Add update check (possible during startup, with error handling etc) }