diff --git a/app/Jobs/ApplicationDeploymentJob.php b/app/Jobs/ApplicationDeploymentJob.php index 7177b27f3..ef7163fcc 100644 --- a/app/Jobs/ApplicationDeploymentJob.php +++ b/app/Jobs/ApplicationDeploymentJob.php @@ -1683,7 +1683,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->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))->toArray(); // Check for custom HEALTHCHECK if ($this->application->build_pack === 'dockerfile' || $this->application->dockerfile) { diff --git a/bootstrap/helpers/docker.php b/bootstrap/helpers/docker.php index f80f7a69c..ed2e34559 100644 --- a/bootstrap/helpers/docker.php +++ b/bootstrap/helpers/docker.php @@ -196,11 +196,12 @@ function defaultDatabaseLabels($database) { $labels->push('coolify.resourceName='.Str::slug($database->name)); $labels->push('coolify.serviceName='.Str::slug($database->name)); $labels->push('coolify.projectName='.Str::slug($database->project()->name)); + $labels->push('coolify.environment='.Str::slug($database->environment->name)); return $labels; } -function defaultLabels($id, $name, string $projectName, string $resourceName, $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) { $labels = collect([]); $labels->push('coolify.managed=true'); @@ -211,6 +212,8 @@ function defaultLabels($id, $name, string $projectName, string $resourceName, $p $labels->push('coolify.resourceName='.Str::slug($resourceName)); $labels->push('coolify.projectName='.Str::slug($projectName)); $labels->push('coolify.serviceName='.Str::slug($subName ?? $resourceName)); + $labels->push('coolify.environment='.Str::slug($environment)); + $labels->push('coolify.pullRequestId='.$pull_request_id); if ($type === 'service') { $subId && $labels->push('coolify.service.subId='.$subId); diff --git a/bootstrap/helpers/shared.php b/bootstrap/helpers/shared.php index fe01e046e..a00607357 100644 --- a/bootstrap/helpers/shared.php +++ b/bootstrap/helpers/shared.php @@ -2068,6 +2068,7 @@ function parseDockerComposeFile(Service|Application $resource, bool $isNew = fal subType: $isDatabase ? 'database' : 'application', subId: $savedService->id, subName: $savedService->name, + environment: $resource->environment->name, ); $serviceLabels = $serviceLabels->merge($defaultLabels); if (! $isDatabase && $fqdns->count() > 0) { @@ -2902,6 +2903,7 @@ function parseDockerComposeFile(Service|Application $resource, bool $isNew = fal name: $containerName, projectName: $resource->project()->name, resourceName: $resource->name, + environment: $resource->environment->name, pull_request_id: $pull_request_id, type: 'application' ); @@ -3687,13 +3689,15 @@ function newParser(Application|Service $resource, int $pull_request_id = 0, ?int } } } + $defaultLabels = defaultLabels( id: $resource->id, name: $containerName, projectName: $resource->project()->name, resourceName: $resource->name, pull_request_id: $pullRequestId, - type: 'application' + type: 'application', + environment: $resource->environment->name, ); } elseif ($isService) { if ($savedService->serviceType()) { @@ -3711,6 +3715,7 @@ function newParser(Application|Service $resource, int $pull_request_id = 0, ?int subType: $isDatabase ? 'database' : 'application', subId: $savedService->id, subName: $savedService->human_name ?? $savedService->name, + environment: $resource->environment->name, ); } // Add COOLIFY_FQDN & COOLIFY_URL to environment