From 7980f21b1b51b65ebeec6c70633dbe4da2e2dcdb Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Thu, 18 Apr 2024 11:14:23 +0200 Subject: [PATCH 1/6] Update version numbers to 4.0.0-beta.265 --- config/sentry.php | 2 +- config/version.php | 2 +- versions.json | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/config/sentry.php b/config/sentry.php index f3296a6fc..02a4ff296 100644 --- a/config/sentry.php +++ b/config/sentry.php @@ -7,7 +7,7 @@ // The release version of your application // Example with dynamic git hash: trim(exec('git --git-dir ' . base_path('.git') . ' log --pretty="%h" -n1 HEAD')) - 'release' => '4.0.0-beta.264', + 'release' => '4.0.0-beta.265', // When left empty or `null` the Laravel environment will be used 'environment' => config('app.env'), diff --git a/config/version.php b/config/version.php index e3c856795..7ac4ffcba 100644 --- a/config/version.php +++ b/config/version.php @@ -1,3 +1,3 @@ Date: Thu, 18 Apr 2024 11:14:26 +0200 Subject: [PATCH 2/6] Fix formatting issue in deployment show.blade.php --- .../livewire/project/application/deployment/show.blade.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/resources/views/livewire/project/application/deployment/show.blade.php b/resources/views/livewire/project/application/deployment/show.blade.php index edb2a0f72..a8d4f3847 100644 --- a/resources/views/livewire/project/application/deployment/show.blade.php +++ b/resources/views/livewire/project/application/deployment/show.blade.php @@ -87,7 +87,7 @@ class="fixed top-4 right-16" x-on:click="toggleScroll"> $line['hidden'], - 'text-red-500 font-bold' => $line['type'] == 'stderr', + 'text-red-500 font-bold whitespace-pre-line' => $line['type'] == 'stderr', ])>[{{ $line['timestamp'] }}] @if ($line['hidden'])

