mirror of
https://github.com/tiennm99/coolify.git
synced 2026-10-13 18:15:24 +00:00
fix(proxy): set Traefik network labels for compose services
Add the Coolify network label when no user-selected Traefik network exists, while preserving custom labels for applications and services.
This commit is contained in:
1 parent
006b1b2b74
commit
1c25b58dc8
4 files changed
+154
No files matched your search
@@ -358,6 +358,19 @@ function parseDockerVolumeString(string $volumeString): array
|
||||
];
|
||||
}
|
||||
|
||||
function addTraefikDockerNetworkLabel(Collection $labels, string $network): Collection
|
||||
{
|
||||
$hasUserDefinedNetwork = $labels->contains(
|
||||
fn ($label): bool => is_string($label) && str($label)->before('=')->is('traefik.docker.network')
|
||||
);
|
||||
|
||||
if (! $hasUserDefinedNetwork) {
|
||||
$labels->push("traefik.docker.network={$network}");
|
||||
}
|
||||
|
||||
return $labels;
|
||||
}
|
||||
|
||||
function applicationParser(Application $resource, int $pull_request_id = 0, ?int $preview_id = null, ?string $commit = null): Collection
|
||||
{
|
||||
$uuid = data_get($resource, 'uuid');
|
||||
@@ -1346,6 +1359,9 @@ function applicationParser(Application $resource, int $pull_request_id = 0, ?int
|
||||
$redirectDirection = in_array($composeRedirect, ['www', 'non-www', 'both'], true)
|
||||
? $composeRedirect
|
||||
: 'both';
|
||||
if (! $use_network_mode && (! $shouldGenerateLabelsExactly || $server->proxyType() === ProxyTypes::TRAEFIK->value)) {
|
||||
$serviceLabels = addTraefikDockerNetworkLabel($serviceLabels, $baseNetwork->first());
|
||||
}
|
||||
if ($shouldGenerateLabelsExactly) {
|
||||
switch ($server->proxyType()) {
|
||||
case ProxyTypes::TRAEFIK->value:
|
||||
@@ -2620,6 +2636,9 @@ function serviceParser(Service $resource): Collection
|
||||
$redirectDirection = in_array(data_get($originalResource, 'redirect'), ['www', 'non-www', 'both'], true)
|
||||
? data_get($originalResource, 'redirect')
|
||||
: 'both';
|
||||
if (! $use_network_mode && (! $shouldGenerateLabelsExactly || $server->proxyType() === ProxyTypes::TRAEFIK->value)) {
|
||||
$serviceLabels = addTraefikDockerNetworkLabel($serviceLabels, $baseNetwork->first());
|
||||
}
|
||||
if ($shouldGenerateLabelsExactly) {
|
||||
switch ($server->proxyType()) {
|
||||
case ProxyTypes::TRAEFIK->value:
|
||||
|
||||
Reference in new issue
Block a user