refactor: Update environment variable handling in StartClickhouse.php and ApplicationDeploymentJob.php
This commit is contained in:
@@ -922,7 +922,7 @@ class ApplicationDeploymentJob implements ShouldBeEncrypted, ShouldQueue
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
add_coolify_default_environment_variables($this->application, $environment, $this->application->environment_variables_preview);
|
add_coolify_default_environment_variables($this->application, $envs, $this->application->environment_variables_preview);
|
||||||
|
|
||||||
foreach ($sorted_environment_variables_preview as $env) {
|
foreach ($sorted_environment_variables_preview as $env) {
|
||||||
$real_value = $env->real_value;
|
$real_value = $env->real_value;
|
||||||
|
@@ -2103,10 +2103,10 @@ function parseDockerComposeFile(Service|Application $resource, bool $isNew = fal
|
|||||||
$parsedServiceVariables->put('COOLIFY_APP_NAME', $resource->name);
|
$parsedServiceVariables->put('COOLIFY_APP_NAME', $resource->name);
|
||||||
}
|
}
|
||||||
if (! $parsedServiceVariables->has('COOLIFY_SERVER_IP')) {
|
if (! $parsedServiceVariables->has('COOLIFY_SERVER_IP')) {
|
||||||
$parsedServiceVariables->put("COOLIFY_SERVER_IP", $resource->destination->server->ip);
|
$parsedServiceVariables->put('COOLIFY_SERVER_IP', $resource->destination->server->ip);
|
||||||
}
|
}
|
||||||
if (! $parsedServiceVariables->has('COOLIFY_ENVIRONMENT_NAME')) {
|
if (! $parsedServiceVariables->has('COOLIFY_ENVIRONMENT_NAME')) {
|
||||||
$parsedServiceVariables->put("COOLIFY_ENVIRONMENT_NAME", $resource->environment->name);
|
$parsedServiceVariables->put('COOLIFY_ENVIRONMENT_NAME', $resource->environment->name);
|
||||||
}
|
}
|
||||||
if (! $parsedServiceVariables->has('COOLIFY_PROJECT_NAME')) {
|
if (! $parsedServiceVariables->has('COOLIFY_PROJECT_NAME')) {
|
||||||
$parsedServiceVariables->put('COOLIFY_PROJECT_NAME', $resource->project()->name);
|
$parsedServiceVariables->put('COOLIFY_PROJECT_NAME', $resource->project()->name);
|
||||||
@@ -3429,6 +3429,7 @@ function newParser(Application|Service $resource, int $pull_request_id = 0, ?int
|
|||||||
});
|
});
|
||||||
$environment->put('COOLIFY_FQDN', $urls->implode(','));
|
$environment->put('COOLIFY_FQDN', $urls->implode(','));
|
||||||
}
|
}
|
||||||
|
add_coolify_default_environment_variables($resource, $environment, $resource->environment_variables);
|
||||||
|
|
||||||
$serviceLabels = $labels->merge($defaultLabels);
|
$serviceLabels = $labels->merge($defaultLabels);
|
||||||
if (! $isDatabase && $fqdns?->count() > 0) {
|
if (! $isDatabase && $fqdns?->count() > 0) {
|
||||||
@@ -3555,7 +3556,8 @@ function newParser(Application|Service $resource, int $pull_request_id = 0, ?int
|
|||||||
return $topLevel;
|
return $topLevel;
|
||||||
}
|
}
|
||||||
|
|
||||||
function generate_fluentd_configuration() : array {
|
function generate_fluentd_configuration(): array
|
||||||
|
{
|
||||||
return [
|
return [
|
||||||
'driver' => 'fluentd',
|
'driver' => 'fluentd',
|
||||||
'options' => [
|
'options' => [
|
||||||
@@ -3564,7 +3566,7 @@ function generate_fluentd_configuration() : array {
|
|||||||
'fluentd-sub-second-precision' => 'true',
|
'fluentd-sub-second-precision' => 'true',
|
||||||
// env vars are used in the LogDrain configurations
|
// env vars are used in the LogDrain configurations
|
||||||
'env' => 'COOLIFY_APP_NAME,COOLIFY_PROJECT_NAME,COOLIFY_SERVER_IP,COOLIFY_ENVIRONMENT_NAME',
|
'env' => 'COOLIFY_APP_NAME,COOLIFY_PROJECT_NAME,COOLIFY_SERVER_IP,COOLIFY_ENVIRONMENT_NAME',
|
||||||
]
|
],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3576,25 +3578,46 @@ function generate_fluentd_configuration() : array {
|
|||||||
* - COOLIFY_ENVIRONMENT_NAME
|
* - COOLIFY_ENVIRONMENT_NAME
|
||||||
*
|
*
|
||||||
* Theses variables are added in place to the $where_to_add array.
|
* Theses variables are added in place to the $where_to_add array.
|
||||||
*
|
|
||||||
* @param StandaloneRedis|StandalonePostgresql|StandaloneMongodb|StandaloneMysql|StandaloneMariadb|StandaloneKeydb|StandaloneDragonfly|StandaloneClickhouse|Application $resource
|
|
||||||
* @param Collection $where_to_add
|
|
||||||
* @param Collection|null $where_to_check
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
function add_coolify_default_environment_variables(StandaloneRedis|StandalonePostgresql|StandaloneMongodb|StandaloneMysql|StandaloneMariadb|StandaloneKeydb|StandaloneDragonfly|StandaloneClickhouse|Application $resource, Collection &$where_to_add, ?Collection $where_to_check = null) {
|
function add_coolify_default_environment_variables(StandaloneRedis|StandalonePostgresql|StandaloneMongodb|StandaloneMysql|StandaloneMariadb|StandaloneKeydb|StandaloneDragonfly|StandaloneClickhouse|Application|Service $resource, Collection &$where_to_add, ?Collection $where_to_check = null)
|
||||||
|
{
|
||||||
if ($where_to_check != null && $where_to_check->where('key', 'COOLIFY_APP_NAME')->isEmpty()) {
|
if ($where_to_check != null && $where_to_check->where('key', 'COOLIFY_APP_NAME')->isEmpty()) {
|
||||||
|
if ($resource instanceof Application && $resource->build_pack === 'dockercompose') {
|
||||||
|
$where_to_add->put('COOLIFY_APP_NAME', $resource->name);
|
||||||
|
} elseif ($resource instanceof Service) {
|
||||||
|
$where_to_add->put('COOLIFY_APP_NAME', $resource->name);
|
||||||
|
} else {
|
||||||
$where_to_add->push("COOLIFY_APP_NAME={$resource->name}");
|
$where_to_add->push("COOLIFY_APP_NAME={$resource->name}");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if ($where_to_check != null && $where_to_check->where('key', 'COOLIFY_SERVER_IP')->isEmpty()) {
|
if ($where_to_check != null && $where_to_check->where('key', 'COOLIFY_SERVER_IP')->isEmpty()) {
|
||||||
|
if ($resource instanceof Application && $resource->build_pack === 'dockercompose') {
|
||||||
|
$where_to_add->put('COOLIFY_SERVER_IP', $resource->destination->server->ip);
|
||||||
|
} elseif ($resource instanceof Service) {
|
||||||
|
$where_to_add->put('COOLIFY_SERVER_IP', $resource->server->ip);
|
||||||
|
} else {
|
||||||
$where_to_add->push("COOLIFY_SERVER_IP={$resource->destination->server->ip}");
|
$where_to_add->push("COOLIFY_SERVER_IP={$resource->destination->server->ip}");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if ($where_to_check != null && $where_to_check->where('key', 'COOLIFY_ENVIRONMENT_NAME')->isEmpty()) {
|
if ($where_to_check != null && $where_to_check->where('key', 'COOLIFY_ENVIRONMENT_NAME')->isEmpty()) {
|
||||||
|
if ($resource instanceof Application && $resource->build_pack === 'dockercompose') {
|
||||||
|
$where_to_add->put('COOLIFY_ENVIRONMENT_NAME', $resource->environment->name);
|
||||||
|
} elseif ($resource instanceof Service) {
|
||||||
|
$where_to_add->put('COOLIFY_ENVIRONMENT_NAME', $resource->environment->name);
|
||||||
|
} else {
|
||||||
$where_to_add->push("COOLIFY_ENVIRONMENT_NAME={$resource->environment->name}");
|
$where_to_add->push("COOLIFY_ENVIRONMENT_NAME={$resource->environment->name}");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if ($where_to_check != null && $where_to_check->where('key', 'COOLIFY_PROJECT_NAME')->isEmpty()) {
|
if ($where_to_check != null && $where_to_check->where('key', 'COOLIFY_PROJECT_NAME')->isEmpty()) {
|
||||||
|
if ($resource instanceof Application && $resource->build_pack === 'dockercompose') {
|
||||||
|
$where_to_add->put('COOLIFY_PROJECT_NAME', $resource->project()->name);
|
||||||
|
} elseif ($resource instanceof Service) {
|
||||||
|
$where_to_add->put('COOLIFY_PROJECT_NAME', $resource->project()->name);
|
||||||
|
} else {
|
||||||
$where_to_add->push("COOLIFY_PROJECT_NAME={$resource->project()->name}");
|
$where_to_add->push("COOLIFY_PROJECT_NAME={$resource->project()->name}");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function convertComposeEnvironmentToArray($environment)
|
function convertComposeEnvironmentToArray($environment)
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user