An open-source, self-hostable PaaS alternative to Vercel, Heroku & Netlify that lets you easily deploy static sites, databases, full-stack applications and 360+ one-click services on your own servers.
PHP coolifydatabasesdeploymentdockerdocker-composeinertiajslaravelmariadbmysqlnextjsnodejsphppostgresredisself-hostedself-hostingserverstatic-sitesveltesvelte5
refactor(deployment): streamline environment variable generation in ApplicationDeploymentJob
Andras Bacsai158747c8b133
diff --git a/app/Jobs/ApplicationDeploymentJob.php b/app/Jobs/ApplicationDeploymentJob.phpindex 91e105f56b..93f730335e 100644--- a/app/Jobs/ApplicationDeploymentJob.php+++ b/app/Jobs/ApplicationDeploymentJob.php@@ -1965,10 +1965,14 @@ class ApplicationDeploymentJob implements ShouldBeEncrypted, ShouldQueue{$this->env_args = collect([]);$this->env_args->put('SOURCE_COMMIT', $this->commit);+$coolify_envs = $this->generate_coolify_env_variables();+ $coolify_envs->each(function ($value, $key) {+ $this->env_args->put($key, $value);+ });+// For build process, include only environment variables where is_buildtime = trueif ($this->pull_request_id === 0) {- // Get environment variables that are marked as available during build$envs = $this->application->environment_variables()->where('key', 'not like', 'NIXPACKS_%')->where('is_buildtime', true)@@ -1977,24 +1981,9 @@ class ApplicationDeploymentJob implements ShouldBeEncrypted, ShouldQueueforeach ($envs as $env) {if (! is_null($env->real_value)) {$this->env_args->put($env->key, $env->real_value);- if (str($env->real_value)->startsWith('$')) {- $variable_key = str($env->real_value)->after('$');- if ($variable_key->startsWith('COOLIFY_')) {- $variable = $coolify_envs->get($variable_key->value());- if (filled($variable)) {- $this->env_args->prepend($variable, $variable_key->value());- }- } else {- $variable = $this->application->environment_variables()->where('key', $variable_key)->first();- if ($variable) {- $this->env_args->prepend($variable->real_value, $env->key);- }- }- }}}} else {- // Get preview environment variables that are marked as available during build$envs = $this->application->environment_variables_preview()->where('key', 'not like', 'NIXPACKS_%')->where('is_buildtime', true)@@ -2003,29 +1992,9 @@ class ApplicationDeploymentJob implements ShouldBeEncrypted, ShouldQueueforeach ($envs as $env) {if (! is_null($env->real_value)) {$this->env_args->put($env->key, $env->real_value);- if (str($env->real_value)->startsWith('$')) {- $variable_key = str($env->real_value)->after('$');- if ($variable_key->startsWith('COOLIFY_')) {- $variable = $coolify_envs->get($variable_key->value());- if (filled($variable)) {- $this->env_args->prepend($variable, $variable_key->value());- }- } else {- $variable = $this->application->environment_variables_preview()->where('key', $variable_key)->first();- if ($variable) {- $this->env_args->prepend($variable->real_value, $env->key);- }- }- }}}}-- // Merge COOLIFY_* variables into env_args for build process- // This ensures they're available for both build args and build secrets- $coolify_envs->each(function ($value, $key) {- $this->env_args->put($key, $value);- });}private function generate_compose_file()