mirror of
https://github.com/nextcloud/all-in-one.git
synced 2024-09-21 23:36:31 +08:00
Merge pull request #2113 from nextcloud/enh/noid/cap_add
fix set_memory for imaginary and move cap_add to containers.json
This commit is contained in:
commit
9f8d17d888
|
@ -21,6 +21,12 @@
|
|||
"type": "string"
|
||||
}
|
||||
},
|
||||
"cap_add": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"depends_on": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
|
|
|
@ -318,6 +318,9 @@
|
|||
],
|
||||
"devices": [
|
||||
"/dev/fuse"
|
||||
],
|
||||
"cap_add": [
|
||||
"SYS_ADMIN"
|
||||
]
|
||||
},
|
||||
{
|
||||
|
@ -411,7 +414,10 @@
|
|||
"environment": [
|
||||
"TZ=%TIMEZONE%"
|
||||
],
|
||||
"restart": "unless-stopped"
|
||||
"restart": "unless-stopped",
|
||||
"cap_add": [
|
||||
"SYS_NICE"
|
||||
]
|
||||
},
|
||||
{
|
||||
"container_name": "nextcloud-aio-fulltextsearch",
|
||||
|
|
|
@ -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(
|
||||
|
@ -38,6 +40,7 @@ class Container {
|
|||
array $dependsOn,
|
||||
array $secrets,
|
||||
array $devices,
|
||||
array $capAdd,
|
||||
DockerActionManager $dockerActionManager
|
||||
) {
|
||||
$this->identifier = $identifier;
|
||||
|
@ -52,6 +55,7 @@ class Container {
|
|||
$this->dependsOn = $dependsOn;
|
||||
$this->secrets = $secrets;
|
||||
$this->devices = $devices;
|
||||
$this->capAdd = $capAdd;
|
||||
$this->dockerActionManager = $dockerActionManager;
|
||||
}
|
||||
|
||||
|
@ -83,6 +87,10 @@ class Container {
|
|||
return $this->devices;
|
||||
}
|
||||
|
||||
public function GetCapAdds() : array {
|
||||
return $this->capAdd;
|
||||
}
|
||||
|
||||
public function GetPorts() : ContainerPorts {
|
||||
return $this->ports;
|
||||
}
|
||||
|
|
|
@ -213,6 +213,11 @@ class ContainerDefinitionFetcher
|
|||
$devices = $entry['devices'];
|
||||
}
|
||||
|
||||
$capAdd = [];
|
||||
if (isset($entry['cap_add'])) {
|
||||
$capAdd = $entry['cap_add'];
|
||||
}
|
||||
|
||||
$containers[] = new Container(
|
||||
$entry['container_name'],
|
||||
$displayName,
|
||||
|
@ -226,6 +231,7 @@ class ContainerDefinitionFetcher
|
|||
$dependsOn,
|
||||
$secrets,
|
||||
$devices,
|
||||
$capAdd,
|
||||
$this->container->get(DockerActionManager::class)
|
||||
);
|
||||
}
|
||||
|
|
|
@ -411,9 +411,13 @@ class DockerActionManager
|
|||
$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
|
||||
|
|
Loading…
Reference in a new issue