add env vars for compose base apps

This commit is contained in:
Vahor 2024-08-27 19:09:04 +02:00
parent a245d16e05
commit 7103dccc72
No known key found for this signature in database
2 changed files with 18 additions and 0 deletions

View File

@ -905,6 +905,8 @@ private function save_environment_variables()
$envs->push("COOLIFY_CONTAINER_NAME={$this->container_name}");
}
}
// TODO: move this in a shared function
if ($this->application->environment_variables_preview->where('key', 'COOLIFY_APP_NAME')->isEmpty()) {
$envs->push("COOLIFY_APP_NAME={$this->application->name}");
}
@ -966,6 +968,8 @@ private function save_environment_variables()
$envs->push("COOLIFY_CONTAINER_NAME={$this->container_name}");
}
}
// TODO: move this in a shared function
if ($this->application->environment_variables->where('key', 'COOLIFY_APP_NAME')->isEmpty()) {
$envs->push("COOLIFY_APP_NAME={$this->application->name}");
}

View File

@ -1471,6 +1471,20 @@ public function newParser(int $pull_request_id = 0, ?int $preview_id = null)
if ($this->environment_variables->where('key', 'COOLIFY_CONTAINER_NAME')->isEmpty()) {
$environment->put('COOLIFY_CONTAINER_NAME', $containerName);
}
// TODO: move this in a shared function
if ($this->environment_variables->where('key', 'COOLIFY_APP_NAME')->isEmpty()) {
$environment->push("COOLIFY_APP_NAME={$this->database->name}");
}
if ($this->environment->where('key', 'COOLIFY_SERVER_IP')->isEmpty()) {
$environment->push("COOLIFY_SERVER_IP={$this->database->destination->server->ip}");
}
if ($this->environment->where('key', 'COOLIFY_ENVIRONMENT_NAME')->isEmpty()) {
$environment->push("COOLIFY_ENVIRONMENT_NAME={$this->database->environment->name}");
}
if ($this->environment->where('key', 'COOLIFY_PROJECT_NAME')->isEmpty()) {
$environment->push("COOLIFY_PROJECT_NAME={$this->database->project()->name}");
}
// Remove SERVICE_FQDN and SERVICE_URL from environment
$environment = $environment->filter(function ($value, $key) {
return ! str($key)->startsWith('SERVICE_FQDN') && ! str($key)->startsWith('SERVICE_URL');