Added Dockerfile for debugging on Linux hosts
This commit is contained in:
parent
b1514c208e
commit
d146406e5d
8 changed files with 66 additions and 6 deletions
|
@ -7,6 +7,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EllieHub", "EllieHub\EllieH
|
||||||
EndProject
|
EndProject
|
||||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{2A553F1B-5A2C-43D6-A145-F219530326D3}"
|
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{2A553F1B-5A2C-43D6-A145-F219530326D3}"
|
||||||
ProjectSection(SolutionItems) = preProject
|
ProjectSection(SolutionItems) = preProject
|
||||||
|
EllieHub\.dockerignore = EllieHub\.dockerignore
|
||||||
|
EllieHub\Dockerfile = EllieHub\Dockerfile
|
||||||
release.ps1 = release.ps1
|
release.ps1 = release.ps1
|
||||||
EndProjectSection
|
EndProjectSection
|
||||||
EndProject
|
EndProject
|
||||||
|
|
39
EllieHub/.dockerignore
Normal file
39
EllieHub/.dockerignore
Normal file
|
@ -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
|
|
@ -18,5 +18,5 @@ public static class AppConstants
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The name for an <see cref="HttpClient"/> that makes calls to the Toastielab API.
|
/// The name for an <see cref="HttpClient"/> that makes calls to the Toastielab API.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public const string ToastielabClient = "NoRedirect";
|
public const string ToastielabClient = "ToastielabClient";
|
||||||
}
|
}
|
19
EllieHub/Dockerfile
Normal file
19
EllieHub/Dockerfile
Normal file
|
@ -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"]
|
|
@ -39,7 +39,7 @@ public sealed class FfmpegWindowsResolver : FfmpegResolver
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override async ValueTask<string> GetLatestVersionAsync(CancellationToken cToken = default)
|
public override async ValueTask<string> 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);
|
var response = await http.GetAsync("https://github.com/GyanD/codexffmpeg/releases/latest", cToken);
|
||||||
|
|
||||||
|
|
|
@ -85,7 +85,7 @@ public sealed class YtdlpResolver : IYtdlpResolver
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public async ValueTask<string> GetLatestVersionAsync(CancellationToken cToken = default)
|
public async ValueTask<string> 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);
|
var response = await http.GetAsync("https://github.com/yt-dlp/yt-dlp/releases/latest", cToken);
|
||||||
|
|
||||||
|
|
|
@ -254,7 +254,7 @@ public sealed partial class EllieResolver : IBotResolver
|
||||||
using var zipFile = ZipFile.OpenRead(backupFileUri);
|
using var zipFile = ZipFile.OpenRead(backupFileUri);
|
||||||
var zippedFiles = zipFile.Entries
|
var zippedFiles = zipFile.Entries
|
||||||
.Where(x =>
|
.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/"))
|
|| (!string.IsNullOrWhiteSpace(x.Name) && x.FullName.Contains("data/") && !x.FullName.Contains("strings/"))
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -229,11 +229,11 @@ public sealed class AppResolver : IAppResolver
|
||||||
/// <exception cref="InvalidOperationException">Occurs when parsing of the response fails.</exception>
|
/// <exception cref="InvalidOperationException">Occurs when parsing of the response fails.</exception>
|
||||||
private async ValueTask<string> GetLatestVersionFromUrlAsync(CancellationToken cToken = default)
|
private async ValueTask<string> GetLatestVersionFromUrlAsync(CancellationToken cToken = default)
|
||||||
{
|
{
|
||||||
var http = _httpClientFactory.CreateClient(AppConstants.NoRedirectClient);
|
var http = _httpClientFactory.CreateClient(AppConstants.ToastielabClient);
|
||||||
var response = await http.GetAsync(_toastielabReleasesRepoUrl, cToken);
|
var response = await http.GetAsync(_toastielabReleasesRepoUrl, cToken);
|
||||||
|
|
||||||
var lastSlashIndex = response.Headers.Location?.OriginalString.LastIndexOf('/')
|
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)..];
|
return response.Headers.Location.OriginalString[(lastSlashIndex + 1)..];
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue