Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix set_memory for imaginary and move cap_add to containers.json #2113

Merged
merged 1 commit into from
Mar 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions php/containers-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@
"type": "string"
}
},
"cap_add": {
"type": "array",
"items": {
"type": "string"
}
},
"depends_on": {
"type": "array",
"items": {
Expand Down
8 changes: 7 additions & 1 deletion php/containers.json
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,9 @@
],
"devices": [
"/dev/fuse"
],
"cap_add": [
"SYS_ADMIN"
]
},
{
Expand Down Expand Up @@ -411,7 +414,10 @@
"environment": [
"TZ=%TIMEZONE%"
],
"restart": "unless-stopped"
"restart": "unless-stopped",
"cap_add": [
"SYS_NICE"
]
},
{
"container_name": "nextcloud-aio-fulltextsearch",
Expand Down
8 changes: 8 additions & 0 deletions php/src/Container/Container.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ class Container {
private array $secrets;
/** @var string[] */
private array $devices;
/** @var string[] */
private array $capAdd;
private DockerActionManager $dockerActionManager;

public function __construct(
Expand All @@ -38,6 +40,7 @@ public function __construct(
array $dependsOn,
array $secrets,
array $devices,
array $capAdd,
DockerActionManager $dockerActionManager
) {
$this->identifier = $identifier;
Expand All @@ -52,6 +55,7 @@ public function __construct(
$this->dependsOn = $dependsOn;
$this->secrets = $secrets;
$this->devices = $devices;
$this->capAdd = $capAdd;
$this->dockerActionManager = $dockerActionManager;
}

Expand Down Expand Up @@ -83,6 +87,10 @@ public function GetDevices() : array {
return $this->devices;
}

public function GetCapAdds() : array {
return $this->capAdd;
}

public function GetPorts() : ContainerPorts {
return $this->ports;
}
Expand Down
6 changes: 6 additions & 0 deletions php/src/ContainerDefinitionFetcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,11 @@ private function GetDefinition(bool $latest): array
$devices = $entry['devices'];
}

$capAdd = [];
if (isset($entry['cap_add'])) {
$capAdd = $entry['cap_add'];
}

$containers[] = new Container(
$entry['container_name'],
$displayName,
Expand All @@ -226,6 +231,7 @@ private function GetDefinition(bool $latest): array
$dependsOn,
$secrets,
$devices,
$capAdd,
$this->container->get(DockerActionManager::class)
);
}
Expand Down
6 changes: 5 additions & 1 deletion php/src/Docker/DockerActionManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -411,9 +411,13 @@ public function CreateContainer(Container $container) : void {
$requestBody['HostConfig']['Devices'] = $devices;
}

$capAdds = $container->GetCapAdds();
if (count($capAdds) > 0) {
$requestBody['HostConfig']['CapAdd'] = $capAdds;
}

// Special things for the backup container which should not be exposed in the containers.json
if ($container->GetIdentifier() === 'nextcloud-aio-borgbackup') {
$requestBody['HostConfig']['CapAdd'] = ["SYS_ADMIN"];
$requestBody['HostConfig']['SecurityOpt'] = ["apparmor:unconfined"];

// Additional backup directories
Expand Down