Skip to content

Commit

Permalink
Main Network aliases bug fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
Ph3nol committed Oct 12, 2017
1 parent 3b8a7c9 commit 8568f66
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
20 changes: 18 additions & 2 deletions src/Application/DockerContainer/NginxDockerContainer.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use Ph3\DockerArch\Application\Architect;
use Ph3\DockerArch\Domain\DockerContainer\Model\DockerContainer;
use Ph3\DockerArch\Domain\DockerContainer\Model\DockerContainerInterface;
use Ph3\DockerArch\Domain\Service\Model\ServiceInterface;
use Ph3\DockerArch\Domain\TemplatedFile\Model\TemplatedFile;

/**
Expand Down Expand Up @@ -73,19 +74,34 @@ public function execute(): void
*/
public function postExecute(): void
{
$service = $this->getService();

// UI.
$port = reset($this->getService()->getDockerContainer()->getPorts());
$port = reset($service->getDockerContainer()->getPorts());
foreach ($this->vhostsServicesByHost as $vhostService) {
if (null === $vhostService->getHost()) {
continue;
}

$this->getService()->addUIAccess([
$service->addUIAccess([
'host' => $vhostService->getHost(),
'port' => $port['from'],
'label' => 'Web Access ('.$vhostService->getHost().')',
]);
}

// Main Network Aliases.
$isServiceNetworkAliasable = function (ServiceInterface $service) {
return (null !== $service->getHost() && 'localhost' !== $service->getHost());
};
if (true === $isServiceNetworkAliasable($service)) {
$this->addNetworkAlias(self::DOCKER_MAIN_NETWORK, $service->getHost());
}
foreach ($this->vhostsServicesByHost as $vhostService) {
if ($isServiceNetworkAliasable($vhostService)) {
$this->addNetworkAlias(self::DOCKER_MAIN_NETWORK, $vhostService->getHost());
}
}
}

/**
Expand Down
4 changes: 0 additions & 4 deletions src/Domain/DockerContainer/Model/DockerContainer.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,6 @@ private function init(): void
*/
public function preExecute(): void
{
$service= $this->getService();
if (null !== $service->getHost() && 'localhost' !== $service->getHost()) {
$this->addNetworkAlias(self::DOCKER_MAIN_NETWORK, $service->getHost());
}
}

/**
Expand Down

0 comments on commit 8568f66

Please sign in to comment.