From 2b64b9de63a5489164289780fe7a192677d1e20a Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Fri, 5 Apr 2024 15:33:11 +0200 Subject: [PATCH 1/7] fix: do not rebuild dockerfile based apps twice --- app/Jobs/ApplicationDeploymentJob.php | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/app/Jobs/ApplicationDeploymentJob.php b/app/Jobs/ApplicationDeploymentJob.php index 356006983..51c024af6 100644 --- a/app/Jobs/ApplicationDeploymentJob.php +++ b/app/Jobs/ApplicationDeploymentJob.php @@ -469,17 +469,17 @@ class ApplicationDeploymentJob implements ShouldQueue, ShouldBeEncrypted $this->set_base_dir(); $this->generate_image_names(); $this->clone_repository(); - // if (!$this->force_rebuild) { - // $this->check_image_locally_or_remotely(); - // if (str($this->saved_outputs->get('local_image_found'))->isNotEmpty() && !$this->application->isConfigurationChanged()) { - // $this->create_workdir(); - // $this->application_deployment_queue->addLogEntry("No configuration changed & image found ({$this->production_image_name}) with the same Git Commit SHA. Build step skipped."); - // $this->generate_compose_file(); - // $this->push_to_docker_registry(); - // $this->rolling_update(); - // return; - // } - // } + if (!$this->force_rebuild) { + $this->check_image_locally_or_remotely(); + if (str($this->saved_outputs->get('local_image_found'))->isNotEmpty() && !$this->application->isConfigurationChanged()) { + $this->create_workdir(); + $this->application_deployment_queue->addLogEntry("No configuration changed & image found ({$this->production_image_name}) with the same Git Commit SHA. Build step skipped."); + $this->generate_compose_file(); + $this->push_to_docker_registry(); + $this->rolling_update(); + return; + } + } $this->cleanup_git(); $this->generate_compose_file(); $this->generate_build_env_variables(); From d84fdc3cd5df7082e5d543a1157057e7a17bd3da Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Fri, 5 Apr 2024 15:33:19 +0200 Subject: [PATCH 2/7] fix: make sure if envs are changed, rebuild is needed --- app/Models/Application.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/Models/Application.php b/app/Models/Application.php index 4aef5db69..4d330a00c 100644 --- a/app/Models/Application.php +++ b/app/Models/Application.php @@ -502,9 +502,9 @@ class Application extends BaseModel { $newConfigHash = $this->fqdn . $this->git_repository . $this->git_branch . $this->git_commit_sha . $this->build_pack . $this->static_image . $this->install_command . $this->build_command . $this->start_command . $this->port_exposes . $this->port_mappings . $this->base_directory . $this->publish_directory . $this->dockerfile . $this->dockerfile_location . $this->custom_labels; if ($this->pull_request_id === 0 || $this->pull_request_id === null) { - $newConfigHash .= json_encode($this->environment_variables()); + $newConfigHash .= json_encode($this->environment_variables()->get('updated_at')); } else { - $newConfigHash .= json_encode($this->environment_variables_preview->all()); + $newConfigHash .= json_encode($this->environment_variables_preview->get('updated_at')); } $newConfigHash = md5($newConfigHash); $oldConfigHash = data_get($this, 'config_hash'); From 30bfad455c42b3f52890311ccf9c123814a8f380 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Fri, 5 Apr 2024 15:33:29 +0200 Subject: [PATCH 3/7] ui: multiple server view --- .../project/shared/destination.blade.php | 83 ++++++++++--------- 1 file changed, 46 insertions(+), 37 deletions(-) diff --git a/resources/views/livewire/project/shared/destination.blade.php b/resources/views/livewire/project/shared/destination.blade.php index 6e494d3e7..013ca5e4f 100644 --- a/resources/views/livewire/project/shared/destination.blade.php +++ b/resources/views/livewire/project/shared/destination.blade.php @@ -2,9 +2,10 @@

Servers

Server related configurations.
-
-
-
Primary Server
+
+

Primary Server

+
@if (str($resource->realStatus())->startsWith('running'))
@@ -12,26 +13,29 @@
@endif -
+
Server: {{ data_get($resource, 'destination.server.name') }}
-
+
Network: {{ data_get($resource, 'destination.network') }}
@if ($resource?->additional_networks?->count() > 0) - Deploy - @if (str($resource->realStatus())->startsWith('running')) - Stop - @endif +
+ Deploy + @if (str($resource->realStatus())->startsWith('running')) + Stop + @endif +
@endif
@if ($resource?->additional_networks?->count() > 0) +

Additional Server(s)

