From 05b5a6fddf5d5544d064f0a85bc9f3adb8e3a51b Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Wed, 17 Apr 2024 14:27:51 +0200 Subject: [PATCH 1/5] Update healthcheck URLs to use 127.0.0.1 instead of localhost --- docker-compose.prod.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docker-compose.prod.yml b/docker-compose.prod.yml index 37c8cc871..f68b2c41c 100644 --- a/docker-compose.prod.yml +++ b/docker-compose.prod.yml @@ -95,7 +95,7 @@ services: expose: - "${APP_PORT:-8000}" healthcheck: - test: curl --fail http://localhost:80/api/health || exit 1 + test: curl --fail http://127.0.0.1:80/api/health || exit 1 interval: 5s retries: 10 timeout: 2s @@ -142,7 +142,7 @@ services: SOKETI_DEFAULT_APP_KEY: "${PUSHER_APP_KEY}" SOKETI_DEFAULT_APP_SECRET: "${PUSHER_APP_SECRET}" healthcheck: - test: wget -qO- http://localhost:6001/ready || exit 1 + test: wget -qO- http://127.0.0.1:6001/ready || exit 1 interval: 5s retries: 10 timeout: 2s From 8c033250b1ea4dc3aa71552bf980e238e95cc80e Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Wed, 17 Apr 2024 14:27:53 +0200 Subject: [PATCH 2/5] Update version numbers to 4.0.0-beta.261 --- 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 a1d034f96..39eb0d3c4 100644 --- a/config/sentry.php +++ b/config/sentry.php @@ -7,7 +7,7 @@ return [ // 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.260', + 'release' => '4.0.0-beta.261', // 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 ebefe1d03..52842cffb 100644 --- a/config/version.php +++ b/config/version.php @@ -1,3 +1,3 @@ Date: Wed, 17 Apr 2024 15:16:08 +0200 Subject: [PATCH 3/5] fix: remove lazy loading until bug figured out --- app/Livewire/Project/Application/Rollback.php | 1 - .../application/configuration.blade.php | 28 +++++++++---------- .../project/application/previews.blade.php | 28 ++++++++++--------- .../project/application/rollback.blade.php | 2 +- .../project/service/configuration.blade.php | 22 ++++++++------- 5 files changed, 42 insertions(+), 39 deletions(-) diff --git a/app/Livewire/Project/Application/Rollback.php b/app/Livewire/Project/Application/Rollback.php index 7bd2d069b..cd778f979 100644 --- a/app/Livewire/Project/Application/Rollback.php +++ b/app/Livewire/Project/Application/Rollback.php @@ -18,7 +18,6 @@ class Rollback extends Component { $this->parameters = get_route_parameters(); } - public function rollbackImage($commit) { $deployment_uuid = new Cuid2(7); diff --git a/resources/views/livewire/project/application/configuration.blade.php b/resources/views/livewire/project/application/configuration.blade.php index 8767b101c..4aaf96569 100644 --- a/resources/views/livewire/project/application/configuration.blade.php +++ b/resources/views/livewire/project/application/configuration.blade.php @@ -83,48 +83,48 @@
- +
- +
- +
@if ($application->git_based())
- +
@endif
- +
- +
- +
- +
- +
- +
- +
- +
- +
- +
diff --git a/resources/views/livewire/project/application/previews.blade.php b/resources/views/livewire/project/application/previews.blade.php index 6d1eb8614..487f2cccd 100644 --- a/resources/views/livewire/project/application/previews.blade.php +++ b/resources/views/livewire/project/application/previews.blade.php @@ -57,7 +57,7 @@
Previews
@foreach ($application->previews as $preview) -
+
PR #{{ data_get($preview, 'pull_request_id') }} | @if (Str::of(data_get($preview, 'status'))->startsWith('running')) @@ -86,18 +86,20 @@ Redeploy @endif - - - Deployment Logs - - - - - Application Logs - - + @if (count($parameters) > 0) + + + Deployment Logs + + + + + Application Logs + + + @endif Delete diff --git a/resources/views/livewire/project/application/rollback.blade.php b/resources/views/livewire/project/application/rollback.blade.php index 0e92fd574..6501155da 100644 --- a/resources/views/livewire/project/application/rollback.blade.php +++ b/resources/views/livewire/project/application/rollback.blade.php @@ -9,7 +9,7 @@
@forelse ($images as $image)
-
+
@if (data_get($image, 'is_current')) diff --git a/resources/views/livewire/project/service/configuration.blade.php b/resources/views/livewire/project/service/configuration.blade.php index 44cecb2dc..3c0e113e4 100644 --- a/resources/views/livewire/project/service/configuration.blade.php +++ b/resources/views/livewire/project/service/configuration.blade.php @@ -75,7 +75,8 @@ - + applicationId="{{ $application->id }}" + wire:key="edit-domain-{{ $application->id }}" /> @endif @@ -160,29 +162,29 @@ Please modify storage layout in your Docker Compose file. @foreach ($applications as $application) + :resource="$application" /> @endforeach @foreach ($databases as $database) - + @endforeach
- +
- +
- +
- +
- +
- +
From e2cd7fe17ec42c2942996eafc11c9339e0d0fb65 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Wed, 17 Apr 2024 15:30:08 +0200 Subject: [PATCH 4/5] fix: rollback feature --- app/Exceptions/Handler.php | 2 +- app/Jobs/ApplicationDeploymentJob.php | 4 ++- app/Livewire/Project/Application/Rollback.php | 1 + bootstrap/helpers/applications.php | 3 +- .../2024_04_17_132541_add_rollback_queues.php | 28 +++++++++++++++++++ 5 files changed, 35 insertions(+), 3 deletions(-) create mode 100644 database/migrations/2024_04_17_132541_add_rollback_queues.php diff --git a/app/Exceptions/Handler.php b/app/Exceptions/Handler.php index 2584df48b..5c8827085 100644 --- a/app/Exceptions/Handler.php +++ b/app/Exceptions/Handler.php @@ -56,7 +56,7 @@ class Handler extends ExceptionHandler { $this->reportable(function (Throwable $e) { if (isDev()) { - // return; + return; } if ($e instanceof RuntimeException) { return; diff --git a/app/Jobs/ApplicationDeploymentJob.php b/app/Jobs/ApplicationDeploymentJob.php index ced01c43c..6bb8eadc7 100644 --- a/app/Jobs/ApplicationDeploymentJob.php +++ b/app/Jobs/ApplicationDeploymentJob.php @@ -49,6 +49,7 @@ class ApplicationDeploymentJob implements ShouldQueue, ShouldBeEncrypted private string $deployment_uuid; private int $pull_request_id; private string $commit; + private bool $rollback; private bool $force_rebuild; private bool $restart_only; @@ -117,6 +118,7 @@ class ApplicationDeploymentJob implements ShouldQueue, ShouldBeEncrypted $this->deployment_uuid = $this->application_deployment_queue->deployment_uuid; $this->pull_request_id = $this->application_deployment_queue->pull_request_id; $this->commit = $this->application_deployment_queue->commit; + $this->rollback = $this->application_deployment_queue->rollback; $this->force_rebuild = $this->application_deployment_queue->force_rebuild; $this->restart_only = $this->application_deployment_queue->restart_only; $this->only_this_server = $this->application_deployment_queue->only_this_server; @@ -1070,7 +1072,7 @@ class ApplicationDeploymentJob implements ShouldQueue, ShouldBeEncrypted ], ); } - if ($this->saved_outputs->get('git_commit_sha')) { + if ($this->saved_outputs->get('git_commit_sha') && !$this->rollback) { $this->commit = $this->saved_outputs->get('git_commit_sha')->before("\t"); } } diff --git a/app/Livewire/Project/Application/Rollback.php b/app/Livewire/Project/Application/Rollback.php index cd778f979..f926b8e12 100644 --- a/app/Livewire/Project/Application/Rollback.php +++ b/app/Livewire/Project/Application/Rollback.php @@ -26,6 +26,7 @@ class Rollback extends Component application: $this->application, deployment_uuid: $deployment_uuid, commit: $commit, + rollback: true, force_rebuild: false, ); return redirect()->route('project.application.deployment.show', [ diff --git a/bootstrap/helpers/applications.php b/bootstrap/helpers/applications.php index 8d810da0f..c0aaf4abf 100644 --- a/bootstrap/helpers/applications.php +++ b/bootstrap/helpers/applications.php @@ -9,7 +9,7 @@ use App\Models\StandaloneDocker; use Illuminate\Support\Collection; use Spatie\Url\Url; -function queue_application_deployment(Application $application, string $deployment_uuid, int | null $pull_request_id = 0, string $commit = 'HEAD', bool $force_rebuild = false, bool $is_webhook = false, bool $restart_only = false, ?string $git_type = null, bool $no_questions_asked = false, Server $server = null, StandaloneDocker $destination = null, bool $only_this_server = false) +function queue_application_deployment(Application $application, string $deployment_uuid, int | null $pull_request_id = 0, string $commit = 'HEAD', bool $force_rebuild = false, bool $is_webhook = false, bool $restart_only = false, ?string $git_type = null, bool $no_questions_asked = false, Server $server = null, StandaloneDocker $destination = null, bool $only_this_server = false, bool $rollback = false) { $application_id = $application->id; $deployment_link = Url::fromString($application->link() . "/deployment/{$deployment_uuid}"); @@ -38,6 +38,7 @@ function queue_application_deployment(Application $application, string $deployme 'is_webhook' => $is_webhook, 'restart_only' => $restart_only, 'commit' => $commit, + 'rollback' => $rollback, 'git_type' => $git_type, 'only_this_server' => $only_this_server ]); diff --git a/database/migrations/2024_04_17_132541_add_rollback_queues.php b/database/migrations/2024_04_17_132541_add_rollback_queues.php new file mode 100644 index 000000000..27865cf0d --- /dev/null +++ b/database/migrations/2024_04_17_132541_add_rollback_queues.php @@ -0,0 +1,28 @@ +boolean('rollback')->default(false); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::table('application_deployment_queues', function (Blueprint $table) { + $table->dropColumn('rollback'); + }); + } +}; From 67011ccd72bf320951070d5f9e9a3d3dc79c5960 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Wed, 17 Apr 2024 15:34:31 +0200 Subject: [PATCH 5/5] fix: base64 encode .env --- app/Jobs/ApplicationDeploymentJob.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/Jobs/ApplicationDeploymentJob.php b/app/Jobs/ApplicationDeploymentJob.php index 6bb8eadc7..80ac8e528 100644 --- a/app/Jobs/ApplicationDeploymentJob.php +++ b/app/Jobs/ApplicationDeploymentJob.php @@ -791,9 +791,10 @@ class ApplicationDeploymentJob implements ShouldQueue, ShouldBeEncrypted "save" => "dotenv" ]); if (str($this->saved_outputs->get('dotenv'))->isNotEmpty()) { + $base64_dotenv = base64_encode($this->saved_outputs->get('dotenv')->value()); $this->execute_remote_command( [ - "echo '{$this->saved_outputs->get('dotenv')->value()}' | tee $this->configuration_dir/.env > /dev/null" + "echo '{$base64_dotenv}' | base64 -d | tee $this->configuration_dir/.env > /dev/null" ] ); } else {