mirror of
https://github.com/nextcloud/all-in-one.git
synced 2026-02-15 02:00:15 +00:00
Merge pull request #7406 from nextcloud/ench/noid/parm
refactor: change private properties to public in Container class
This commit is contained in:
commit
52f8c97d45
6 changed files with 105 additions and 193 deletions
|
|
@ -5,121 +5,56 @@ namespace AIO\Container;
|
||||||
use AIO\Data\ConfigurationManager;
|
use AIO\Data\ConfigurationManager;
|
||||||
use AIO\Docker\DockerActionManager;
|
use AIO\Docker\DockerActionManager;
|
||||||
use AIO\ContainerDefinitionFetcher;
|
use AIO\ContainerDefinitionFetcher;
|
||||||
|
use JsonException;
|
||||||
|
|
||||||
readonly class Container {
|
readonly class Container {
|
||||||
public function __construct(
|
public function __construct(
|
||||||
private string $identifier,
|
public string $identifier,
|
||||||
private string $displayName,
|
public string $displayName,
|
||||||
private string $containerName,
|
public string $containerName,
|
||||||
private string $restartPolicy,
|
public string $restartPolicy,
|
||||||
private int $maxShutdownTime,
|
public int $maxShutdownTime,
|
||||||
private ContainerPorts $ports,
|
public ContainerPorts $ports,
|
||||||
private string $internalPorts,
|
public string $internalPorts,
|
||||||
private ContainerVolumes $volumes,
|
public ContainerVolumes $volumes,
|
||||||
private ContainerEnvironmentVariables $containerEnvironmentVariables,
|
public ContainerEnvironmentVariables $containerEnvironmentVariables,
|
||||||
/** @var string[] */
|
/** @var string[] */
|
||||||
private array $dependsOn,
|
public array $dependsOn,
|
||||||
private string $uiSecret,
|
private string $uiSecret,
|
||||||
/** @var string[] */
|
/** @var string[] */
|
||||||
private array $devices,
|
public array $devices,
|
||||||
private bool $enableNvidiaGpu,
|
public bool $enableNvidiaGpu,
|
||||||
/** @var string[] */
|
/** @var string[] */
|
||||||
private array $capAdd,
|
public array $capAdd,
|
||||||
private int $shmSize,
|
public int $shmSize,
|
||||||
private bool $apparmorUnconfined,
|
public bool $apparmorUnconfined,
|
||||||
/** @var string[] */
|
/** @var string[] */
|
||||||
private array $backupVolumes,
|
public array $backupVolumes,
|
||||||
private array $nextcloudExecCommands,
|
public array $nextcloudExecCommands,
|
||||||
private bool $readOnlyRootFs,
|
public bool $readOnlyRootFs,
|
||||||
private array $tmpfs,
|
public array $tmpfs,
|
||||||
private bool $init,
|
public bool $init,
|
||||||
private string $imageTag,
|
public string $imageTag,
|
||||||
private AioVariables $aioVariables,
|
public AioVariables $aioVariables,
|
||||||
private string $documentation,
|
public string $documentation,
|
||||||
private DockerActionManager $dockerActionManager
|
private DockerActionManager $dockerActionManager
|
||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function GetIdentifier() : string {
|
|
||||||
return $this->identifier;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function GetDisplayName() : string {
|
|
||||||
return $this->displayName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function GetContainerName() : string {
|
|
||||||
return $this->containerName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function GetRestartPolicy() : string {
|
|
||||||
return $this->restartPolicy;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function GetImageTag() : string {
|
|
||||||
return $this->imageTag;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function GetReadOnlySetting() : bool {
|
|
||||||
return $this->readOnlyRootFs;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function GetInit() : bool {
|
|
||||||
return $this->init;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function GetShmSize() : int {
|
|
||||||
return $this->shmSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function isApparmorUnconfined() : bool {
|
|
||||||
return $this->apparmorUnconfined;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function GetMaxShutdownTime() : int {
|
|
||||||
return $this->maxShutdownTime;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function GetUiSecret() : string {
|
public function GetUiSecret() : string {
|
||||||
return $this->dockerActionManager->GetAndGenerateSecretWrapper($this->uiSecret);
|
return $this->dockerActionManager->GetAndGenerateSecretWrapper($this->uiSecret);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function GetTmpfs() : array {
|
/**
|
||||||
return $this->tmpfs;
|
* @throws JsonException
|
||||||
}
|
*/
|
||||||
|
|
||||||
public function GetDevices() : array {
|
|
||||||
return $this->devices;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function isNvidiaGpuEnabled() : bool {
|
|
||||||
return $this->enableNvidiaGpu;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function GetCapAdds() : array {
|
|
||||||
return $this->capAdd;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function GetBackupVolumes() : array {
|
|
||||||
return $this->backupVolumes;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function GetPorts() : ContainerPorts {
|
|
||||||
return $this->ports;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function GetInternalPort() : string {
|
|
||||||
return $this->internalPorts;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function GetVolumes() : ContainerVolumes {
|
|
||||||
return $this->volumes;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function GetRunningState() : ContainerState {
|
public function GetRunningState() : ContainerState {
|
||||||
return $this->dockerActionManager->GetContainerRunningState($this);
|
return $this->dockerActionManager->GetContainerRunningState($this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @throws JsonException
|
||||||
|
*/
|
||||||
public function GetRestartingState() : ContainerState {
|
public function GetRestartingState() : ContainerState {
|
||||||
return $this->dockerActionManager->GetContainerRestartingState($this);
|
return $this->dockerActionManager->GetContainerRestartingState($this);
|
||||||
}
|
}
|
||||||
|
|
@ -131,27 +66,4 @@ readonly class Container {
|
||||||
public function GetStartingState() : ContainerState {
|
public function GetStartingState() : ContainerState {
|
||||||
return $this->dockerActionManager->GetContainerStartingState($this);
|
return $this->dockerActionManager->GetContainerStartingState($this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return string[]
|
|
||||||
*/
|
|
||||||
public function GetDependsOn() : array {
|
|
||||||
return $this->dependsOn;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function GetNextcloudExecCommands() : array {
|
|
||||||
return $this->nextcloudExecCommands;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function GetEnvironmentVariables() : ContainerEnvironmentVariables {
|
|
||||||
return $this->containerEnvironmentVariables;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function GetAioVariables() : AioVariables {
|
|
||||||
return $this->aioVariables;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function GetDocumentation() : string {
|
|
||||||
return $this->documentation;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@ readonly class ContainerDefinitionFetcher {
|
||||||
$containers = $this->FetchDefinition();
|
$containers = $this->FetchDefinition();
|
||||||
|
|
||||||
foreach ($containers as $container) {
|
foreach ($containers as $container) {
|
||||||
if ($container->GetIdentifier() === $id) {
|
if ($container->identifier === $id) {
|
||||||
return $container;
|
return $container;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ readonly class DockerController {
|
||||||
$container = $this->containerDefinitionFetcher->GetContainerById($id);
|
$container = $this->containerDefinitionFetcher->GetContainerById($id);
|
||||||
|
|
||||||
// Start all dependencies first and then itself
|
// Start all dependencies first and then itself
|
||||||
foreach($container->GetDependsOn() as $dependency) {
|
foreach($container->dependsOn as $dependency) {
|
||||||
$this->PerformRecursiveContainerStart($dependency, $pullImage);
|
$this->PerformRecursiveContainerStart($dependency, $pullImage);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -46,7 +46,7 @@ readonly class DockerController {
|
||||||
$container = $this->containerDefinitionFetcher->GetContainerById($id);
|
$container = $this->containerDefinitionFetcher->GetContainerById($id);
|
||||||
|
|
||||||
// Pull all dependencies first and then itself
|
// Pull all dependencies first and then itself
|
||||||
foreach($container->GetDependsOn() as $dependency) {
|
foreach($container->dependsOn as $dependency) {
|
||||||
$this->PerformRecursiveImagePull($dependency);
|
$this->PerformRecursiveImagePull($dependency);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -255,7 +255,7 @@ readonly class DockerController {
|
||||||
// We want to stop the Nextcloud container after 10s and not wait for the configured stop_grace_period
|
// We want to stop the Nextcloud container after 10s and not wait for the configured stop_grace_period
|
||||||
$this->dockerActionManager->StopContainer($container, $forceStopNextcloud);
|
$this->dockerActionManager->StopContainer($container, $forceStopNextcloud);
|
||||||
}
|
}
|
||||||
foreach($container->GetDependsOn() as $dependency) {
|
foreach($container->dependsOn as $dependency) {
|
||||||
$this->PerformRecursiveContainerStop($dependency, $forceStopNextcloud);
|
$this->PerformRecursiveContainerStop($dependency, $forceStopNextcloud);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -36,15 +36,15 @@ readonly class DockerActionManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
private function BuildImageName(Container $container): string {
|
private function BuildImageName(Container $container): string {
|
||||||
$tag = $container->GetImageTag();
|
$tag = $container->imageTag;
|
||||||
if ($tag === '%AIO_CHANNEL%') {
|
if ($tag === '%AIO_CHANNEL%') {
|
||||||
$tag = $this->GetCurrentChannel();
|
$tag = $this->GetCurrentChannel();
|
||||||
}
|
}
|
||||||
return $container->GetContainerName() . ':' . $tag;
|
return $container->containerName . ':' . $tag;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function GetContainerRunningState(Container $container): ContainerState {
|
public function GetContainerRunningState(Container $container): ContainerState {
|
||||||
$url = $this->BuildApiUrl(sprintf('containers/%s/json', urlencode($container->GetIdentifier())));
|
$url = $this->BuildApiUrl(sprintf('containers/%s/json', urlencode($container->identifier)));
|
||||||
try {
|
try {
|
||||||
$response = $this->guzzleClient->get($url);
|
$response = $this->guzzleClient->get($url);
|
||||||
} catch (RequestException $e) {
|
} catch (RequestException $e) {
|
||||||
|
|
@ -64,7 +64,7 @@ readonly class DockerActionManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function GetContainerRestartingState(Container $container): ContainerState {
|
public function GetContainerRestartingState(Container $container): ContainerState {
|
||||||
$url = $this->BuildApiUrl(sprintf('containers/%s/json', urlencode($container->GetIdentifier())));
|
$url = $this->BuildApiUrl(sprintf('containers/%s/json', urlencode($container->identifier)));
|
||||||
try {
|
try {
|
||||||
$response = $this->guzzleClient->get($url);
|
$response = $this->guzzleClient->get($url);
|
||||||
} catch (RequestException $e) {
|
} catch (RequestException $e) {
|
||||||
|
|
@ -84,16 +84,16 @@ readonly class DockerActionManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function GetContainerUpdateState(Container $container): VersionState {
|
public function GetContainerUpdateState(Container $container): VersionState {
|
||||||
$tag = $container->GetImageTag();
|
$tag = $container->imageTag;
|
||||||
if ($tag === '%AIO_CHANNEL%') {
|
if ($tag === '%AIO_CHANNEL%') {
|
||||||
$tag = $this->GetCurrentChannel();
|
$tag = $this->GetCurrentChannel();
|
||||||
}
|
}
|
||||||
|
|
||||||
$runningDigests = $this->GetRepoDigestsOfContainer($container->GetIdentifier());
|
$runningDigests = $this->GetRepoDigestsOfContainer($container->identifier);
|
||||||
if ($runningDigests === null) {
|
if ($runningDigests === null) {
|
||||||
return VersionState::Different;
|
return VersionState::Different;
|
||||||
}
|
}
|
||||||
$remoteDigest = $this->GetLatestDigestOfTag($container->GetContainerName(), $tag);
|
$remoteDigest = $this->GetLatestDigestOfTag($container->containerName, $tag);
|
||||||
if ($remoteDigest === null) {
|
if ($remoteDigest === null) {
|
||||||
return VersionState::Equal;
|
return VersionState::Equal;
|
||||||
}
|
}
|
||||||
|
|
@ -112,8 +112,8 @@ readonly class DockerActionManager {
|
||||||
return $runningState;
|
return $runningState;
|
||||||
}
|
}
|
||||||
|
|
||||||
$containerName = $container->GetIdentifier();
|
$containerName = $container->identifier;
|
||||||
$internalPort = $container->GetInternalPort();
|
$internalPort = $container->internalPorts;
|
||||||
if ($internalPort === '%APACHE_PORT%') {
|
if ($internalPort === '%APACHE_PORT%') {
|
||||||
$internalPort = $this->configurationManager->GetApachePort();
|
$internalPort = $this->configurationManager->GetApachePort();
|
||||||
} elseif ($internalPort === '%TALK_PORT%') {
|
} elseif ($internalPort === '%TALK_PORT%') {
|
||||||
|
|
@ -134,7 +134,7 @@ readonly class DockerActionManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function DeleteContainer(Container $container): void {
|
public function DeleteContainer(Container $container): void {
|
||||||
$url = $this->BuildApiUrl(sprintf('containers/%s?v=true', urlencode($container->GetIdentifier())));
|
$url = $this->BuildApiUrl(sprintf('containers/%s?v=true', urlencode($container->identifier)));
|
||||||
try {
|
try {
|
||||||
$this->guzzleClient->delete($url);
|
$this->guzzleClient->delete($url);
|
||||||
} catch (RequestException $e) {
|
} catch (RequestException $e) {
|
||||||
|
|
@ -166,17 +166,17 @@ readonly class DockerActionManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function StartContainer(Container $container): void {
|
public function StartContainer(Container $container): void {
|
||||||
$url = $this->BuildApiUrl(sprintf('containers/%s/start', urlencode($container->GetIdentifier())));
|
$url = $this->BuildApiUrl(sprintf('containers/%s/start', urlencode($container->identifier)));
|
||||||
try {
|
try {
|
||||||
$this->guzzleClient->post($url);
|
$this->guzzleClient->post($url);
|
||||||
} catch (RequestException $e) {
|
} catch (RequestException $e) {
|
||||||
throw new \Exception("Could not start container " . $container->GetIdentifier() . ": " . $e->getResponse()?->getBody()->getContents());
|
throw new \Exception("Could not start container " . $container->identifier . ": " . $e->getResponse()?->getBody()->getContents());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function CreateVolumes(Container $container): void {
|
public function CreateVolumes(Container $container): void {
|
||||||
$url = $this->BuildApiUrl('volumes/create');
|
$url = $this->BuildApiUrl('volumes/create');
|
||||||
foreach ($container->GetVolumes()->GetVolumes() as $volume) {
|
foreach ($container->volumes->GetVolumes() as $volume) {
|
||||||
$forbiddenChars = [
|
$forbiddenChars = [
|
||||||
'/',
|
'/',
|
||||||
];
|
];
|
||||||
|
|
@ -202,9 +202,9 @@ readonly class DockerActionManager {
|
||||||
|
|
||||||
public function CreateContainer(Container $container): void {
|
public function CreateContainer(Container $container): void {
|
||||||
$volumes = [];
|
$volumes = [];
|
||||||
foreach ($container->GetVolumes()->GetVolumes() as $volume) {
|
foreach ($container->volumes->GetVolumes() as $volume) {
|
||||||
// // NEXTCLOUD_MOUNT gets added via bind-mount later on
|
// // NEXTCLOUD_MOUNT gets added via bind-mount later on
|
||||||
// if ($container->GetIdentifier() === 'nextcloud-aio-nextcloud') {
|
// if ($container->identifier === 'nextcloud-aio-nextcloud') {
|
||||||
// if ($volume->name === $this->configurationManager->GetNextcloudMount()) {
|
// if ($volume->name === $this->configurationManager->GetNextcloudMount()) {
|
||||||
// continue;
|
// continue;
|
||||||
// }
|
// }
|
||||||
|
|
@ -228,7 +228,7 @@ readonly class DockerActionManager {
|
||||||
$requestBody['HostConfig']['Binds'] = $volumes;
|
$requestBody['HostConfig']['Binds'] = $volumes;
|
||||||
}
|
}
|
||||||
|
|
||||||
$aioVariables = $container->GetAioVariables()->GetVariables();
|
$aioVariables = $container->aioVariables->GetVariables();
|
||||||
foreach ($aioVariables as $variable) {
|
foreach ($aioVariables as $variable) {
|
||||||
$config = $this->configurationManager->GetConfig();
|
$config = $this->configurationManager->GetConfig();
|
||||||
$variable = $this->replaceEnvPlaceholders($variable);
|
$variable = $this->replaceEnvPlaceholders($variable);
|
||||||
|
|
@ -238,9 +238,9 @@ readonly class DockerActionManager {
|
||||||
sleep(1);
|
sleep(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
$envs = $container->GetEnvironmentVariables()->GetVariables();
|
$envs = $container->containerEnvironmentVariables->GetVariables();
|
||||||
// Special thing for the nextcloud container
|
// Special thing for the nextcloud container
|
||||||
if ($container->GetIdentifier() === 'nextcloud-aio-nextcloud') {
|
if ($container->identifier === 'nextcloud-aio-nextcloud') {
|
||||||
$envs[] = $this->GetAllNextcloudExecCommands();
|
$envs[] = $this->GetAllNextcloudExecCommands();
|
||||||
}
|
}
|
||||||
foreach ($envs as $key => $env) {
|
foreach ($envs as $key => $env) {
|
||||||
|
|
@ -251,13 +251,13 @@ readonly class DockerActionManager {
|
||||||
$requestBody['Env'] = $envs;
|
$requestBody['Env'] = $envs;
|
||||||
}
|
}
|
||||||
|
|
||||||
$requestBody['HostConfig']['RestartPolicy']['Name'] = $container->GetRestartPolicy();
|
$requestBody['HostConfig']['RestartPolicy']['Name'] = $container->restartPolicy;
|
||||||
|
|
||||||
$requestBody['HostConfig']['ReadonlyRootfs'] = $container->GetReadOnlySetting();
|
$requestBody['HostConfig']['ReadonlyRootfs'] = $container->readOnlyRootFs;
|
||||||
|
|
||||||
$exposedPorts = [];
|
$exposedPorts = [];
|
||||||
if ($container->GetInternalPort() !== 'host') {
|
if ($container->internalPorts !== 'host') {
|
||||||
foreach ($container->GetPorts()->GetPorts() as $value) {
|
foreach ($container->ports->GetPorts() as $value) {
|
||||||
$port = $value->port;
|
$port = $value->port;
|
||||||
$protocol = $value->protocol;
|
$protocol = $value->protocol;
|
||||||
if ($port === '%APACHE_PORT%') {
|
if ($port === '%APACHE_PORT%') {
|
||||||
|
|
@ -279,7 +279,7 @@ readonly class DockerActionManager {
|
||||||
|
|
||||||
if (count($exposedPorts) > 0) {
|
if (count($exposedPorts) > 0) {
|
||||||
$requestBody['ExposedPorts'] = $exposedPorts;
|
$requestBody['ExposedPorts'] = $exposedPorts;
|
||||||
foreach ($container->GetPorts()->GetPorts() as $value) {
|
foreach ($container->ports->GetPorts() as $value) {
|
||||||
$port = $value->port;
|
$port = $value->port;
|
||||||
$protocol = $value->protocol;
|
$protocol = $value->protocol;
|
||||||
if ($port === '%APACHE_PORT%') {
|
if ($port === '%APACHE_PORT%') {
|
||||||
|
|
@ -314,7 +314,7 @@ readonly class DockerActionManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
$devices = [];
|
$devices = [];
|
||||||
foreach ($container->GetDevices() as $device) {
|
foreach ($container->devices as $device) {
|
||||||
if ($device === '/dev/dri' && !$this->configurationManager->isDriDeviceEnabled()) {
|
if ($device === '/dev/dri' && !$this->configurationManager->isDriDeviceEnabled()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
@ -325,7 +325,7 @@ readonly class DockerActionManager {
|
||||||
$requestBody['HostConfig']['Devices'] = $devices;
|
$requestBody['HostConfig']['Devices'] = $devices;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($container->isNvidiaGpuEnabled() && $this->configurationManager->isNvidiaGpuEnabled()) {
|
if ($container->enableNvidiaGpu && $this->configurationManager->isNvidiaGpuEnabled()) {
|
||||||
$requestBody['HostConfig']['Runtime'] = 'nvidia';
|
$requestBody['HostConfig']['Runtime'] = 'nvidia';
|
||||||
$requestBody['HostConfig']['DeviceRequests'] = [
|
$requestBody['HostConfig']['DeviceRequests'] = [
|
||||||
[
|
[
|
||||||
|
|
@ -336,13 +336,13 @@ readonly class DockerActionManager {
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
$shmSize = $container->GetShmSize();
|
$shmSize = $container->shmSize;
|
||||||
if ($shmSize > 0) {
|
if ($shmSize > 0) {
|
||||||
$requestBody['HostConfig']['ShmSize'] = $shmSize;
|
$requestBody['HostConfig']['ShmSize'] = $shmSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
$tmpfs = [];
|
$tmpfs = [];
|
||||||
foreach ($container->GetTmpfs() as $tmp) {
|
foreach ($container->tmpfs as $tmp) {
|
||||||
$mode = "";
|
$mode = "";
|
||||||
if (str_contains($tmp, ':')) {
|
if (str_contains($tmp, ':')) {
|
||||||
$mode = explode(':', $tmp)[1];
|
$mode = explode(':', $tmp)[1];
|
||||||
|
|
@ -354,9 +354,9 @@ readonly class DockerActionManager {
|
||||||
$requestBody['HostConfig']['Tmpfs'] = $tmpfs;
|
$requestBody['HostConfig']['Tmpfs'] = $tmpfs;
|
||||||
}
|
}
|
||||||
|
|
||||||
$requestBody['HostConfig']['Init'] = $container->GetInit();
|
$requestBody['HostConfig']['Init'] = $container->init;
|
||||||
|
|
||||||
$capAdds = $container->GetCapAdds();
|
$capAdds = $container->capAdd;
|
||||||
if (count($capAdds) > 0) {
|
if (count($capAdds) > 0) {
|
||||||
$requestBody['HostConfig']['CapAdd'] = $capAdds;
|
$requestBody['HostConfig']['CapAdd'] = $capAdds;
|
||||||
}
|
}
|
||||||
|
|
@ -368,14 +368,14 @@ readonly class DockerActionManager {
|
||||||
|
|
||||||
// Disable SELinux for AIO containers so that it does not break them
|
// Disable SELinux for AIO containers so that it does not break them
|
||||||
$requestBody['HostConfig']['SecurityOpt'] = ["label:disable"];
|
$requestBody['HostConfig']['SecurityOpt'] = ["label:disable"];
|
||||||
if ($container->isApparmorUnconfined()) {
|
if ($container->apparmorUnconfined) {
|
||||||
$requestBody['HostConfig']['SecurityOpt'] = ["apparmor:unconfined", "label:disable"];
|
$requestBody['HostConfig']['SecurityOpt'] = ["apparmor:unconfined", "label:disable"];
|
||||||
}
|
}
|
||||||
|
|
||||||
$mounts = [];
|
$mounts = [];
|
||||||
|
|
||||||
// Special things for the backup container which should not be exposed in the containers.json
|
// Special things for the backup container which should not be exposed in the containers.json
|
||||||
if (str_starts_with($container->GetIdentifier(), 'nextcloud-aio-borgbackup')) {
|
if (str_starts_with($container->identifier, 'nextcloud-aio-borgbackup')) {
|
||||||
// Additional backup directories
|
// Additional backup directories
|
||||||
foreach ($this->getAllBackupVolumes() as $additionalBackupVolumes) {
|
foreach ($this->getAllBackupVolumes() as $additionalBackupVolumes) {
|
||||||
if ($additionalBackupVolumes !== '') {
|
if ($additionalBackupVolumes !== '') {
|
||||||
|
|
@ -384,7 +384,7 @@ readonly class DockerActionManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make volumes read only in case of borgbackup container. The viewer makes them writeable
|
// Make volumes read only in case of borgbackup container. The viewer makes them writeable
|
||||||
$isReadOnly = $container->GetIdentifier() === 'nextcloud-aio-borgbackup';
|
$isReadOnly = $container->identifier === 'nextcloud-aio-borgbackup';
|
||||||
|
|
||||||
foreach ($this->configurationManager->GetAdditionalBackupDirectoriesArray() as $additionalBackupDirectories) {
|
foreach ($this->configurationManager->GetAdditionalBackupDirectoriesArray() as $additionalBackupDirectories) {
|
||||||
if ($additionalBackupDirectories !== '') {
|
if ($additionalBackupDirectories !== '') {
|
||||||
|
|
@ -397,12 +397,12 @@ readonly class DockerActionManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Special things for the talk container which should not be exposed in the containers.json
|
// Special things for the talk container which should not be exposed in the containers.json
|
||||||
} elseif ($container->GetIdentifier() === 'nextcloud-aio-talk') {
|
} elseif ($container->identifier === 'nextcloud-aio-talk') {
|
||||||
// This is needed due to a bug in libwebsockets used in Janus which cannot handle unlimited ulimits
|
// This is needed due to a bug in libwebsockets used in Janus which cannot handle unlimited ulimits
|
||||||
$requestBody['HostConfig']['Ulimits'] = [["Name" => "nofile", "Hard" => 200000, "Soft" => 200000]];
|
$requestBody['HostConfig']['Ulimits'] = [["Name" => "nofile", "Hard" => 200000, "Soft" => 200000]];
|
||||||
// // Special things for the nextcloud container which should not be exposed in the containers.json
|
// // Special things for the nextcloud container which should not be exposed in the containers.json
|
||||||
// } elseif ($container->GetIdentifier() === 'nextcloud-aio-nextcloud') {
|
// } elseif ($container->identifier === 'nextcloud-aio-nextcloud') {
|
||||||
// foreach ($container->GetVolumes()->GetVolumes() as $volume) {
|
// foreach ($container->volumes->GetVolumes() as $volume) {
|
||||||
// if ($volume->name !== $this->configurationManager->GetNextcloudMount()) {
|
// if ($volume->name !== $this->configurationManager->GetNextcloudMount()) {
|
||||||
// continue;
|
// continue;
|
||||||
// }
|
// }
|
||||||
|
|
@ -410,11 +410,11 @@ readonly class DockerActionManager {
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// Special things for the caddy community container
|
// Special things for the caddy community container
|
||||||
} elseif ($container->GetIdentifier() === 'nextcloud-aio-caddy') {
|
} elseif ($container->identifier === 'nextcloud-aio-caddy') {
|
||||||
$requestBody['HostConfig']['ExtraHosts'] = ['host.docker.internal:host-gateway'];
|
$requestBody['HostConfig']['ExtraHosts'] = ['host.docker.internal:host-gateway'];
|
||||||
|
|
||||||
// Special things for the collabora container which should not be exposed in the containers.json
|
// Special things for the collabora container which should not be exposed in the containers.json
|
||||||
} elseif ($container->GetIdentifier() === 'nextcloud-aio-collabora') {
|
} elseif ($container->identifier === 'nextcloud-aio-collabora') {
|
||||||
if (!$this->configurationManager->isSeccompDisabled()) {
|
if (!$this->configurationManager->isSeccompDisabled()) {
|
||||||
// Load reference seccomp profile for collabora
|
// Load reference seccomp profile for collabora
|
||||||
$seccompProfile = (string)file_get_contents(DataConst::GetCollaboraSeccompProfilePath());
|
$seccompProfile = (string)file_get_contents(DataConst::GetCollaboraSeccompProfilePath());
|
||||||
|
|
@ -437,9 +437,9 @@ readonly class DockerActionManager {
|
||||||
$requestBody['Labels'] = ["com.centurylinklabs.watchtower.enable" => "false", "diun.enable" => "false", "org.label-schema.vendor" => "Nextcloud", "com.docker.compose.project" => "nextcloud-aio"];
|
$requestBody['Labels'] = ["com.centurylinklabs.watchtower.enable" => "false", "diun.enable" => "false", "org.label-schema.vendor" => "Nextcloud", "com.docker.compose.project" => "nextcloud-aio"];
|
||||||
|
|
||||||
// Containers should have a fixed host name. See https://github.com/nextcloud/all-in-one/discussions/6589
|
// Containers should have a fixed host name. See https://github.com/nextcloud/all-in-one/discussions/6589
|
||||||
$requestBody['Hostname'] = $container->GetIdentifier();
|
$requestBody['Hostname'] = $container->identifier;
|
||||||
|
|
||||||
$url = $this->BuildApiUrl('containers/create?name=' . $container->GetIdentifier());
|
$url = $this->BuildApiUrl('containers/create?name=' . $container->identifier);
|
||||||
try {
|
try {
|
||||||
$this->guzzleClient->request(
|
$this->guzzleClient->request(
|
||||||
'POST',
|
'POST',
|
||||||
|
|
@ -449,18 +449,18 @@ readonly class DockerActionManager {
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
} catch (RequestException $e) {
|
} catch (RequestException $e) {
|
||||||
throw new \Exception("Could not create container " . $container->GetIdentifier() . ": " . $e->getResponse()?->getBody()->getContents());
|
throw new \Exception("Could not create container " . $container->identifier . ": " . $e->getResponse()?->getBody()->getContents());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function isRegistryReachable(Container $container): bool {
|
public function isRegistryReachable(Container $container): bool {
|
||||||
$tag = $container->GetImageTag();
|
$tag = $container->imageTag;
|
||||||
if ($tag === '%AIO_CHANNEL%') {
|
if ($tag === '%AIO_CHANNEL%') {
|
||||||
$tag = $this->GetCurrentChannel();
|
$tag = $this->GetCurrentChannel();
|
||||||
}
|
}
|
||||||
|
|
||||||
$remoteDigest = $this->GetLatestDigestOfTag($container->GetContainerName(), $tag);
|
$remoteDigest = $this->GetLatestDigestOfTag($container->containerName, $tag);
|
||||||
|
|
||||||
if ($remoteDigest === null) {
|
if ($remoteDigest === null) {
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -472,7 +472,7 @@ readonly class DockerActionManager {
|
||||||
public function PullImage(Container $container, bool $pullImage = true): void {
|
public function PullImage(Container $container, bool $pullImage = true): void {
|
||||||
|
|
||||||
// Skip database image pull if the last shutdown was not clean
|
// Skip database image pull if the last shutdown was not clean
|
||||||
if ($container->GetIdentifier() === 'nextcloud-aio-database') {
|
if ($container->identifier === 'nextcloud-aio-database') {
|
||||||
if ($this->GetDatabasecontainerExitCode() > 0) {
|
if ($this->GetDatabasecontainerExitCode() > 0) {
|
||||||
$pullImage = false;
|
$pullImage = false;
|
||||||
error_log('Not pulling the latest database image because the container was not correctly shut down.');
|
error_log('Not pulling the latest database image because the container was not correctly shut down.');
|
||||||
|
|
@ -484,7 +484,7 @@ readonly class DockerActionManager {
|
||||||
if ($pullImage) {
|
if ($pullImage) {
|
||||||
if (!$this->isRegistryReachable($container)) {
|
if (!$this->isRegistryReachable($container)) {
|
||||||
$pullImage = false;
|
$pullImage = false;
|
||||||
error_log('Not pulling the ' . $container->GetContainerName() . ' image for the ' . $container->GetIdentifier() . ' container because the registry does not seem to be reachable.');
|
error_log('Not pulling the ' . $container->containerName . ' image for the ' . $container->identifier . ' container because the registry does not seem to be reachable.');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -598,7 +598,7 @@ readonly class DockerActionManager {
|
||||||
if ($container->GetUpdateState() === VersionState::Different) {
|
if ($container->GetUpdateState() === VersionState::Different) {
|
||||||
$updateAvailable = '1';
|
$updateAvailable = '1';
|
||||||
}
|
}
|
||||||
foreach ($container->GetDependsOn() as $dependency) {
|
foreach ($container->dependsOn as $dependency) {
|
||||||
$updateAvailable .= $this->isContainerUpdateAvailable($dependency);
|
$updateAvailable .= $this->isContainerUpdateAvailable($dependency);
|
||||||
}
|
}
|
||||||
return $updateAvailable;
|
return $updateAvailable;
|
||||||
|
|
@ -622,10 +622,10 @@ readonly class DockerActionManager {
|
||||||
$container = $this->containerDefinitionFetcher->GetContainerById($id);
|
$container = $this->containerDefinitionFetcher->GetContainerById($id);
|
||||||
|
|
||||||
$backupVolumes = '';
|
$backupVolumes = '';
|
||||||
foreach ($container->GetBackupVolumes() as $backupVolume) {
|
foreach ($container->backupVolumes as $backupVolume) {
|
||||||
$backupVolumes .= $backupVolume . ' ';
|
$backupVolumes .= $backupVolume . ' ';
|
||||||
}
|
}
|
||||||
foreach ($container->GetDependsOn() as $dependency) {
|
foreach ($container->dependsOn as $dependency) {
|
||||||
$backupVolumes .= $this->getBackupVolumes($dependency);
|
$backupVolumes .= $this->getBackupVolumes($dependency);
|
||||||
}
|
}
|
||||||
return $backupVolumes;
|
return $backupVolumes;
|
||||||
|
|
@ -641,10 +641,10 @@ readonly class DockerActionManager {
|
||||||
$container = $this->containerDefinitionFetcher->GetContainerById($id);
|
$container = $this->containerDefinitionFetcher->GetContainerById($id);
|
||||||
|
|
||||||
$nextcloudExecCommands = '';
|
$nextcloudExecCommands = '';
|
||||||
foreach ($container->GetNextcloudExecCommands() as $execCommand) {
|
foreach ($container->nextcloudExecCommands as $execCommand) {
|
||||||
$nextcloudExecCommands .= $execCommand . PHP_EOL;
|
$nextcloudExecCommands .= $execCommand . PHP_EOL;
|
||||||
}
|
}
|
||||||
foreach ($container->GetDependsOn() as $dependency) {
|
foreach ($container->dependsOn as $dependency) {
|
||||||
$nextcloudExecCommands .= $this->GetNextcloudExecCommands($dependency);
|
$nextcloudExecCommands .= $this->GetNextcloudExecCommands($dependency);
|
||||||
}
|
}
|
||||||
return $nextcloudExecCommands;
|
return $nextcloudExecCommands;
|
||||||
|
|
@ -776,7 +776,7 @@ readonly class DockerActionManager {
|
||||||
public function sendNotification(Container $container, string $subject, string $message, string $file = '/notify.sh'): void {
|
public function sendNotification(Container $container, string $subject, string $message, string $file = '/notify.sh'): void {
|
||||||
if ($this->GetContainerStartingState($container) === ContainerState::Running) {
|
if ($this->GetContainerStartingState($container) === ContainerState::Running) {
|
||||||
|
|
||||||
$containerName = $container->GetIdentifier();
|
$containerName = $container->identifier;
|
||||||
|
|
||||||
// schedule the exec
|
// schedule the exec
|
||||||
$url = $this->BuildApiUrl(sprintf('containers/%s/exec', urlencode($containerName)));
|
$url = $this->BuildApiUrl(sprintf('containers/%s/exec', urlencode($containerName)));
|
||||||
|
|
@ -901,14 +901,14 @@ readonly class DockerActionManager {
|
||||||
// Add a secondary alias for domaincheck container, to keep it as similar to actual apache controller as possible.
|
// Add a secondary alias for domaincheck container, to keep it as similar to actual apache controller as possible.
|
||||||
// If a reverse-proxy is relying on container name as hostname this allows it to operate as usual and still validate the domain
|
// If a reverse-proxy is relying on container name as hostname this allows it to operate as usual and still validate the domain
|
||||||
// The domaincheck container and apache container are never supposed to be active at the same time because they use the same APACHE_PORT anyway, so this doesn't add any new constraints.
|
// The domaincheck container and apache container are never supposed to be active at the same time because they use the same APACHE_PORT anyway, so this doesn't add any new constraints.
|
||||||
$alias = ($container->GetIdentifier() === 'nextcloud-aio-domaincheck') ? 'nextcloud-aio-apache' : '';
|
$alias = ($container->identifier === 'nextcloud-aio-domaincheck') ? 'nextcloud-aio-apache' : '';
|
||||||
|
|
||||||
$this->ConnectContainerIdToNetwork($container->GetIdentifier(), $container->GetInternalPort(), alias: $alias);
|
$this->ConnectContainerIdToNetwork($container->identifier, $container->internalPorts, alias: $alias);
|
||||||
|
|
||||||
if ($container->GetIdentifier() === 'nextcloud-aio-apache' || $container->GetIdentifier() === 'nextcloud-aio-domaincheck') {
|
if ($container->identifier === 'nextcloud-aio-apache' || $container->identifier === 'nextcloud-aio-domaincheck') {
|
||||||
$apacheAdditionalNetwork = $this->configurationManager->GetApacheAdditionalNetwork();
|
$apacheAdditionalNetwork = $this->configurationManager->GetApacheAdditionalNetwork();
|
||||||
if ($apacheAdditionalNetwork !== '') {
|
if ($apacheAdditionalNetwork !== '') {
|
||||||
$this->ConnectContainerIdToNetwork($container->GetIdentifier(), $container->GetInternalPort(), $apacheAdditionalNetwork, false, $alias);
|
$this->ConnectContainerIdToNetwork($container->identifier, $container->internalPorts, $apacheAdditionalNetwork, false, $alias);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -917,9 +917,9 @@ readonly class DockerActionManager {
|
||||||
if ($forceStopContainer) {
|
if ($forceStopContainer) {
|
||||||
$maxShutDownTime = 10;
|
$maxShutDownTime = 10;
|
||||||
} else {
|
} else {
|
||||||
$maxShutDownTime = $container->GetMaxShutdownTime();
|
$maxShutDownTime = $container->maxShutdownTime;
|
||||||
}
|
}
|
||||||
$url = $this->BuildApiUrl(sprintf('containers/%s/stop?t=%s', urlencode($container->GetIdentifier()), $maxShutDownTime));
|
$url = $this->BuildApiUrl(sprintf('containers/%s/stop?t=%s', urlencode($container->identifier), $maxShutDownTime));
|
||||||
try {
|
try {
|
||||||
$this->guzzleClient->post($url);
|
$this->guzzleClient->post($url);
|
||||||
} catch (RequestException $e) {
|
} catch (RequestException $e) {
|
||||||
|
|
|
||||||
|
|
@ -3,24 +3,24 @@
|
||||||
<span>
|
<span>
|
||||||
{% if c.GetStartingState().value == 'starting' %}
|
{% if c.GetStartingState().value == 'starting' %}
|
||||||
<span class="status running"></span>
|
<span class="status running"></span>
|
||||||
{{ c.GetDisplayName() }}
|
{{ c.displayName }}
|
||||||
(<a href="api/docker/logs?id={{ c.GetIdentifier() }}" target="_blank">Starting</a>)
|
(<a href="api/docker/logs?id={{ c.identifier }}" target="_blank">Starting</a>)
|
||||||
{% elseif c.GetRunningState().value == 'running' %}
|
{% elseif c.GetRunningState().value == 'running' %}
|
||||||
<span class="status success"></span>
|
<span class="status success"></span>
|
||||||
{{ c.GetDisplayName() }}
|
{{ c.displayName }}
|
||||||
(<a href="api/docker/logs?id={{ c.GetIdentifier() }}" target="_blank">Running</a>)
|
(<a href="api/docker/logs?id={{ c.identifier }}" target="_blank">Running</a>)
|
||||||
{% else %}
|
{% else %}
|
||||||
<span class="status error"></span>
|
<span class="status error"></span>
|
||||||
{{ c.GetDisplayName() }}
|
{{ c.displayName }}
|
||||||
(<a href="api/docker/logs?id={{ c.GetIdentifier() }}" target="_blank">Stopped</a>)
|
(<a href="api/docker/logs?id={{ c.identifier }}" target="_blank">Stopped</a>)
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if c.GetDocumentation() != '' %}
|
{% if c.documentation != '' %}
|
||||||
(<a target="_blank" href="{{ c.GetDocumentation() }}">docs</a>)
|
(<a target="_blank" href="{{ c.documentation }}">docs</a>)
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</span>
|
</span>
|
||||||
{% if c.GetUiSecret() != '' %}
|
{% if c.GetUiSecret() != '' %}
|
||||||
<details>
|
<details>
|
||||||
<summary>Show password for {{ c.GetDisplayName() }}</summary>
|
<summary>Show password for {{ c.displayName }}</summary>
|
||||||
<input type="text" value="{{ c.GetUiSecret() }}" readonly>
|
<input type="text" value="{{ c.GetUiSecret() }}" readonly>
|
||||||
</details>
|
</details>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
|
||||||
|
|
@ -45,19 +45,19 @@
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% for container in containers %}
|
{% for container in containers %}
|
||||||
{% if container.GetDisplayName() != '' and container.GetRunningState().value == 'running' %}
|
{% if container.displayName != '' and container.GetRunningState().value == 'running' %}
|
||||||
{% set isAnyRunning = true %}
|
{% set isAnyRunning = true %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if container.GetDisplayName() != '' and container.GetRestartingState().value == 'restarting' %}
|
{% if container.displayName != '' and container.GetRestartingState().value == 'restarting' %}
|
||||||
{% set isAnyRestarting = true %}
|
{% set isAnyRestarting = true %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if container.GetIdentifier() == 'nextcloud-aio-watchtower' and container.GetRunningState().value == 'running' %}
|
{% if container.identifier == 'nextcloud-aio-watchtower' and container.GetRunningState().value == 'running' %}
|
||||||
{% set isWatchtowerRunning = true %}
|
{% set isWatchtowerRunning = true %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if container.GetIdentifier() == 'nextcloud-aio-domaincheck' and container.GetRunningState().value == 'running' %}
|
{% if container.identifier == 'nextcloud-aio-domaincheck' and container.GetRunningState().value == 'running' %}
|
||||||
{% set isDomaincheckRunning = true %}
|
{% set isDomaincheckRunning = true %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if container.GetIdentifier() == 'nextcloud-aio-apache' and container.GetStartingState().value == 'starting' %}
|
{% if container.identifier == 'nextcloud-aio-apache' and container.GetStartingState().value == 'starting' %}
|
||||||
{% set isApacheStarting = true %}
|
{% set isApacheStarting = true %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
@ -280,7 +280,7 @@
|
||||||
<ul>
|
<ul>
|
||||||
{# @var containers \AIO\Container\Container[] #}
|
{# @var containers \AIO\Container\Container[] #}
|
||||||
{% for container in containers %}
|
{% for container in containers %}
|
||||||
{% if container.GetDisplayName() != '' %}
|
{% if container.displayName != '' %}
|
||||||
{% include 'components/container-state.twig' with {'c': container} only %}
|
{% include 'components/container-state.twig' with {'c': container} only %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue