diff --git a/EllieHub.sln b/EllieHub.sln index ec52221..c9486a5 100644 --- a/EllieHub.sln +++ b/EllieHub.sln @@ -7,6 +7,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EllieHub", "EllieHub\EllieH EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{2A553F1B-5A2C-43D6-A145-F219530326D3}" ProjectSection(SolutionItems) = preProject + EllieHub\.dockerignore = EllieHub\.dockerignore + EllieHub\Dockerfile = EllieHub\Dockerfile release.ps1 = release.ps1 EndProjectSection EndProject diff --git a/EllieHub/.dockerignore b/EllieHub/.dockerignore new file mode 100644 index 0000000..fe15679 --- /dev/null +++ b/EllieHub/.dockerignore @@ -0,0 +1,39 @@ +# .NET +**/bin/ +**/obj/ +**/out/ + +# Node +**/node_modules/ +**/npm-debug.log +**/dist/ + +# Version control +.git +.gitignore + +# IDEs +**/.vscode/ +**/.idea/ +**/*.swp +**/*.swo + +# Environment files +**/.env +**/.env.local +**/.env.* + +# Testing +**/coverage +**/*.test.js + +# OS files +**/.DS_Store + +# Files +Dockerfile* +**/*.trx +**/*.md +**/*.ps1 +**/*.cmd +**/*.sh \ No newline at end of file diff --git a/EllieHub/Common/AppConstants.cs b/EllieHub/Common/AppConstants.cs index c5bfb08..2d703af 100644 --- a/EllieHub/Common/AppConstants.cs +++ b/EllieHub/Common/AppConstants.cs @@ -18,5 +18,5 @@ public static class AppConstants /// /// The name for an that makes calls to the Toastielab API. /// - public const string ToastielabClient = "NoRedirect"; + public const string ToastielabClient = "ToastielabClient"; } \ No newline at end of file diff --git a/EllieHub/Dockerfile b/EllieHub/Dockerfile new file mode 100644 index 0000000..e62644f --- /dev/null +++ b/EllieHub/Dockerfile @@ -0,0 +1,19 @@ +# Please, see the following url: https://toastielab.dev/EllieBotDevs/EllieHub/wiki/Docker +FROM--platform =$BUILDPLATFORM mcr.microsoft.com / dotnet / sdk:9.0 AS base +WORKDIR / +RUN apt-get update \ + && apt-get install -y libsm-dev libice-dev libx11-dev fontconfig \ + && rm -rf /var/lib/apt/lists/* \ + && useradd -m -u 1000 elliehub_user +FROM base AS publish +ARG DOTNET_BUILD=Debug +WORKDIR /home/elliehub_user/src +COPY . . +ADD https://toastielab.dev/EllieBotDevs/EllieHub/raw/branch/main/.editorconfig .editorconfig +RUN dotnet publish "EllieHub.csproj" -c $DOTNET_BUILD -o /home/elliehub_user/app /p:SelfContained=false /p:PublishSingleFile=false /p:IncludeNativeLibrariesForSelfExtract=false \ + && chown -R elliehub_user:elliehub_user /home/elliehub_user +FROM base AS final +USER elliehub_user +WORKDIR /home/elliehub_user/app +COPY --from=publish /home/elliehub_user/app . +ENTRYPOINT ["dotnet", "EllieHub.dll"] \ No newline at end of file diff --git a/EllieHub/Features/AppConfig/Services/FfmpegWindowsResolver.cs b/EllieHub/Features/AppConfig/Services/FfmpegWindowsResolver.cs index 846c8da..6a9e0e8 100644 --- a/EllieHub/Features/AppConfig/Services/FfmpegWindowsResolver.cs +++ b/EllieHub/Features/AppConfig/Services/FfmpegWindowsResolver.cs @@ -39,7 +39,7 @@ public sealed class FfmpegWindowsResolver : FfmpegResolver /// public override async ValueTask GetLatestVersionAsync(CancellationToken cToken = default) { - var http = _httpClientFactory.CreateClient(AppConstants.NoRedirectClient); + var http = _httpClientFactory.CreateClient(AppConstants.ToastielabClient); var response = await http.GetAsync("https://github.com/GyanD/codexffmpeg/releases/latest", cToken); diff --git a/EllieHub/Features/AppConfig/Services/YtdlpResolver.cs b/EllieHub/Features/AppConfig/Services/YtdlpResolver.cs index ee8b40c..1ce589a 100644 --- a/EllieHub/Features/AppConfig/Services/YtdlpResolver.cs +++ b/EllieHub/Features/AppConfig/Services/YtdlpResolver.cs @@ -85,7 +85,7 @@ public sealed class YtdlpResolver : IYtdlpResolver /// public async ValueTask GetLatestVersionAsync(CancellationToken cToken = default) { - var http = _httpClientFactory.CreateClient(AppConstants.NoRedirectClient); + var http = _httpClientFactory.CreateClient(AppConstants.ToastielabClient); var response = await http.GetAsync("https://github.com/yt-dlp/yt-dlp/releases/latest", cToken); diff --git a/EllieHub/Features/BotConfig/Services/EllieResolver.cs b/EllieHub/Features/BotConfig/Services/EllieResolver.cs index 7c92fbd..085e9c0 100644 --- a/EllieHub/Features/BotConfig/Services/EllieResolver.cs +++ b/EllieHub/Features/BotConfig/Services/EllieResolver.cs @@ -254,7 +254,7 @@ public sealed partial class EllieResolver : IBotResolver using var zipFile = ZipFile.OpenRead(backupFileUri); var zippedFiles = zipFile.Entries .Where(x => - x.Name is "creds.yml" // Restore creds.yml and everything in the "data" folder, except the stuff in the "strings" folder. + x.Name is "creds.yml" // Restore creds.yml and everything in the "data" folder, but not the stuff in the "strings" folder. || (!string.IsNullOrWhiteSpace(x.Name) && x.FullName.Contains("data/") && !x.FullName.Contains("strings/")) ); diff --git a/EllieHub/Features/Home/Services/AppResolver.cs b/EllieHub/Features/Home/Services/AppResolver.cs index 6400cb1..bd540f7 100644 --- a/EllieHub/Features/Home/Services/AppResolver.cs +++ b/EllieHub/Features/Home/Services/AppResolver.cs @@ -229,11 +229,11 @@ public sealed class AppResolver : IAppResolver /// Occurs when parsing of the response fails. private async ValueTask GetLatestVersionFromUrlAsync(CancellationToken cToken = default) { - var http = _httpClientFactory.CreateClient(AppConstants.NoRedirectClient); + var http = _httpClientFactory.CreateClient(AppConstants.ToastielabClient); var response = await http.GetAsync(_toastielabReleasesRepoUrl, cToken); var lastSlashIndex = response.Headers.Location?.OriginalString.LastIndexOf('/') - ?? throw new InvalidOperationException("Failed to get the latest EllieBot version."); + ?? throw new InvalidOperationException("Failed to get the latest EllieHub version."); return response.Headers.Location.OriginalString[(lastSlashIndex + 1)..]; }