fix: domains for compose bp

This commit is contained in:
Andras Bacsai 2023-12-15 11:00:51 +01:00
parent ab2f9f073f
commit 3b6d3343c7
2 changed files with 72 additions and 66 deletions

View File

@ -146,7 +146,6 @@ class General extends Component
$this->parsedServiceDomains[$serviceName]['domain'] = $domain; $this->parsedServiceDomains[$serviceName]['domain'] = $domain;
$this->application->docker_compose_domains = json_encode($this->parsedServiceDomains); $this->application->docker_compose_domains = json_encode($this->parsedServiceDomains);
$this->application->save(); $this->application->save();
$this->dispatch('success', 'Domain generated.');
} }
return $domain; return $domain;
} }

View File

@ -966,9 +966,6 @@ class Application extends BaseModel
function loadComposeFile($isInit = false) function loadComposeFile($isInit = false)
{ {
$initialDockerComposeLocation = $this->docker_compose_location; $initialDockerComposeLocation = $this->docker_compose_location;
$initialDockerComposeRaw = $this->docker_compose_raw;
// $initialDockerComposePrLocation = $this->docker_compose_pr_location;
if ($this->build_pack === 'dockercompose') {
if ($isInit && $this->docker_compose_raw) { if ($isInit && $this->docker_compose_raw) {
return; return;
} }
@ -1022,8 +1019,19 @@ class Application extends BaseModel
]); ]);
instant_remote_process($commands, $this->destination->server, false); instant_remote_process($commands, $this->destination->server, false);
$parsedServices = $this->parseCompose(); $parsedServices = $this->parseCompose();
if (md5($this->docker_compose_raw) !== md5($initialDockerComposeRaw)) { if ($this->docker_compose_domains) {
$json = collect(json_decode($this->docker_compose_domains));
$names = collect(data_get($parsedServices, 'services'))->keys()->toArray();
$jsonNames = $json->keys()->toArray();
$diff = array_diff($jsonNames, $names);
$json = $json->filter(function ($value, $key) use ($diff) {
return !in_array($key, $diff);
});
if ($json) {
$this->docker_compose_domains = json_encode($json);
} else {
$this->docker_compose_domains = null; $this->docker_compose_domains = null;
}
$this->save(); $this->save();
} }
return [ return [
@ -1032,7 +1040,6 @@ class Application extends BaseModel
'initialDockerComposePrLocation' => $this->docker_compose_pr_location, 'initialDockerComposePrLocation' => $this->docker_compose_pr_location,
]; ];
} }
}
function parseContainerLabels(?ApplicationPreview $preview = null) function parseContainerLabels(?ApplicationPreview $preview = null)
{ {
$customLabels = data_get($this, 'custom_labels'); $customLabels = data_get($this, 'custom_labels');