mirror of
https://github.com/nextcloud/all-in-one.git
synced 2024-12-26 08:41:07 +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 {
|
||||
public string $port;
|
||||
public string $ipBinding;
|
||||
public bool $protocol;
|
||||
public string $protocol;
|
||||
|
||||
public function __construct(
|
||||
string $port,
|
||||
string $ipBinding,
|
||||
bool $protocol
|
||||
string $protocol
|
||||
) {
|
||||
$this->port = $port;
|
||||
$this->ipBinding = $ipBinding;
|
||||
|
|
|
@ -77,6 +77,17 @@ class ContainerDefinitionFetcher
|
|||
|
||||
$ports = new ContainerPorts();
|
||||
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(
|
||||
new ContainerPort(
|
||||
$value['port_number'],
|
||||
|
|
|
@ -361,31 +361,19 @@ class DockerActionManager
|
|||
$exposedPorts = [];
|
||||
if ($container->GetInternalPort() !== 'host') {
|
||||
foreach($container->GetPorts()->GetPorts() as $value) {
|
||||
$exposedPorts[$value->port] = null;
|
||||
$portWithProtocol = $value->port . '/' . $value->protocol;
|
||||
$exposedPorts[$portWithProtocol] = null;
|
||||
}
|
||||
}
|
||||
|
||||
if(count($exposedPorts) > 0) {
|
||||
$requestBody['ExposedPorts'] = $exposedPorts;
|
||||
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] = [
|
||||
$requestBody['HostConfig']['PortBindings'][$portWithProtocol] = [
|
||||
[
|
||||
'HostPort' => $port,
|
||||
'HostIp' => $ipBinding,
|
||||
|
|
Loading…
Reference in a new issue