From 09329142d52e094caa90892547ce93d6ae1301bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roberto=20Bl=C3=A1zquez?= Date: Fri, 19 Jan 2024 22:00:31 +0100 Subject: [PATCH] Install libs in Dockerfile --- DiscordBot/Program.cs | 2 -- DiscordBot/Utils/LibInstaller.cs | 31 ------------------------------- Dockerfile | 3 +++ 3 files changed, 3 insertions(+), 33 deletions(-) delete mode 100644 DiscordBot/Utils/LibInstaller.cs diff --git a/DiscordBot/Program.cs b/DiscordBot/Program.cs index 9a65ae7..9ad8f6f 100644 --- a/DiscordBot/Program.cs +++ b/DiscordBot/Program.cs @@ -7,7 +7,6 @@ using DiscordBot.Modules; using DiscordBot.MusicPlayer.Config; using DiscordBot.MusicPlayer.Factories; -using DiscordBot.Utils; using DSharpPlus; using DSharpPlus.CommandsNext; using DSharpPlus.VoiceNext; @@ -26,7 +25,6 @@ internal static class Program { public static async Task Main() { - await LibInstaller.InstallLibsAsync(); //gets the enviroment to be used when getting the appsettings var enviroment = GetEnvironmentVariable("Environment") ?? "No environment found, using default appsettings"; diff --git a/DiscordBot/Utils/LibInstaller.cs b/DiscordBot/Utils/LibInstaller.cs deleted file mode 100644 index dcd9195..0000000 --- a/DiscordBot/Utils/LibInstaller.cs +++ /dev/null @@ -1,31 +0,0 @@ -using System; -using System.Runtime.InteropServices; -using System.Threading.Tasks; -using CliWrap; - -namespace DiscordBot.Utils; - -public static class LibInstaller -{ - public static async Task InstallLibsAsync() - { - if (!RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) return; - await AptUpdate(); - await Task.WhenAll(InstallSodiumAsync(), InstallOpusAsync()); - } - - private static async Task AptUpdate() => await Cli.Wrap("apt") - .WithArguments(["update"]) - .WithStandardOutputPipe(PipeTarget.ToDelegate(Console.WriteLine)) - .ExecuteAsync(); - - private static async Task InstallSodiumAsync() => await Cli.Wrap("apt") - .WithArguments(["install", "libsodium-dev", "-y"]) - .WithStandardOutputPipe(PipeTarget.ToDelegate(Console.WriteLine)) - .ExecuteAsync(); - - private static async Task InstallOpusAsync() => await Cli.Wrap("apt") - .WithArguments(["install", "libopus-dev", "-y"]) - .WithStandardOutputPipe(PipeTarget.ToDelegate(Console.WriteLine)) - .ExecuteAsync(); -} \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 73ee77a..9a72c77 100644 --- a/Dockerfile +++ b/Dockerfile @@ -9,6 +9,9 @@ WORKDIR "/src/DiscordBot" RUN dotnet publish "DiscordBot.csproj" -a $TARGETARCH --self-contained false -c Release --no-restore -o /app/publish FROM mcr.microsoft.com/dotnet/runtime:8.0-jammy +RUN apt update +RUN apt install libsodium-dev -y +RUN apt install libopus-dev -y WORKDIR /app COPY --from=build /app/publish . ENTRYPOINT ["dotnet", "DiscordBot.dll"]