mirror of
https://github.com/Tyrrrz/DiscordChatExporter.git
synced 2025-05-22 10:55:15 -04:00
Use Alpine as the base image in docker, publish a self-contained app (#974)
This commit is contained in:
parent
fc07f8da6c
commit
db45b49af7
2 changed files with 27 additions and 9 deletions
|
@ -1,5 +1,7 @@
|
||||||
# Build
|
# Build
|
||||||
FROM mcr.microsoft.com/dotnet/sdk:7.0 AS build
|
FROM mcr.microsoft.com/dotnet/sdk:7.0-alpine AS build
|
||||||
|
|
||||||
|
WORKDIR /build
|
||||||
|
|
||||||
COPY favicon.ico ./
|
COPY favicon.ico ./
|
||||||
COPY NuGet.config ./
|
COPY NuGet.config ./
|
||||||
|
@ -7,16 +9,30 @@ COPY Directory.Build.props ./
|
||||||
COPY DiscordChatExporter.Core ./DiscordChatExporter.Core
|
COPY DiscordChatExporter.Core ./DiscordChatExporter.Core
|
||||||
COPY DiscordChatExporter.Cli ./DiscordChatExporter.Cli
|
COPY DiscordChatExporter.Cli ./DiscordChatExporter.Cli
|
||||||
|
|
||||||
RUN dotnet publish DiscordChatExporter.Cli --configuration Release --output ./publish
|
RUN dotnet publish DiscordChatExporter.Cli \
|
||||||
|
--self-contained \
|
||||||
|
--use-current-runtime \
|
||||||
|
--configuration Release \
|
||||||
|
--output ./publish
|
||||||
|
|
||||||
# Run
|
# Run
|
||||||
FROM mcr.microsoft.com/dotnet/runtime:7.0 AS run
|
FROM mcr.microsoft.com/dotnet/runtime-deps:7.0-alpine
|
||||||
|
|
||||||
RUN useradd dce
|
# tzdata is needed for DateTimeOffset.ToLocalTime (for TimeZoneInfo.Local, to be precise)
|
||||||
|
RUN apk add --no-cache tzdata
|
||||||
|
RUN adduser \
|
||||||
|
--disabled-password \
|
||||||
|
--no-create-home \
|
||||||
|
dce
|
||||||
USER dce
|
USER dce
|
||||||
|
COPY --from=build /build/publish /opt/discord_chat_exporter
|
||||||
|
|
||||||
COPY --from=build ./publish ./
|
# Need to keep this as /out for backwards compatibility with documentation.
|
||||||
|
# A lot of people have this directory mounted in their scripts files, so
|
||||||
|
# changing it would break existing workflows.
|
||||||
|
WORKDIR /out
|
||||||
|
|
||||||
WORKDIR ./out
|
# Having it in PATH is convenient for interactive shell sessions,
|
||||||
|
# which may be useful for debugging.
|
||||||
ENTRYPOINT ["dotnet", "../DiscordChatExporter.Cli.dll"]
|
ENV PATH="$PATH:/opt/discord_chat_exporter"
|
||||||
|
ENTRYPOINT ["DiscordChatExporter.Cli"]
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Diagnostics.CodeAnalysis;
|
using System.Diagnostics.CodeAnalysis;
|
||||||
|
using System.Globalization;
|
||||||
|
|
||||||
namespace DiscordChatExporter.Core.Discord.Data.Common;
|
namespace DiscordChatExporter.Core.Discord.Data.Common;
|
||||||
|
|
||||||
|
@ -39,7 +40,8 @@ public readonly partial record struct FileSize(long TotalBytes)
|
||||||
}
|
}
|
||||||
|
|
||||||
[ExcludeFromCodeCoverage]
|
[ExcludeFromCodeCoverage]
|
||||||
public override string ToString() => $"{GetLargestWholeNumberValue():0.##} {GetLargestWholeNumberSymbol()}";
|
public override string ToString() =>
|
||||||
|
string.Create(CultureInfo.InvariantCulture, $"{GetLargestWholeNumberValue():0.##} {GetLargestWholeNumberSymbol()}");
|
||||||
}
|
}
|
||||||
|
|
||||||
public partial record struct FileSize
|
public partial record struct FileSize
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue