add env vars on old compose parser

This commit is contained in:
Vahor 2024-08-27 19:36:22 +02:00
parent 7103dccc72
commit 2d9c583af3
No known key found for this signature in database
2 changed files with 17 additions and 2 deletions

View File

@ -48,7 +48,7 @@ public function handle(Server $server)
[FILTER]
Name modify
Match *
Set server_name {$server->name}
Set coolify.server_name {$server->name}
Rename COOLIFY_APP_NAME coolify.app_name
Rename COOLIFY_PROJECT_NAME coolify.project_name
Rename COOLIFY_SERVER_IP coolify.server_ip
@ -105,7 +105,7 @@ public function handle(Server $server)
[FILTER]
Name modify
Match *
Set server_name {$server->name}
Set coolify.server_name {$server->name}
Rename COOLIFY_APP_NAME coolify.app_name
Rename COOLIFY_PROJECT_NAME coolify.project_name
Rename COOLIFY_SERVER_IP coolify.server_ip

View File

@ -2106,6 +2106,21 @@ function parseDockerComposeFile(Service|Application $resource, bool $isNew = fal
}
}
$parsedServiceVariables->put('COOLIFY_CONTAINER_NAME', "$serviceName-{$resource->uuid}");
// TODO: move this in a shared function
if (! $parsedServiceVariables->has('COOLIFY_APP_NAME')) {
$parsedServiceVariables->put('COOLIFY_APP_NAME', $resource->name);
}
if (! $parsedServiceVariables->has('COOLIFY_SERVER_IP')) {
$parsedServiceVariables->put("COOLIFY_SERVER_IP", $resource->destination->server->ip);
}
if (! $parsedServiceVariables->has('COOLIFY_ENVIRONMENT_NAME')) {
$parsedServiceVariables->put("COOLIFY_ENVIRONMENT_NAME", $resource->environment->name);
}
if (! $parsedServiceVariables->has('COOLIFY_PROJECT_NAME')) {
$parsedServiceVariables->put('COOLIFY_PROJECT_NAME', $resource->project()->name);
}
$parsedServiceVariables = $parsedServiceVariables->map(function ($value, $key) use ($envs_from_coolify) {
if (! str($value)->startsWith('$')) {
$found_env = $envs_from_coolify->where('key', $key)->first();