Implemented statistics. Refactored storage abstractions. Added config options for docker and local storage. Added server service and server updating.

This commit is contained in:
2026-03-02 15:51:05 +00:00
parent 52dbd13fb5
commit 2d1b48b0d4
27 changed files with 493 additions and 147 deletions

View File

@@ -1,4 +1,6 @@
using Docker.DotNet;
using Microsoft.Extensions.Options;
using MoonlightServers.Daemon.Configuration;
using MoonlightServers.Daemon.ServerSystem.Abstractions;
namespace MoonlightServers.Daemon.ServerSystem.Implementations.Docker;
@@ -7,16 +9,23 @@ 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.AddOptions<DockerOptions>().BindConfiguration("Moonlight:Docker");
collection.AddSingleton(client);
collection.AddSingleton(sp =>
{
var options = sp.GetRequiredService<IOptions<DockerOptions>>();
return new DockerClientBuilder()
.WithEndpoint(new Uri(options.Value.SocketUri))
.Build();
});
collection.AddSingleton<DockerEventService>();
collection.AddHostedService(sp => sp.GetRequiredService<DockerEventService>());
collection.AddSingleton<IRuntimeEnvironmentService, DockerRuntimeEnvService>();
collection.AddSingleton<IInstallEnvironmentService, DockerInstallEnvService>();
collection.AddSingleton<ContainerConfigMapper>();
}
}