Updated docker and repo check for no internet connection

This commit is contained in:
2025-01-14 12:44:07 +02:00
parent 7ebe3e7014
commit 8b2169dc7b
13 changed files with 178 additions and 22 deletions

View File

@@ -11,6 +11,7 @@
<PublishAot>False</PublishAot>
<FileVersion>1.0.4.0</FileVersion>
<IsPackable>false</IsPackable>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<DebugType>full</DebugType>
@@ -42,4 +43,9 @@
<ItemGroup>
<ProjectReference Include="..\DiscordBotCore\DiscordBotCore.csproj" />
</ItemGroup>
<ItemGroup>
<Content Include="..\.dockerignore">
<Link>.dockerignore</Link>
</Content>
</ItemGroup>
</Project>

24
DiscordBot/Dockerfile Normal file
View File

@@ -0,0 +1,24 @@
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base
USER $APP_UID
WORKDIR /app
EXPOSE 5055
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
ARG BUILD_CONFIGURATION=Release
WORKDIR /src
COPY ["DiscordBot/DiscordBot.csproj", "DiscordBot/"]
COPY ["DiscordBotCore/DiscordBotCore.csproj", "DiscordBotCore/"]
RUN dotnet restore "DiscordBot/DiscordBot.csproj"
COPY . .
WORKDIR "/src/DiscordBot"
RUN dotnet build "DiscordBot.csproj" -c $BUILD_CONFIGURATION -o /app/build
FROM build AS publish
ARG BUILD_CONFIGURATION=Release
RUN dotnet publish "DiscordBot.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
EXPOSE 5055
ENTRYPOINT ["dotnet", "DiscordBot.dll"]

View File

@@ -24,6 +24,7 @@ public class Program
await LoadComponents(args);
await PrepareConsole();
await PluginMethods.RefreshPlugins(false);
await ConsoleInputHandler();
}
@@ -55,7 +56,6 @@ public class Program
AnsiConsole.MarkupLine("[yellow]Git SethBot: https://github.com/andreitdr/SethDiscordBot [/]");
AnsiConsole.MarkupLine("[yellow]Remember to close the bot using the shutdown command ([/][red]exit[/][yellow]) or some settings won't be saved[/]");
AnsiConsole.MarkupLine($"[yellow]Running on [/][magenta]{(OperatingSystem.IsWindows() ? "Windows" : "Linux")}[/]");
AnsiConsole.MarkupLine("[yellow]===== Seth Discord Bot =====[/]");
@@ -118,7 +118,9 @@ public class Program
if (!Application.CurrentApplication.ApplicationEnvironmentVariables.ContainsKey("ServerID") ||
!Application.CurrentApplication.ApplicationEnvironmentVariables.ContainsKey("token") ||
!Application.CurrentApplication.ApplicationEnvironmentVariables.ContainsKey("prefix"))
{
await Installer.GenerateStartupConfig();
}
if (args.Length > 0)
{
@@ -127,7 +129,7 @@ public class Program
if(args.Contains("--socket-api"))
Application.InitializeThreadedSockets();
}
}