mirror of
https://github.com/nextcloud/all-in-one.git
synced 2024-12-27 01:02:10 +08:00
Merge pull request #1656 from nextcloud/enh/noid/fix-exposing-containers
fix exposing containers
This commit is contained in:
commit
454269ec5b
3 changed files with 17 additions and 18 deletions
|
@ -5,12 +5,12 @@ namespace AIO\Container;
|
||||||
class ContainerPort {
|
class ContainerPort {
|
||||||
public string $port;
|
public string $port;
|
||||||
public string $ipBinding;
|
public string $ipBinding;
|
||||||
public bool $protocol;
|
public string $protocol;
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
string $port,
|
string $port,
|
||||||
string $ipBinding,
|
string $ipBinding,
|
||||||
bool $protocol
|
string $protocol
|
||||||
) {
|
) {
|
||||||
$this->port = $port;
|
$this->port = $port;
|
||||||
$this->ipBinding = $ipBinding;
|
$this->ipBinding = $ipBinding;
|
||||||
|
|
|
@ -77,6 +77,17 @@ class ContainerDefinitionFetcher
|
||||||
|
|
||||||
$ports = new ContainerPorts();
|
$ports = new ContainerPorts();
|
||||||
foreach ($entry['ports'] as $value) {
|
foreach ($entry['ports'] as $value) {
|
||||||
|
|
||||||
|
if ($value['port_number'] === '%APACHE_PORT%') {
|
||||||
|
$value['port_number'] = $this->configurationManager->GetApachePort();
|
||||||
|
} elseif ($value['port_number'] === '%TALK_PORT%') {
|
||||||
|
$value['port_number'] = $this->configurationManager->GetTalkPort();
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($value['ip_binding'] === '%APACHE_IP_BINDING%') {
|
||||||
|
$value['ip_binding'] = $this->configurationManager->GetApacheIPBinding();
|
||||||
|
}
|
||||||
|
|
||||||
$ports->AddPort(
|
$ports->AddPort(
|
||||||
new ContainerPort(
|
new ContainerPort(
|
||||||
$value['port_number'],
|
$value['port_number'],
|
||||||
|
|
|
@ -361,31 +361,19 @@ class DockerActionManager
|
||||||
$exposedPorts = [];
|
$exposedPorts = [];
|
||||||
if ($container->GetInternalPort() !== 'host') {
|
if ($container->GetInternalPort() !== 'host') {
|
||||||
foreach($container->GetPorts()->GetPorts() as $value) {
|
foreach($container->GetPorts()->GetPorts() as $value) {
|
||||||
$exposedPorts[$value->port] = null;
|
$portWithProtocol = $value->port . '/' . $value->protocol;
|
||||||
|
$exposedPorts[$portWithProtocol] = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(count($exposedPorts) > 0) {
|
if(count($exposedPorts) > 0) {
|
||||||
|
$requestBody['ExposedPorts'] = $exposedPorts;
|
||||||
foreach ($container->GetPorts()->GetPorts() as $value) {
|
foreach ($container->GetPorts()->GetPorts() as $value) {
|
||||||
$port = $value->port;
|
$port = $value->port;
|
||||||
if($port === '%APACHE_PORT%') {
|
|
||||||
$port = $this->configurationManager->GetApachePort();
|
|
||||||
} elseif($port === '%TALK_PORT%') {
|
|
||||||
$port = $this->configurationManager->GetTalkPort();
|
|
||||||
}
|
|
||||||
|
|
||||||
$ipBinding = $value->ipBinding;
|
$ipBinding = $value->ipBinding;
|
||||||
if($ipBinding === '%APACHE_IP_BINDING%') {
|
|
||||||
$ipBinding = $this->configurationManager->GetApacheIPBinding();
|
|
||||||
}
|
|
||||||
if ($ipBinding === '') {
|
|
||||||
$ipBinding = '0.0.0.0';
|
|
||||||
}
|
|
||||||
|
|
||||||
$protocol = $value->protocol;
|
$protocol = $value->protocol;
|
||||||
$portWithProtocol = $port . '/' . $protocol;
|
$portWithProtocol = $port . '/' . $protocol;
|
||||||
$requestBody['ExposedPorts'][$portWithProtocol] = null;
|
$requestBody['HostConfig']['PortBindings'][$portWithProtocol] = [
|
||||||
$requestBody['HostConfig']['PortBindings'][$port] = [
|
|
||||||
[
|
[
|
||||||
'HostPort' => $port,
|
'HostPort' => $port,
|
||||||
'HostIp' => $ipBinding,
|
'HostIp' => $ipBinding,
|
||||||
|
|
Loading…
Reference in a new issue