Skip to content

Commit

Permalink
Merge pull request #2811 from nextcloud/enh/2506/allow-to-add-tmpfs
Browse files Browse the repository at this point in the history
allow to add tmpfs
  • Loading branch information
szaimen authored Jun 19, 2023
2 parents a8ed5d3 + a1727d3 commit 417ebc5
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 0 deletions.
7 changes: 7 additions & 0 deletions php/containers-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,13 @@
"read_only": {
"type": "boolean"
},
"tmpfs": {
"type": "array",
"items": {
"type": "string",
"pattern": "^/[a-z/]$"
}
},
"volumes": {
"type": "array",
"items": {
Expand Down
7 changes: 7 additions & 0 deletions php/src/Container/Container.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ class Container {
private array $backupVolumes;
private array $nextcloudExecCommands;
private bool $readOnlyRootFs;
private array $tmpfs;
private DockerActionManager $dockerActionManager;

public function __construct(
Expand All @@ -52,6 +53,7 @@ public function __construct(
array $backupVolumes,
array $nextcloudExecCommands,
bool $readOnlyRootFs,
array $tmpfs,
DockerActionManager $dockerActionManager
) {
$this->identifier = $identifier;
Expand All @@ -72,6 +74,7 @@ public function __construct(
$this->backupVolumes = $backupVolumes;
$this->nextcloudExecCommands = $nextcloudExecCommands;
$this->readOnlyRootFs = $readOnlyRootFs;
$this->tmpfs = $tmpfs;
$this->dockerActionManager = $dockerActionManager;
}

Expand Down Expand Up @@ -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;
}
Expand Down
6 changes: 6 additions & 0 deletions php/src/ContainerDefinitionFetcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -286,6 +291,7 @@ private function GetDefinition(bool $latest): array
$backupVolumes,
$nextcloudExecCommands,
$readOnlyRootFs,
$tmpfs,
$this->container->get(DockerActionManager::class)
);
}
Expand Down
5 changes: 5 additions & 0 deletions php/src/Docker/DockerActionManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 417ebc5

Please sign in to comment.