fix(compose): normalize service-name keys for domains and env vars (#11040)

This commit is contained in:
Andras Bacsai
2026-08-03 23:08:56 +02:00
committed by GitHub
parent 7b18777f06
commit 0b843bb07c
18 changed files with 1443 additions and 220 deletions
+10 -19
View File
@@ -139,7 +139,7 @@ function replaceVariables(string $variable): Stringable
function getFilesystemVolumesFromServer(ServiceApplication|ServiceDatabase|Application $oneService, bool $isInit = false)
{
try {
if ($oneService->getMorphClass() === \App\Models\Application::class) {
if ($oneService->getMorphClass() === Application::class) {
$workdir = $oneService->workdir();
$server = $oneService->destination->server;
} else {
@@ -204,7 +204,7 @@ function getFilesystemVolumesFromServer(ServiceApplication|ServiceDatabase|Appli
instant_remote_process(["mkdir -p $fileLocation"], $server);
}
}
} catch (\Throwable $e) {
} catch (Throwable $e) {
return handleError($e);
}
}
@@ -214,7 +214,7 @@ function updateCompose(ServiceApplication|ServiceDatabase $resource)
$name = data_get($resource, 'name');
$dockerComposeRaw = data_get($resource, 'service.docker_compose_raw');
if (! $dockerComposeRaw) {
throw new \Exception('No compose file found or not a valid YAML file.');
throw new Exception('No compose file found or not a valid YAML file.');
}
$dockerCompose = Yaml::parse($dockerComposeRaw);
@@ -325,22 +325,13 @@ function updateCompose(ServiceApplication|ServiceDatabase $resource)
}
if ($resource->fqdn) {
$resourceFqdns = str($resource->fqdn)->explode(',');
$resourceFqdns = $resourceFqdns->first();
$url = Url::fromString($resourceFqdns);
$firstFqdn = firstDomainFromList($resource->fqdn);
$url = Url::fromString($firstFqdn);
$port = $url->getPort();
$path = $url->getPath();
// Prepare URL value (with scheme and host)
$urlValue = $url->getScheme().'://'.$url->getHost();
$urlValue = ($path === '/') ? $urlValue : $urlValue.$path;
// Prepare FQDN value (host only, no scheme)
$fqdnHost = $url->getHost();
$fqdnValue = str($fqdnHost)->after('://');
if ($path !== '/') {
$fqdnValue = $fqdnValue.$path;
}
// Same helpers as application/service parsers (COOLIFY_URL / COOLIFY_FQDN).
$urlValue = getFqdnWithoutPort($firstFqdn);
$fqdnValue = getHostWithoutPort($firstFqdn);
// For each service name found in template, create BOTH SERVICE_URL and SERVICE_FQDN pairs
foreach ($serviceNamesToProcess as $serviceInfo) {
@@ -396,7 +387,7 @@ function updateCompose(ServiceApplication|ServiceDatabase $resource)
}
}
}
} catch (\Throwable $e) {
} catch (Throwable $e) {
return handleError($e);
}
}
@@ -495,7 +486,7 @@ function applyServiceApplicationPrerequisites(Service $service): void
}
}
}
} catch (\Throwable $e) {
} catch (Throwable $e) {
// Log error but don't throw - prerequisites are nice-to-have, not critical
Log::error('Failed to apply service application prerequisites', [
'service_id' => $service->id,