From 7824060a6cae98e0d5a6116223514cb005b5b0ba Mon Sep 17 00:00:00 2001 From: Simon L Date: Fri, 26 May 2023 12:00:05 +0200 Subject: [PATCH] set NEXTCLOUD_MOUNT to rshared Signed-off-by: Simon L --- php/src/Docker/DockerActionManager.php | 31 ++++++++++++++++++++------ 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/php/src/Docker/DockerActionManager.php b/php/src/Docker/DockerActionManager.php index c11f16a03f5..bae9f6f6b48 100644 --- a/php/src/Docker/DockerActionManager.php +++ b/php/src/Docker/DockerActionManager.php @@ -211,9 +211,16 @@ public function CreateVolumes(Container $container): void public function CreateContainer(Container $container) : void { $volumes = []; - foreach($container->GetVolumes()->GetVolumes() as $volume) { + foreach ($container->GetVolumes()->GetVolumes() as $volume) { + // NEXTCLOUD_MOUNT gets added via bind-mount later on + if ($container->GetIdentifier() === 'nextcloud-aio-nextcloud') { + if ($volume->name === $this->configurationManager->GetNextcloudMount()) { + continue; + } + } + $volumeEntry = $volume->name . ':' . $volume->mountPoint; - if($volume->isWritable) { + if ($volume->isWritable) { $volumeEntry = $volumeEntry . ':' . 'rw'; } else { $volumeEntry = $volumeEntry . ':' . 'ro'; @@ -226,7 +233,7 @@ public function CreateContainer(Container $container) : void { 'Image' => $this->BuildImageName($container), ]; - if(count($volumes) > 0) { + if (count($volumes) > 0) { $requestBody['HostConfig']['Binds'] = $volumes; } @@ -425,10 +432,11 @@ public function CreateContainer(Container $container) : void { $requestBody['HostConfig']['SecurityOpt'] = ["apparmor:unconfined"]; } + $mounts = []; + // Special things for the backup container which should not be exposed in the containers.json if ($container->GetIdentifier() === 'nextcloud-aio-borgbackup') { // Additional backup directories - $mounts = []; foreach ($this->getAllBackupVolumes() as $additionalBackupVolumes) { if ($additionalBackupVolumes !== '') { $mounts[] = ["Type" => "volume", "Source" => $additionalBackupVolumes, "Target" => "/nextcloud_aio_volumes/" . $additionalBackupVolumes, "ReadOnly" => false]; @@ -443,13 +451,22 @@ public function CreateContainer(Container $container) : void { } } } - if(count($mounts) > 0) { - $requestBody['HostConfig']['Mounts'] = $mounts; - } // Special things for the talk container which should not be exposed in the containers.json } elseif ($container->GetIdentifier() === 'nextcloud-aio-talk') { // This is needed due to a bug in libwebsockets which cannot handle unlimited ulimits $requestBody['HostConfig']['Ulimits'] = [["Name" => "nofile", "Hard" => 200000, "Soft" => 200000]]; + // Special things for the nextcloud container which should not be exposed in the containers.json + } elseif ($container->GetIdentifier() === 'nextcloud-aio-nextcloud') { + foreach ($container->GetVolumes()->GetVolumes() as $volume) { + if ($volume->name !== $this->configurationManager->GetNextcloudMount()) { + continue; + } + $mounts[] = ["Type" => "bind", "Source" => $volume->name, "Target" => $volume->mountPoint, "ReadOnly" => !$volume->isWritable, "Propagation" => "rshared"]; + } + } + + if (count($mounts) > 0) { + $requestBody['HostConfig']['Mounts'] = $mounts; } $url = $this->BuildApiUrl('containers/create?name=' . $container->GetIdentifier());