[COMMAND] {{ $line['command'] }}
[OUTPUT] @endif @if (str($line['output'])->contains('http://') || str($line['output'])->contains('https://')) @@ -100,7 +100,7 @@ class="fixed top-4 right-16" x-on:click="toggleScroll"> @endforeach From 5e1396025cdc63c5bc2e9a548c4d19541e7dbf79 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Thu, 18 Apr 2024 11:41:58 +0200 Subject: [PATCH 3/6] Fix issue with saving environment variables in ApplicationDeploymentJob.php --- app/Jobs/ApplicationDeploymentJob.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/Jobs/ApplicationDeploymentJob.php b/app/Jobs/ApplicationDeploymentJob.php index fa5fb7d93..594b1e412 100644 --- a/app/Jobs/ApplicationDeploymentJob.php +++ b/app/Jobs/ApplicationDeploymentJob.php @@ -775,6 +775,7 @@ private function save_environment_variables() } if ($envs->isEmpty()) { + $this->env_filename = null; $this->execute_remote_command( [ "command" => "rm -f $this->configuration_dir/{$this->env_filename}", @@ -782,7 +783,6 @@ private function save_environment_variables() "ignore_errors" => true ] ); - $this->env_filename = null; return; } // $this->execute_remote_command([ @@ -1295,7 +1295,7 @@ private function generate_compose_file() // $docker_compose['services'][$this->container_name]['env_file'] = [$this->env_filename]; // } // } - if ($this->env_filename) { + if (!is_null($this->env_filename)) { $docker_compose['services'][$this->container_name]['env_file'] = [$this->env_filename]; } if (!$this->custom_healthcheck_found) { From 77797133924849e1ed0ad41205839eefbe5e2d15 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Thu, 18 Apr 2024 11:48:10 +0200 Subject: [PATCH 4/6] Fix issue with user validation in Server.php --- app/Models/Server.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/Models/Server.php b/app/Models/Server.php index fb3443d94..bda044320 100644 --- a/app/Models/Server.php +++ b/app/Models/Server.php @@ -860,6 +860,9 @@ public function validateCoolifyNetwork($isSwarm = false, $isBuildServer = false) } public function isNonRoot() { + if ($this->user instanceof Stringable) { + return $this->user->value() !== 'root'; + } return $this->user !== 'root'; } } From 7c0b98bb70eddc3739d114a37f74c20d38506b8f Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Thu, 18 Apr 2024 12:37:06 +0200 Subject: [PATCH 5/6] Fix sorting issue in save_environment_variables() function --- app/Jobs/ApplicationDeploymentJob.php | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/app/Jobs/ApplicationDeploymentJob.php b/app/Jobs/ApplicationDeploymentJob.php index 594b1e412..4b4631de9 100644 --- a/app/Jobs/ApplicationDeploymentJob.php +++ b/app/Jobs/ApplicationDeploymentJob.php @@ -740,6 +740,9 @@ private function save_environment_variables() $envs->push("SOURCE_COMMIT=unknown"); } } + $envs = $envs->sort(function ($a, $b) { + return strpos($a, '$') === false ? -1 : 1; + }); } else { $this->env_filename = ".env"; foreach ($this->application->environment_variables as $env) { @@ -783,7 +786,16 @@ private function save_environment_variables() "ignore_errors" => true ] ); - return; + } else { + $envs_base64 = base64_encode($envs->implode("\n")); + $this->execute_remote_command( + [ + executeInDocker($this->deployment_uuid, "echo '$envs_base64' | base64 -d | tee $this->workdir/{$this->env_filename} > /dev/null") + ], + [ + "echo '$envs_base64' | base64 -d | tee $this->configuration_dir/{$this->env_filename} > /dev/null" + ] + ); } // $this->execute_remote_command([ // executeInDocker($this->deployment_uuid, "cat $this->workdir/.env 2>/dev/null || true"), @@ -806,15 +818,7 @@ private function save_environment_variables() // ] // ); // } - $envs_base64 = base64_encode($envs->implode("\n")); - $this->execute_remote_command( - [ - executeInDocker($this->deployment_uuid, "echo '$envs_base64' | base64 -d | tee $this->workdir/{$this->env_filename} > /dev/null") - ], - [ - "echo '$envs_base64' | base64 -d | tee $this->configuration_dir/{$this->env_filename} > /dev/null" - ] - ); + } From 676c022e41834313cddba03a527fb1c9b900da47 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Thu, 18 Apr 2024 13:53:10 +0200 Subject: [PATCH 6/6] fix: .env saved to deployment server, not to build server --- app/Jobs/ApplicationDeploymentJob.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/app/Jobs/ApplicationDeploymentJob.php b/app/Jobs/ApplicationDeploymentJob.php index 4b4631de9..0207e4a80 100644 --- a/app/Jobs/ApplicationDeploymentJob.php +++ b/app/Jobs/ApplicationDeploymentJob.php @@ -24,6 +24,7 @@ use Illuminate\Queue\InteractsWithQueue; use Illuminate\Queue\SerializesModels; use Illuminate\Support\Collection; +use Illuminate\Support\Facades\Log; use Illuminate\Support\Sleep; use Illuminate\Support\Str; use RuntimeException; @@ -743,6 +744,7 @@ private function save_environment_variables() $envs = $envs->sort(function ($a, $b) { return strpos($a, '$') === false ? -1 : 1; }); + Log::info("message", $envs->implode("\n")); } else { $this->env_filename = ".env"; foreach ($this->application->environment_variables as $env) { @@ -779,6 +781,9 @@ private function save_environment_variables() if ($envs->isEmpty()) { $this->env_filename = null; + if ($this->use_build_server) { + $this->server = $this->original_server; + } $this->execute_remote_command( [ "command" => "rm -f $this->configuration_dir/{$this->env_filename}", @@ -786,16 +791,28 @@ private function save_environment_variables() "ignore_errors" => true ] ); + if ($this->use_build_server) { + $this->server = $this->build_server; + } } else { $envs_base64 = base64_encode($envs->implode("\n")); $this->execute_remote_command( [ executeInDocker($this->deployment_uuid, "echo '$envs_base64' | base64 -d | tee $this->workdir/{$this->env_filename} > /dev/null") ], + + ); + if ($this->use_build_server) { + $this->server = $this->original_server; + } + $this->execute_remote_command( [ "echo '$envs_base64' | base64 -d | tee $this->configuration_dir/{$this->env_filename} > /dev/null" ] ); + if ($this->use_build_server) { + $this->server = $this->build_server; + } } // $this->execute_remote_command([ // executeInDocker($this->deployment_uuid, "cat $this->workdir/.env 2>/dev/null || true"),