@foreach ($resource->additional_networks as $destination) -
-
+
+
@if (str(data_get($destination, 'pivot.status'))->startsWith('running'))
@@ -40,28 +44,31 @@ class="absolute bg-error -top-1 -left-1 badge ">
@endif
- Server: {{ data_get($destination, 'server.name') }} -
-
- Network: {{ data_get($destination, 'network') }} +
+ Server: {{ data_get($destination, 'server.name') }} +
+
+ Network: {{ data_get($destination, 'network') }} +
- Deploy - Promote - to Primary - @if (data_get_str($destination, 'pivot.status')->startsWith('running')) - Stop - @endif - - This will stop the running application in this server and remove it as a deployment - destination.

Please think again. -
- +
+ Deploy + Promote + to Primary + @if (data_get_str($destination, 'pivot.status')->startsWith('running')) + Stop + @endif + + This will stop the running application in this server and remove it as a deployment + destination.

Please think again. +
+
@endforeach @endif @@ -75,10 +82,12 @@
- Server: {{ data_get($network, 'server.name') }} -
-
- Network: {{ data_get($network, 'name') }} +
+ Server: {{ data_get($network, 'server.name') }} +
+
+ Network: {{ data_get($network, 'name') }} +
@endforeach From 0844645a8b551f823695edaf17c99449b8fd25c5 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Fri, 5 Apr 2024 15:33:33 +0200 Subject: [PATCH 4/7] version++ --- 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 bef8d46c8..9561601c1 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.249', + 'release' => '4.0.0-beta.250', // 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 cabb9ad06..bcd3a45f5 100644 --- a/config/version.php +++ b/config/version.php @@ -1,3 +1,3 @@ Date: Fri, 5 Apr 2024 15:42:31 +0200 Subject: [PATCH 5/7] Fix deploy button alignment in destination.blade.php --- resources/views/livewire/project/shared/destination.blade.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/views/livewire/project/shared/destination.blade.php b/resources/views/livewire/project/shared/destination.blade.php index 013ca5e4f..6d0dc0a62 100644 --- a/resources/views/livewire/project/shared/destination.blade.php +++ b/resources/views/livewire/project/shared/destination.blade.php @@ -21,7 +21,7 @@
@if ($resource?->additional_networks?->count() > 0) -
+
Deploy @if (str($resource->realStatus())->startsWith('running')) From c223408c3cb1d37ae17af53634627f1011b5ebb6 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Fri, 5 Apr 2024 15:59:59 +0200 Subject: [PATCH 6/7] Add updatedApplicationFqdn method to ServiceApplicationView --- .../Project/Service/ServiceApplicationView.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/app/Livewire/Project/Service/ServiceApplicationView.php b/app/Livewire/Project/Service/ServiceApplicationView.php index 70a8662d5..0986987f9 100644 --- a/app/Livewire/Project/Service/ServiceApplicationView.php +++ b/app/Livewire/Project/Service/ServiceApplicationView.php @@ -24,6 +24,16 @@ class ServiceApplicationView extends Component { return view('livewire.project.service.service-application-view'); } + public function updatedApplicationFqdn() + { + $this->application->fqdn = str($this->application->fqdn)->replaceEnd(',', '')->trim(); + $this->application->fqdn = str($this->application->fqdn)->replaceStart(',', '')->trim(); + $this->application->fqdn = str($this->application->fqdn)->trim()->explode(',')->map(function ($domain) { + return str($domain)->trim()->lower(); + }); + $this->application->fqdn = $this->application->fqdn->unique()->implode(','); + $this->application->save(); + } public function instantSave() { $this->submit(); From 36c31dcd6777095f8fec4819ba5d860943db8b47 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Fri, 5 Apr 2024 16:48:06 +0200 Subject: [PATCH 7/7] Add role-based authorization for updating teams --- app/Models/Team.php | 8 +++++--- app/Models/User.php | 4 ++++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/app/Models/Team.php b/app/Models/Team.php index a3dd4e473..e08ba7f5b 100644 --- a/app/Models/Team.php +++ b/app/Models/Team.php @@ -21,9 +21,11 @@ class Team extends Model implements SendsDiscord, SendsEmail protected static function booted() { - // static::saved(function () { - // refreshSession(); - // }); + static::saving(function ($team) { + if (auth()->user()->isMember()) { + throw new \Exception('You are not allowed to update this team.'); + } + }); } public function routeNotificationForDiscord() diff --git a/app/Models/User.php b/app/Models/User.php index e2ecae56a..0fa8ead2f 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -127,6 +127,10 @@ class User extends Authenticatable implements SendsEmail { return $this->role() === 'owner'; } + public function isMember() + { + return $this->role() === 'member'; + } public function isAdminFromSession() { if (auth()->user()->id === 0) {