Refactor EditDomain.php and shared.php to improve DockerCompose parsing logic

This commit is contained in:
Andras Bacsai 2024-04-16 12:41:21 +02:00
parent 3935a3c885
commit 8164610105
2 changed files with 10 additions and 3 deletions

View File

@ -41,7 +41,7 @@ public function submit()
} catch (\Throwable $e) { } catch (\Throwable $e) {
return handleError($e, $this); return handleError($e, $this);
} finally { } finally {
$this->dispatch('generateDockerCompose'); $this->application->service->parse();
$this->dispatch('refresh'); $this->dispatch('refresh');
$this->dispatch('configurationChanged'); $this->dispatch('configurationChanged');
} }

View File

@ -980,15 +980,18 @@ function parseDockerComposeFile(Service|Application $resource, bool $isNew = fal
]); ]);
} }
// Caddy needs exact port in some cases. // Caddy needs exact port in some cases.
ray($predefinedPort);
if ($predefinedPort && !$key->endsWith("_{$predefinedPort}")) { if ($predefinedPort && !$key->endsWith("_{$predefinedPort}")) {
$fqdns_exploded = str($savedService->fqdn)->explode(',');
if ($fqdns_exploded->count() > 1) {
continue;
}
if ($resource->server->proxyType() === 'CADDY') { if ($resource->server->proxyType() === 'CADDY') {
$env = EnvironmentVariable::where([ $env = EnvironmentVariable::where([
'key' => $key, 'key' => $key,
'service_id' => $resource->id, 'service_id' => $resource->id,
])->first(); ])->first();
ray($env);
if ($env) { if ($env) {
$env_url = Url::fromString($savedService->fqdn); $env_url = Url::fromString($savedService->fqdn);
$env_port = $env_url->getPort(); $env_port = $env_url->getPort();
if ($env_port !== $predefinedPort) { if ($env_port !== $predefinedPort) {
@ -1050,6 +1053,10 @@ function parseDockerComposeFile(Service|Application $resource, bool $isNew = fal
} }
// Caddy needs exact port in some cases. // Caddy needs exact port in some cases.
if ($predefinedPort && !$key->endsWith("_{$predefinedPort}") && $command?->value() === 'FQDN' && $resource->server->proxyType() === 'CADDY') { if ($predefinedPort && !$key->endsWith("_{$predefinedPort}") && $command?->value() === 'FQDN' && $resource->server->proxyType() === 'CADDY') {
$fqdns_exploded = str($savedService->fqdn)->explode(',');
if ($fqdns_exploded->count() > 1) {
continue;
}
$env = EnvironmentVariable::where([ $env = EnvironmentVariable::where([
'key' => $key, 'key' => $key,
'service_id' => $resource->id, 'service_id' => $resource->id,