Merge pull request #1656 from nextcloud/enh/noid/fix-exposing-containers

fix exposing containers
This commit is contained in:
Simon L 2023-01-02 17:55:32 +01:00 committed by GitHub
commit 454269ec5b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 18 deletions

View file

@ -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;

View file

@ -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'],

View file

@ -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,