Added docker
This commit is contained in:
@@ -0,0 +1,25 @@
|
|||||||
|
**/.dockerignore
|
||||||
|
**/.env
|
||||||
|
**/.git
|
||||||
|
**/.gitignore
|
||||||
|
**/.project
|
||||||
|
**/.settings
|
||||||
|
**/.toolstarget
|
||||||
|
**/.vs
|
||||||
|
**/.vscode
|
||||||
|
**/.idea
|
||||||
|
**/*.*proj.user
|
||||||
|
**/*.dbmdl
|
||||||
|
**/*.jfm
|
||||||
|
**/azds.yaml
|
||||||
|
**/bin
|
||||||
|
**/charts
|
||||||
|
**/docker-compose*
|
||||||
|
**/Dockerfile*
|
||||||
|
**/node_modules
|
||||||
|
**/npm-debug.log
|
||||||
|
**/obj
|
||||||
|
**/secrets.dev.yaml
|
||||||
|
**/values.dev.yaml
|
||||||
|
LICENSE
|
||||||
|
README.md
|
||||||
@@ -44,26 +44,28 @@
|
|||||||
|
|
||||||
private async void Initialize()
|
private async void Initialize()
|
||||||
{
|
{
|
||||||
_DiscordBotStartup.Log += async (str, type) => {
|
_DiscordBotStartup.Log = async (str, type) => {
|
||||||
_TextValue += $"[{type}] {str} \n";
|
_TextValue += $"[{type}] {str} \n";
|
||||||
await InvokeAsync(StateHasChanged);
|
await InvokeAsync(StateHasChanged);
|
||||||
|
|
||||||
|
Console.WriteLine(str);
|
||||||
};
|
};
|
||||||
|
|
||||||
dynamic result = _DiscordBotStartup.LoadComponents();
|
if (_DiscordBotStartup.LoadComponents())
|
||||||
|
{
|
||||||
|
await _DiscordBotStartup.PrepareBot();
|
||||||
|
await _DiscordBotStartup.RefreshPlugins(false);
|
||||||
|
|
||||||
if (!result)
|
return;
|
||||||
{
|
}
|
||||||
result = await DialogService.OpenAsync<Settings>("Please complete this setup before starting the bot", new Dictionary<string, object>()
|
|
||||||
{
|
|
||||||
{"OnSaveChanged", () => {DialogService.Close(true);}}
|
|
||||||
});
|
|
||||||
|
|
||||||
if (result != true)
|
while (await DialogService.OpenAsync<Settings>("Please complete this setup before starting the bot") == false)
|
||||||
{
|
{
|
||||||
Environment.Exit(0);
|
Console.WriteLine("Failed to complete the setup. Invalid data acquired ...");
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
await _DiscordBotStartup.PrepareBot();
|
await _DiscordBotStartup.PrepareBot();
|
||||||
await _DiscordBotStartup.RefreshPlugins(false);
|
await _DiscordBotStartup.RefreshPlugins(false);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
@page "/settings"
|
@page "/settings"
|
||||||
@using DiscordBotCore
|
@using DiscordBotCore
|
||||||
@inject NotificationService NotificationService
|
@inject NotificationService NotificationService
|
||||||
|
@inject DialogService DialogService
|
||||||
|
|
||||||
<RadzenPanel>
|
<RadzenPanel>
|
||||||
<HeaderTemplate>
|
<HeaderTemplate>
|
||||||
@@ -45,9 +46,6 @@
|
|||||||
private string _Prefix = string.Empty;
|
private string _Prefix = string.Empty;
|
||||||
private string _ServerIds = string.Empty;
|
private string _ServerIds = string.Empty;
|
||||||
|
|
||||||
[Parameter]
|
|
||||||
public Action? OnSaveChanged { get; set; }
|
|
||||||
|
|
||||||
protected override void OnInitialized()
|
protected override void OnInitialized()
|
||||||
{
|
{
|
||||||
base.OnInitialized();
|
base.OnInitialized();
|
||||||
@@ -81,8 +79,11 @@
|
|||||||
|
|
||||||
private async Task SaveChanges()
|
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>();
|
List<ulong> serverIds = new List<ulong>();
|
||||||
string[] values = _ServerIds.Split('\n');
|
string[] values = _ServerIds.Split('\n');
|
||||||
@@ -95,13 +96,20 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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);
|
Application.CurrentApplication.ApplicationEnvironmentVariables.Set("ServerID", serverIds);
|
||||||
|
|
||||||
await Application.CurrentApplication.ApplicationEnvironmentVariables.SaveToFile();
|
await Application.CurrentApplication.ApplicationEnvironmentVariables.SaveToFile();
|
||||||
|
|
||||||
NotificationService.Notify(NotificationSeverity.Success, "Configuration", "Configuration has been saved !", 4000);
|
NotificationService.Notify(NotificationSeverity.Success, "Configuration", "Configuration has been saved !", 4000);
|
||||||
|
|
||||||
OnSaveChanged?.Invoke();
|
DialogService.Close(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ServerIDsValueChanged(string obj)
|
private void ServerIDsValueChanged(string obj)
|
||||||
|
|||||||
@@ -12,7 +12,6 @@
|
|||||||
@code {
|
@code {
|
||||||
[Parameter]
|
[Parameter]
|
||||||
public ModuleRequirement Requirements { get; set; }
|
public ModuleRequirement Requirements { get; set; }
|
||||||
|
|
||||||
private List<MarketItem> MarketItems = new List<MarketItem>();
|
private List<MarketItem> MarketItems = new List<MarketItem>();
|
||||||
|
|
||||||
protected override async Task OnInitializedAsync()
|
protected override async Task OnInitializedAsync()
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
<TargetFramework>net8.0</TargetFramework>
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
@@ -24,6 +25,9 @@
|
|||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Content Remove="Data\**" />
|
<Content Remove="Data\**" />
|
||||||
|
<Content Include="..\.dockerignore">
|
||||||
|
<Link>.dockerignore</Link>
|
||||||
|
</Content>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
@@ -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"]
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
using DiscordBotCore;
|
using DiscordBotCore;
|
||||||
using DiscordBotCore.Interfaces.Modules;
|
using DiscordBotCore.Interfaces.Modules;
|
||||||
using DiscordBotCore.Others;
|
using DiscordBotCore.Others;
|
||||||
|
|
||||||
@@ -26,13 +26,14 @@ public class Entry : IModule
|
|||||||
|
|
||||||
public Guid CreateApplication(string dllFilePath)
|
public Guid CreateApplication(string dllFilePath)
|
||||||
{
|
{
|
||||||
if(_ExternalApplicationManager is null)
|
|
||||||
|
if (_ExternalApplicationManager is null)
|
||||||
{
|
{
|
||||||
Application.Logger.Log("Failed to create application because the manager is not initialized. This should have never happened in the first place !!!", this, LogType.Critical);
|
Application.Logger.Log("Failed to create application because the manager is not initialized. This should have never happened in the first place !!!", this, LogType.Critical);
|
||||||
return Guid.Empty;
|
return Guid.Empty;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(_ExternalApplicationManager.TryCreateApplication(dllFilePath, out Guid appId))
|
if (_ExternalApplicationManager.TryCreateApplication(dllFilePath, out Guid appId))
|
||||||
{
|
{
|
||||||
return appId;
|
return appId;
|
||||||
}
|
}
|
||||||
@@ -42,7 +43,7 @@ public class Entry : IModule
|
|||||||
|
|
||||||
public void StopApplication(Guid applicationId)
|
public void StopApplication(Guid applicationId)
|
||||||
{
|
{
|
||||||
if(_ExternalApplicationManager is null)
|
if (_ExternalApplicationManager is null)
|
||||||
{
|
{
|
||||||
Application.Logger.Log("Failed to stop application because the manager is not initialized. This should have never happened in the first place!!!", this, LogType.Critical);
|
Application.Logger.Log("Failed to stop application because the manager is not initialized. This should have never happened in the first place!!!", this, LogType.Critical);
|
||||||
return;
|
return;
|
||||||
@@ -53,7 +54,7 @@ public class Entry : IModule
|
|||||||
|
|
||||||
public void CallFunctionWithParameter(Guid appId, string functionName, ref object parameter)
|
public void CallFunctionWithParameter(Guid appId, string functionName, ref object parameter)
|
||||||
{
|
{
|
||||||
if(_ExternalApplicationManager is null)
|
if (_ExternalApplicationManager is null)
|
||||||
{
|
{
|
||||||
Application.Logger.Log("Failed to call function because the manager is not initialized. This should have never happened in the first place!!!", this, LogType.Critical);
|
Application.Logger.Log("Failed to call function because the manager is not initialized. This should have never happened in the first place!!!", this, LogType.Critical);
|
||||||
return;
|
return;
|
||||||
@@ -64,7 +65,7 @@ public class Entry : IModule
|
|||||||
|
|
||||||
public void CallFunctionWithoutParameter(Guid appId, string functionName)
|
public void CallFunctionWithoutParameter(Guid appId, string functionName)
|
||||||
{
|
{
|
||||||
if(_ExternalApplicationManager is null)
|
if (_ExternalApplicationManager is null)
|
||||||
{
|
{
|
||||||
Application.Logger.Log("Failed to call function because the manager is not initialized. This should have never happened in the first place!!!", this, LogType.Critical);
|
Application.Logger.Log("Failed to call function because the manager is not initialized. This should have never happened in the first place!!!", this, LogType.Critical);
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -32,6 +32,11 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DiscordBotWebUI", "DiscordB
|
|||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CppCompatibilityModule", "Modules\CppCompatibilityModule\CppCompatibilityModule.csproj", "{C67908F9-4A55-4DD8-B993-C26C648226F1}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CppCompatibilityModule", "Modules\CppCompatibilityModule\CppCompatibilityModule.csproj", "{C67908F9-4A55-4DD8-B993-C26C648226F1}"
|
||||||
EndProject
|
EndProject
|
||||||
|
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{6D42702D-C449-40FD-9AE6-3FC407923A8B}"
|
||||||
|
ProjectSection(SolutionItems) = preProject
|
||||||
|
docker-compose.yml = docker-compose.yml
|
||||||
|
EndProjectSection
|
||||||
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Any CPU = Debug|Any CPU
|
Debug|Any CPU = Debug|Any CPU
|
||||||
|
|||||||
@@ -0,0 +1,6 @@
|
|||||||
|
services:
|
||||||
|
discordbotwebui:
|
||||||
|
image: discordbotwebui
|
||||||
|
build:
|
||||||
|
context: .
|
||||||
|
dockerfile: DiscordBotWebUI/Dockerfile
|
||||||
Reference in New Issue
Block a user