mirror of
https://github.com/coollabsio/coolify.git
synced 2026-03-11 08:55:47 +00:00
Merge e4d0c53d2b into 872e300cf9
This commit is contained in:
commit
a344758e8f
4 changed files with 36 additions and 3 deletions
|
|
@ -2520,7 +2520,7 @@ class ApplicationDeploymentJob implements ShouldBeEncrypted, ShouldQueue
|
|||
return escapeDollarSign($value);
|
||||
});
|
||||
}
|
||||
$labels = $labels->merge(defaultLabels($this->application->id, $this->application->uuid, $this->application->project()->name, $this->application->name, $this->application->environment->name, $this->pull_request_id))->toArray();
|
||||
$labels = $labels->merge(defaultLabels($this->application->id, $this->application->uuid, $this->application->project()->name, $this->application->name, $this->application->environment->name, $this->pull_request_id, tags: $this->application->tags))->toArray();
|
||||
|
||||
// Check for custom HEALTHCHECK
|
||||
if ($this->application->build_pack === 'dockerfile' || $this->application->dockerfile) {
|
||||
|
|
|
|||
|
|
@ -210,6 +210,23 @@ function get_port_from_dockerfile($dockerfile): ?int
|
|||
return null;
|
||||
}
|
||||
|
||||
function formatTagsForDockerLabel($tags, int $limit = 50): string
|
||||
{
|
||||
if (! $tags || $tags->isEmpty()) {
|
||||
return '';
|
||||
}
|
||||
|
||||
return $tags->take($limit)
|
||||
->pluck('name')
|
||||
->map(function ($tag) {
|
||||
// Sanitize to only allow characters safe for Docker labels
|
||||
// Allows: alphanumeric, hyphens, underscores, periods, colons, forward slashes
|
||||
return preg_replace('/[^a-zA-Z0-9\-_.:\/]/', '', $tag);
|
||||
})
|
||||
->filter() // Remove empty strings after sanitization
|
||||
->implode(' ');
|
||||
}
|
||||
|
||||
function defaultDatabaseLabels($database)
|
||||
{
|
||||
$labels = collect([]);
|
||||
|
|
@ -222,10 +239,15 @@ function defaultDatabaseLabels($database)
|
|||
$labels->push('coolify.environmentName='.Str::slug($database->environment->name));
|
||||
$labels->push('coolify.database.subType='.$database->type());
|
||||
|
||||
$tagsLabel = formatTagsForDockerLabel($database->tags ?? collect());
|
||||
if ($tagsLabel) {
|
||||
$labels->push('coolify.tags='.$tagsLabel);
|
||||
}
|
||||
|
||||
return $labels;
|
||||
}
|
||||
|
||||
function defaultLabels($id, $name, string $projectName, string $resourceName, string $environment, $pull_request_id = 0, string $type = 'application', $subType = null, $subId = null, $subName = null)
|
||||
function defaultLabels($id, $name, string $projectName, string $resourceName, string $environment, $pull_request_id = 0, string $type = 'application', $subType = null, $subId = null, $subName = null, $tags = null)
|
||||
{
|
||||
$labels = collect([]);
|
||||
$labels->push('coolify.managed=true');
|
||||
|
|
@ -245,6 +267,13 @@ function defaultLabels($id, $name, string $projectName, string $resourceName, st
|
|||
$subName && $labels->push('coolify.service.subName='.Str::slug($subName));
|
||||
}
|
||||
|
||||
if ($tags) {
|
||||
$tagsLabel = formatTagsForDockerLabel($tags);
|
||||
if ($tagsLabel) {
|
||||
$labels->push('coolify.tags='.$tagsLabel);
|
||||
}
|
||||
}
|
||||
|
||||
return $labels;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1254,6 +1254,7 @@ function applicationParser(Application $resource, int $pull_request_id = 0, ?int
|
|||
pull_request_id: $pullRequestId,
|
||||
type: 'application',
|
||||
environment: $resource->environment->name,
|
||||
tags: $resource->tags,
|
||||
);
|
||||
|
||||
$isDatabase = isDatabaseImage($image, $service);
|
||||
|
|
@ -2499,6 +2500,7 @@ function serviceParser(Service $resource): Collection
|
|||
subId: $savedService->id,
|
||||
subName: $savedService->human_name ?? $savedService->name,
|
||||
environment: $resource->environment->name,
|
||||
tags: $resource->tags,
|
||||
);
|
||||
|
||||
// Add COOLIFY_FQDN & COOLIFY_URL to environment
|
||||
|
|
|
|||
|
|
@ -2283,6 +2283,7 @@ function parseDockerComposeFile(Service|Application $resource, bool $isNew = fal
|
|||
subId: $savedService->id,
|
||||
subName: $savedService->name,
|
||||
environment: $resource->environment->name,
|
||||
tags: $resource->tags,
|
||||
);
|
||||
$serviceLabels = $serviceLabels->merge($defaultLabels);
|
||||
if (! $isDatabase && $fqdns->count() > 0) {
|
||||
|
|
@ -3130,7 +3131,8 @@ function parseDockerComposeFile(Service|Application $resource, bool $isNew = fal
|
|||
resourceName: $resource->name,
|
||||
environment: $resource->environment->name,
|
||||
pull_request_id: $pull_request_id,
|
||||
type: 'application'
|
||||
type: 'application',
|
||||
tags: $resource->tags,
|
||||
);
|
||||
$serviceLabels = $serviceLabels->merge($defaultLabels);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue