mirror of
https://github.com/tiennm99/coolify.git
synced 2026-10-13 14:15:58 +00:00
fix(parsers): populate docker_compose_domains for API-created Docker Compose apps (#9300)
This commit is contained in:
3 files changed
+327
-4
No files matched your search
@@ -501,6 +501,40 @@ function applicationParser(Application $resource, int $pull_request_id = 0, ?int
|
||||
'is_preview' => false,
|
||||
]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Also populate docker_compose_domains for dockercompose apps from direct SERVICE_* declarations.
|
||||
if ($resource->build_pack === 'dockercompose' && ($key->startsWith('SERVICE_FQDN_') || $key->startsWith('SERVICE_URL_'))) {
|
||||
$parsed = parseServiceEnvironmentVariable($key->value());
|
||||
$normalizedServiceName = str($parsed['service_name'])->replace('-', '_')->replace('.', '_')->value();
|
||||
$serviceExists = false;
|
||||
foreach (array_keys($services) as $serviceNameKey) {
|
||||
if (str($serviceNameKey)->replace('-', '_')->replace('.', '_')->value() === $normalizedServiceName) {
|
||||
$serviceExists = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ($serviceExists) {
|
||||
$domains = collect(json_decode(data_get($resource, 'docker_compose_domains') ?: '[]'));
|
||||
$domainExists = data_get($domains->get($normalizedServiceName), 'domain');
|
||||
if (is_null($domainExists)) {
|
||||
$serviceNameForDomain = str($parsed['service_name'])->replace('_', '-')->value();
|
||||
$domainValue = generateUrl(server: $server, random: "$serviceNameForDomain-$uuid");
|
||||
if ($value && get_class($value) === Illuminate\Support\Stringable::class && $value->startsWith('/')) {
|
||||
$path = $value->value();
|
||||
if ($path !== '/') {
|
||||
$domainValue = "$domainValue$path";
|
||||
}
|
||||
}
|
||||
if ($parsed['port'] && is_numeric($parsed['port'])) {
|
||||
$domainValue = "$domainValue:{$parsed['port']}";
|
||||
}
|
||||
$domains->put($normalizedServiceName, ['domain' => $domainValue]);
|
||||
$resource->docker_compose_domains = $domains->toJson();
|
||||
$resource->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -608,7 +642,7 @@ function applicationParser(Application $resource, int $pull_request_id = 0, ?int
|
||||
|
||||
// Only add domain if the service exists
|
||||
if ($serviceExists) {
|
||||
$domains = collect(json_decode(data_get($resource, 'docker_compose_domains'))) ?? collect([]);
|
||||
$domains = collect(json_decode(data_get($resource, 'docker_compose_domains') ?: '[]'));
|
||||
$domainExists = data_get($domains->get($serviceName), 'domain');
|
||||
|
||||
// Update domain using URL with port if applicable
|
||||
|
||||
Reference in new issue
Block a user