diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..cd967fc --- /dev/null +++ b/.dockerignore @@ -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 \ No newline at end of file diff --git a/BattleBitMiniGames.sln b/BattleBitMiniGames.sln new file mode 100644 index 0000000..4a05136 --- /dev/null +++ b/BattleBitMiniGames.sln @@ -0,0 +1,15 @@ +Microsoft Visual Studio Solution File, Format Version 12.00 +Project("{FA8F5709-D424-4435-AB63-E82CD78AFC05}") = "BattleBitMinigames", "BattleBitMinigames.csproj", "{AAECC0BF-4E85-4B20-AA90-11BC73D21F20}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {AAECC0BF-4E85-4B20-AA90-11BC73D21F20}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {AAECC0BF-4E85-4B20-AA90-11BC73D21F20}.Debug|Any CPU.Build.0 = Debug|Any CPU + {AAECC0BF-4E85-4B20-AA90-11BC73D21F20}.Release|Any CPU.ActiveCfg = Release|Any CPU + {AAECC0BF-4E85-4B20-AA90-11BC73D21F20}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection +EndGlobal \ No newline at end of file diff --git a/BattleBitMinigames.csproj b/BattleBitMinigames.csproj index ed6f5f1..3159c13 100644 --- a/BattleBitMinigames.csproj +++ b/BattleBitMinigames.csproj @@ -5,6 +5,7 @@ enable enable BattleBitMinigames + Linux diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..1cb6f1f --- /dev/null +++ b/Dockerfile @@ -0,0 +1,20 @@ +FROM mcr.microsoft.com/dotnet/runtime:6.0 AS base +WORKDIR /app + +FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build +ARG BUILD_CONFIGURATION=Release +WORKDIR /src +COPY ["BattleBitMinigames.csproj", "./"] +RUN dotnet restore "BattleBitMinigames.csproj" +COPY . . +WORKDIR "/src/" +RUN dotnet build "BattleBitMinigames.csproj" -c $BUILD_CONFIGURATION -o /app/build + +FROM build AS publish +ARG BUILD_CONFIGURATION=Release +RUN dotnet publish "BattleBitMinigames.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false + +FROM base AS final +WORKDIR /app +COPY --from=publish /app/publish . +ENTRYPOINT ["dotnet", "BattleBitMinigames.dll"] diff --git a/Handlers/ConsoleCommandHandler.cs b/Handlers/ConsoleCommandHandler.cs index 8ddfc9d..e0d161d 100644 --- a/Handlers/ConsoleCommandHandler.cs +++ b/Handlers/ConsoleCommandHandler.cs @@ -2,16 +2,16 @@ namespace BattleBitMinigames.Handlers; -public class ConsoleCommandHandler +public static class ConsoleCommandHandler { - public void Listen() + public static void Listen() { while (true) { - string? command = Console.ReadLine(); + var command = Console.ReadLine(); if (command is null) { - Program.Logger.Warn("No std in stream available."); + Program.Logger.Warn("No stdin stream available."); Program.Logger.Error("Exiting..."); return; } @@ -22,12 +22,12 @@ public void Listen() continue; } - string[] commandParts = command.Split(" ", StringSplitOptions.RemoveEmptyEntries); + var commandParts = command.Split(" ", StringSplitOptions.RemoveEmptyEntries); if (commandParts.Length == 0) continue; - string commandName = commandParts[0]; + var commandName = commandParts[0]; - ConsoleCommand? consoleCommand = ConsoleCommandList.Commands.FirstOrDefault(c => c.Name == commandName); + var consoleCommand = ConsoleCommandList.Commands.FirstOrDefault(c => c.Name == commandName); if (consoleCommand == null) { Program.Logger.Error($"Command {commandName} not found."); diff --git a/Program.cs b/Program.cs index dd0906e..fc85958 100644 --- a/Program.cs +++ b/Program.cs @@ -272,9 +272,8 @@ private static async Task OnGameServerConnected(GameServer serv await Task.CompletedTask; } - private void StartCommandHandler() + private static void StartCommandHandler() { - ConsoleCommandHandler commandHandler = new(); - commandHandler.Listen(); + ConsoleCommandHandler.Listen(); } } \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..79f8a66 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,16 @@ +services: + battlebitminigames: + container_name: battlebitminigames + image: battlebitminigames + stdin_open: true + tty: true + build: + context: . + dockerfile: Dockerfile + volumes: + - "./bin/Debug/net6.0/appsettings.json:/app/appsettings.json" + networks: + - battlebit + +networks: + battlebit: \ No newline at end of file