Implemented more life cycle handling. Added support for rootless environments
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using Docker.DotNet.Models;
|
||||
using Mono.Unix.Native;
|
||||
using MoonCore.Helpers;
|
||||
using MoonlightServers.Daemon.Configuration;
|
||||
using MoonlightServers.Daemon.Models.Cache;
|
||||
@@ -42,8 +43,20 @@ public static class ServerConfigurationHelper
|
||||
parameters.WorkingDir = "/home/container";
|
||||
|
||||
// - User
|
||||
//TODO: use config
|
||||
parameters.User = $"998:998";
|
||||
var userId = Syscall.getuid();
|
||||
|
||||
if (userId == 0)
|
||||
{
|
||||
// We are running as root, so we need to run the container as another user and chown the files when we make changes
|
||||
parameters.User = $"998:998";
|
||||
}
|
||||
else
|
||||
{
|
||||
// We are not running as root, so we start the container as the same user,
|
||||
// as we are not able to chown the container content to a different user
|
||||
parameters.User = $"{userId}:{userId}";
|
||||
}
|
||||
|
||||
|
||||
// -- Mounts
|
||||
parameters.HostConfig.Mounts = new List<Mount>();
|
||||
|
||||
Reference in New Issue
Block a user