Added docker
This commit is contained in:
@@ -43,27 +43,29 @@
|
||||
}
|
||||
|
||||
private async void Initialize()
|
||||
{
|
||||
_DiscordBotStartup.Log += async (str, type) => {
|
||||
{
|
||||
_DiscordBotStartup.Log = async (str, type) => {
|
||||
_TextValue += $"[{type}] {str} \n";
|
||||
await InvokeAsync(StateHasChanged);
|
||||
};
|
||||
|
||||
dynamic result = _DiscordBotStartup.LoadComponents();
|
||||
|
||||
if (!result)
|
||||
{
|
||||
result = await DialogService.OpenAsync<Settings>("Please complete this setup before starting the bot", new Dictionary<string, object>()
|
||||
{
|
||||
{"OnSaveChanged", () => {DialogService.Close(true);}}
|
||||
});
|
||||
|
||||
if (result != true)
|
||||
{
|
||||
Environment.Exit(0);
|
||||
}
|
||||
Console.WriteLine(str);
|
||||
};
|
||||
|
||||
if (_DiscordBotStartup.LoadComponents())
|
||||
{
|
||||
await _DiscordBotStartup.PrepareBot();
|
||||
await _DiscordBotStartup.RefreshPlugins(false);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
while (await DialogService.OpenAsync<Settings>("Please complete this setup before starting the bot") == false)
|
||||
{
|
||||
Console.WriteLine("Failed to complete the setup. Invalid data acquired ...");
|
||||
}
|
||||
|
||||
|
||||
|
||||
await _DiscordBotStartup.PrepareBot();
|
||||
await _DiscordBotStartup.RefreshPlugins(false);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
@page "/settings"
|
||||
@using DiscordBotCore
|
||||
@inject NotificationService NotificationService
|
||||
@inject DialogService DialogService
|
||||
|
||||
<RadzenPanel>
|
||||
<HeaderTemplate>
|
||||
@@ -44,9 +45,6 @@
|
||||
private string _Token = string.Empty;
|
||||
private string _Prefix = string.Empty;
|
||||
private string _ServerIds = string.Empty;
|
||||
|
||||
[Parameter]
|
||||
public Action? OnSaveChanged { get; set; }
|
||||
|
||||
protected override void OnInitialized()
|
||||
{
|
||||
@@ -81,8 +79,11 @@
|
||||
|
||||
private async Task SaveChanges()
|
||||
{
|
||||
Application.CurrentApplication.ApplicationEnvironmentVariables.Set("token", _Token);
|
||||
Application.CurrentApplication.ApplicationEnvironmentVariables.Set("prefix", _Prefix);
|
||||
|
||||
if (_Prefix.Length != 1)
|
||||
{
|
||||
DialogService.Close(false);
|
||||
}
|
||||
|
||||
List<ulong> serverIds = new List<ulong>();
|
||||
string[] values = _ServerIds.Split('\n');
|
||||
@@ -94,14 +95,21 @@
|
||||
serverIds.Add(actualValue);
|
||||
}
|
||||
}
|
||||
|
||||
if (serverIds.Count == 0)
|
||||
{
|
||||
DialogService.Close(false);
|
||||
}
|
||||
|
||||
Application.CurrentApplication.ApplicationEnvironmentVariables.Set("token", _Token);
|
||||
Application.CurrentApplication.ApplicationEnvironmentVariables.Set("prefix", _Prefix);
|
||||
Application.CurrentApplication.ApplicationEnvironmentVariables.Set("ServerID", serverIds);
|
||||
|
||||
await Application.CurrentApplication.ApplicationEnvironmentVariables.SaveToFile();
|
||||
|
||||
NotificationService.Notify(NotificationSeverity.Success, "Configuration", "Configuration has been saved !", 4000);
|
||||
|
||||
OnSaveChanged?.Invoke();
|
||||
|
||||
DialogService.Close(true);
|
||||
}
|
||||
|
||||
private void ServerIDsValueChanged(string obj)
|
||||
|
||||
@@ -12,7 +12,6 @@
|
||||
@code {
|
||||
[Parameter]
|
||||
public ModuleRequirement Requirements { get; set; }
|
||||
|
||||
private List<MarketItem> MarketItems = new List<MarketItem>();
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
@@ -24,6 +25,9 @@
|
||||
|
||||
<ItemGroup>
|
||||
<Content Remove="Data\**" />
|
||||
<Content Include="..\.dockerignore">
|
||||
<Link>.dockerignore</Link>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
24
DiscordBotWebUI/Dockerfile
Normal file
24
DiscordBotWebUI/Dockerfile
Normal file
@@ -0,0 +1,24 @@
|
||||
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base
|
||||
USER $APP_UID
|
||||
WORKDIR /app
|
||||
EXPOSE 8080
|
||||
EXPOSE 8081
|
||||
|
||||
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
|
||||
ARG BUILD_CONFIGURATION=Release
|
||||
WORKDIR /src
|
||||
COPY ["DiscordBotWebUI/DiscordBotWebUI.csproj", "DiscordBotWebUI/"]
|
||||
COPY ["DiscordBotCore/DiscordBotCore.csproj", "DiscordBotCore/"]
|
||||
RUN dotnet restore "DiscordBotWebUI/DiscordBotWebUI.csproj"
|
||||
COPY . .
|
||||
WORKDIR "/src/DiscordBotWebUI"
|
||||
RUN dotnet build "DiscordBotWebUI.csproj" -c $BUILD_CONFIGURATION -o /app/build
|
||||
|
||||
FROM build AS publish
|
||||
ARG BUILD_CONFIGURATION=Release
|
||||
RUN dotnet publish "DiscordBotWebUI.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false
|
||||
|
||||
FROM base AS final
|
||||
WORKDIR /app
|
||||
COPY --from=publish /app/publish .
|
||||
ENTRYPOINT ["dotnet", "DiscordBotWebUI.dll"]
|
||||
Reference in New Issue
Block a user