diff --git a/app/Models/Service.php b/app/Models/Service.php index 8adca3424..795b9a421 100644 --- a/app/Models/Service.php +++ b/app/Models/Service.php @@ -839,20 +839,33 @@ public function saveComposeConfigs() $commands[] = "cd $workdir"; $json = Yaml::parse($this->docker_compose); + $envs_from_coolify = $this->environment_variables()->get(); foreach ($json['services'] as $service => $config) { $envs = collect($config['environment']); $envs->push("COOLIFY_CONTAINER_NAME=$service-{$this->uuid}"); + foreach ($envs_from_coolify as $env) { + $envs = $envs->map(function ($value) use ($env) { + if (str($value)->startsWith($env->key)) { + return "{$env->key}={$env->real_value}"; + } + + return $value; + }); + } + $envs = $envs->unique(); data_set($json, "services.$service.environment", $envs->toArray()); } + $this->docker_compose = Yaml::dump($json); $docker_compose_base64 = base64_encode($this->docker_compose); + $commands[] = "echo $docker_compose_base64 | base64 -d | tee docker-compose.yml > /dev/null"; - $envs = $this->environment_variables()->get(); $commands[] = 'rm -f .env || true'; - foreach ($envs as $env) { + + foreach ($envs_from_coolify as $env) { $commands[] = "echo '{$env->key}={$env->real_value}' >> .env"; } - if ($envs->count() === 0) { + if ($envs_from_coolify->count() === 0) { $commands[] = 'touch .env'; } instant_remote_process($commands, $this->server); diff --git a/resources/views/livewire/project/shared/environment-variable/all.blade.php b/resources/views/livewire/project/shared/environment-variable/all.blade.php index 42a2b48a7..649d59a20 100644 --- a/resources/views/livewire/project/shared/environment-variable/all.blade.php +++ b/resources/views/livewire/project/shared/environment-variable/all.blade.php @@ -2,13 +2,11 @@