Files
Servers/MoonlightServers.Daemon/ServerSystem/Implementations/Docker/Extensions.cs

22 lines
772 B
C#

using Docker.DotNet;
using MoonlightServers.Daemon.ServerSystem.Abstractions;
namespace MoonlightServers.Daemon.ServerSystem.Implementations.Docker;
public static class Extensions
{
public static void AddDockerServices(this IServiceCollection collection)
{
var client = new DockerClientBuilder()
.WithEndpoint(new Uri("unix:///var/run/docker.sock"))
.Build();
collection.AddSingleton(client);
collection.AddSingleton<DockerEventService>();
collection.AddHostedService(sp => sp.GetRequiredService<DockerEventService>());
collection.AddSingleton<IRuntimeEnvironmentService, DockerRuntimeEnvService>();
collection.AddSingleton<IInstallEnvironmentService, DockerInstallEnvService>();
}
}