Merge pull request from nextcloud/enh/2506/allow-to-specify-read-only

allow to specify read_only root FS in containers definition
This commit is contained in:
Simon L 2023-06-06 10:34:03 +02:00 committed by GitHub
commit 68f64397ea
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 18 additions and 0 deletions

View file

@ -134,6 +134,9 @@
"pattern": "^nextcloud-aio$"
}
},
"read_only": {
"type": "boolean"
},
"volumes": {
"type": "array",
"items": {

View file

@ -30,6 +30,7 @@ class Container {
/** @var string[] */
private array $backupVolumes;
private array $nextcloudExecCommands;
private bool $readOnlyRootFs;
private DockerActionManager $dockerActionManager;
public function __construct(
@ -50,6 +51,7 @@ class Container {
bool $apparmorUnconfined,
array $backupVolumes,
array $nextcloudExecCommands,
bool $readOnlyRootFs,
DockerActionManager $dockerActionManager
) {
$this->identifier = $identifier;
@ -69,6 +71,7 @@ class Container {
$this->apparmorUnconfined = $apparmorUnconfined;
$this->backupVolumes = $backupVolumes;
$this->nextcloudExecCommands = $nextcloudExecCommands;
$this->readOnlyRootFs = $readOnlyRootFs;
$this->dockerActionManager = $dockerActionManager;
}
@ -88,6 +91,10 @@ class Container {
return $this->restartPolicy;
}
public function GetReadOnlySetting() : bool {
return $this->readOnlyRootFs;
}
public function GetShmSize() : int {
return $this->shmSize;
}

View file

@ -262,6 +262,11 @@ class ContainerDefinitionFetcher
$nextcloudExecCommands = $entry['nextcloud_exec_commands'];
}
$readOnlyRootFs = false;
if (isset($entry['read_only'])) {
$readOnlyRootFs = $entry['read_only'];
}
$containers[] = new Container(
$entry['container_name'],
$displayName,
@ -280,6 +285,7 @@ class ContainerDefinitionFetcher
$apparmorUnconfined,
$backupVolumes,
$nextcloudExecCommands,
$readOnlyRootFs,
$this->container->get(DockerActionManager::class)
);
}

View file

@ -383,6 +383,8 @@ class DockerActionManager
}
$requestBody['HostConfig']['RestartPolicy']['Name'] = $container->GetRestartPolicy();
$requestBody['HostConfig']['ReadonlyRootfs'] = $container->GetReadOnlySetting();
$exposedPorts = [];
if ($container->GetInternalPort() !== 'host') {