From a1727d3f4f984ca8b92eae6209d9b81380663308 Mon Sep 17 00:00:00 2001 From: Simon L Date: Mon, 19 Jun 2023 13:04:39 +0200 Subject: [PATCH] allow to add tmpfs Signed-off-by: Simon L --- php/containers-schema.json | 7 +++++++ php/src/Container/Container.php | 7 +++++++ php/src/ContainerDefinitionFetcher.php | 6 ++++++ php/src/Docker/DockerActionManager.php | 5 +++++ 4 files changed, 25 insertions(+) diff --git a/php/containers-schema.json b/php/containers-schema.json index 1c7527e6690..a5811ed86f3 100644 --- a/php/containers-schema.json +++ b/php/containers-schema.json @@ -137,6 +137,13 @@ "read_only": { "type": "boolean" }, + "tmpfs": { + "type": "array", + "items": { + "type": "string", + "pattern": "^/[a-z/]$" + } + }, "volumes": { "type": "array", "items": { diff --git a/php/src/Container/Container.php b/php/src/Container/Container.php index 6fa6585b21c..1782211afe0 100644 --- a/php/src/Container/Container.php +++ b/php/src/Container/Container.php @@ -31,6 +31,7 @@ class Container { private array $backupVolumes; private array $nextcloudExecCommands; private bool $readOnlyRootFs; + private array $tmpfs; private DockerActionManager $dockerActionManager; public function __construct( @@ -52,6 +53,7 @@ public function __construct( array $backupVolumes, array $nextcloudExecCommands, bool $readOnlyRootFs, + array $tmpfs, DockerActionManager $dockerActionManager ) { $this->identifier = $identifier; @@ -72,6 +74,7 @@ public function __construct( $this->backupVolumes = $backupVolumes; $this->nextcloudExecCommands = $nextcloudExecCommands; $this->readOnlyRootFs = $readOnlyRootFs; + $this->tmpfs = $tmpfs; $this->dockerActionManager = $dockerActionManager; } @@ -111,6 +114,10 @@ public function GetSecrets() : array { return $this->secrets; } + public function GetTmpfs() : array { + return $this->tmpfs; + } + public function GetDevices() : array { return $this->devices; } diff --git a/php/src/ContainerDefinitionFetcher.php b/php/src/ContainerDefinitionFetcher.php index e23262ced17..65e55a0a9a8 100644 --- a/php/src/ContainerDefinitionFetcher.php +++ b/php/src/ContainerDefinitionFetcher.php @@ -267,6 +267,11 @@ private function GetDefinition(bool $latest): array $readOnlyRootFs = $entry['read_only']; } + $tmpfs = []; + if (isset($entry['tmpfs'])) { + $tmpfs = $entry['tmpfs']; + } + $containers[] = new Container( $entry['container_name'], $displayName, @@ -286,6 +291,7 @@ private function GetDefinition(bool $latest): array $backupVolumes, $nextcloudExecCommands, $readOnlyRootFs, + $tmpfs, $this->container->get(DockerActionManager::class) ); } diff --git a/php/src/Docker/DockerActionManager.php b/php/src/Docker/DockerActionManager.php index 33fa195627c..eb10b4733d5 100644 --- a/php/src/Docker/DockerActionManager.php +++ b/php/src/Docker/DockerActionManager.php @@ -430,6 +430,11 @@ public function CreateContainer(Container $container) : void { $requestBody['HostConfig']['ShmSize'] = $shmSize; } + $tmpfs = $container->GetTmpfs(); + if (count($tmpfs) > 0) { + $requestBody['HostConfig']['Tmpfs'] = $tmpfs; + } + $capAdds = $container->GetCapAdds(); if (count($capAdds) > 0) { $requestBody['HostConfig']['CapAdd'] = $capAdds;