allow to add tmpfs

Signed-off-by: Simon L <szaimen@e.mail.de>
This commit is contained in:
Simon L 2023-06-19 13:04:39 +02:00
parent a8ed5d3dc8
commit a1727d3f4f
4 changed files with 25 additions and 0 deletions

View file

@ -137,6 +137,13 @@
"read_only": { "read_only": {
"type": "boolean" "type": "boolean"
}, },
"tmpfs": {
"type": "array",
"items": {
"type": "string",
"pattern": "^/[a-z/]$"
}
},
"volumes": { "volumes": {
"type": "array", "type": "array",
"items": { "items": {

View file

@ -31,6 +31,7 @@ class Container {
private array $backupVolumes; private array $backupVolumes;
private array $nextcloudExecCommands; private array $nextcloudExecCommands;
private bool $readOnlyRootFs; private bool $readOnlyRootFs;
private array $tmpfs;
private DockerActionManager $dockerActionManager; private DockerActionManager $dockerActionManager;
public function __construct( public function __construct(
@ -52,6 +53,7 @@ class Container {
array $backupVolumes, array $backupVolumes,
array $nextcloudExecCommands, array $nextcloudExecCommands,
bool $readOnlyRootFs, bool $readOnlyRootFs,
array $tmpfs,
DockerActionManager $dockerActionManager DockerActionManager $dockerActionManager
) { ) {
$this->identifier = $identifier; $this->identifier = $identifier;
@ -72,6 +74,7 @@ class Container {
$this->backupVolumes = $backupVolumes; $this->backupVolumes = $backupVolumes;
$this->nextcloudExecCommands = $nextcloudExecCommands; $this->nextcloudExecCommands = $nextcloudExecCommands;
$this->readOnlyRootFs = $readOnlyRootFs; $this->readOnlyRootFs = $readOnlyRootFs;
$this->tmpfs = $tmpfs;
$this->dockerActionManager = $dockerActionManager; $this->dockerActionManager = $dockerActionManager;
} }
@ -111,6 +114,10 @@ class Container {
return $this->secrets; return $this->secrets;
} }
public function GetTmpfs() : array {
return $this->tmpfs;
}
public function GetDevices() : array { public function GetDevices() : array {
return $this->devices; return $this->devices;
} }

View file

@ -267,6 +267,11 @@ class ContainerDefinitionFetcher
$readOnlyRootFs = $entry['read_only']; $readOnlyRootFs = $entry['read_only'];
} }
$tmpfs = [];
if (isset($entry['tmpfs'])) {
$tmpfs = $entry['tmpfs'];
}
$containers[] = new Container( $containers[] = new Container(
$entry['container_name'], $entry['container_name'],
$displayName, $displayName,
@ -286,6 +291,7 @@ class ContainerDefinitionFetcher
$backupVolumes, $backupVolumes,
$nextcloudExecCommands, $nextcloudExecCommands,
$readOnlyRootFs, $readOnlyRootFs,
$tmpfs,
$this->container->get(DockerActionManager::class) $this->container->get(DockerActionManager::class)
); );
} }

View file

@ -430,6 +430,11 @@ class DockerActionManager
$requestBody['HostConfig']['ShmSize'] = $shmSize; $requestBody['HostConfig']['ShmSize'] = $shmSize;
} }
$tmpfs = $container->GetTmpfs();
if (count($tmpfs) > 0) {
$requestBody['HostConfig']['Tmpfs'] = $tmpfs;
}
$capAdds = $container->GetCapAdds(); $capAdds = $container->GetCapAdds();
if (count($capAdds) > 0) { if (count($capAdds) > 0) {
$requestBody['HostConfig']['CapAdd'] = $capAdds; $requestBody['HostConfig']['CapAdd'] = $capAdds;