Skip to content

Commit

Permalink
Merge pull request #2601 from nextcloud/enh/2585/volume-mounts
Browse files Browse the repository at this point in the history
set NEXTCLOUD_MOUNT to rshared
  • Loading branch information
szaimen authored Jul 20, 2023
2 parents 40dfd4c + 7824060 commit 00557fe
Showing 1 changed file with 24 additions and 7 deletions.
31 changes: 24 additions & 7 deletions php/src/Docker/DockerActionManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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;
}

Expand Down Expand Up @@ -447,10 +454,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];
Expand All @@ -465,13 +473,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());
Expand Down

0 comments on commit 00557fe

Please sign in to comment.