mirror of
https://github.com/nextcloud/all-in-one.git
synced 2025-12-20 14:36:52 +00:00
refactor containerports
Signed-off-by: Simon L <szaimen@e.mail.de>
This commit is contained in:
parent
1194b7a1ff
commit
5dc9fad2d6
6 changed files with 103 additions and 47 deletions
|
|
@ -125,6 +125,12 @@ class DockerActionManager
|
|||
|
||||
$containerName = $container->GetIdentifier();
|
||||
$internalPort = $container->GetInternalPort();
|
||||
if($internalPort === '%APACHE_PORT%') {
|
||||
$internalPort = $this->configurationManager->GetApachePort();
|
||||
} elseif($internalPort === '%TALK_PORT%') {
|
||||
$internalPort = $this->configurationManager->GetTalkPort();
|
||||
}
|
||||
|
||||
if ($internalPort !== "" && $internalPort !== 'host') {
|
||||
$connection = @fsockopen($containerName, (int)$internalPort, $errno, $errstr, 0.1);
|
||||
if ($connection) {
|
||||
|
|
@ -216,13 +222,6 @@ class DockerActionManager
|
|||
$volumes[] = $volumeEntry;
|
||||
}
|
||||
|
||||
$exposedPorts = [];
|
||||
if ($container->GetInternalPort() !== 'host') {
|
||||
foreach($container->GetPorts()->GetPorts() as $port) {
|
||||
$exposedPorts[$port] = null;
|
||||
}
|
||||
}
|
||||
|
||||
$requestBody = [
|
||||
'Image' => $this->BuildImageName($container),
|
||||
];
|
||||
|
|
@ -358,25 +357,40 @@ class DockerActionManager
|
|||
}
|
||||
|
||||
$requestBody['HostConfig']['RestartPolicy']['Name'] = $container->GetRestartPolicy();
|
||||
|
||||
$exposedPorts = [];
|
||||
if ($container->GetInternalPort() !== 'host') {
|
||||
foreach($container->GetPorts()->GetPorts() as $value) {
|
||||
$exposedPorts[$value->port] = null;
|
||||
}
|
||||
}
|
||||
|
||||
if(count($exposedPorts) > 0) {
|
||||
$requestBody['ExposedPorts'] = $exposedPorts;
|
||||
foreach ($container->GetPorts()->GetPorts() as $port) {
|
||||
$portNumber = explode("/", $port);
|
||||
if ($this->configurationManager->GetApachePort() === $portNumber[0] && $this->configurationManager->GetApacheIPBinding() !== '') {
|
||||
$requestBody['HostConfig']['PortBindings'][$port] = [
|
||||
[
|
||||
'HostPort' => $portNumber[0],
|
||||
'HostIp' => $this->configurationManager->GetApacheIPBinding(),
|
||||
]
|
||||
];
|
||||
} else {
|
||||
$requestBody['HostConfig']['PortBindings'][$port] = [
|
||||
[
|
||||
'HostPort' => $portNumber[0],
|
||||
]
|
||||
];
|
||||
foreach ($container->GetPorts()->GetPorts() as $value) {
|
||||
$port = $value->port;
|
||||
if($port === '%APACHE_PORT%') {
|
||||
$port = $this->configurationManager->GetApachePort();
|
||||
} elseif($port === '%TALK_PORT%') {
|
||||
$port = $this->configurationManager->GetTalkPort();
|
||||
}
|
||||
|
||||
$ipBinding = $value->ipBinding;
|
||||
if($ipBinding === '%APACHE_IP_BINDING%') {
|
||||
$ipBinding = $this->configurationManager->GetApacheIPBinding();
|
||||
}
|
||||
if ($ipBinding === '') {
|
||||
$ipBinding = '0.0.0.0';
|
||||
}
|
||||
|
||||
$protocol = $value->protocol;
|
||||
$portWithProtocol = $port . '/' . $protocol;
|
||||
$requestBody['ExposedPorts'][$portWithProtocol] = null;
|
||||
$requestBody['HostConfig']['PortBindings'][$port] = [
|
||||
[
|
||||
'HostPort' => $port,
|
||||
'HostIp' => $ipBinding,
|
||||
]
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue