From bf953bf1b587fafbe514ff10b577be83aa91a751 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Thu, 16 May 2024 21:35:57 +0200 Subject: [PATCH 01/12] Update version numbers --- 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 0f7ae133f..d7b871287 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.280', + 'release' => '4.0.0-beta.281', // 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 651fec610..b0e477b06 100644 --- a/config/version.php +++ b/config/version.php @@ -1,3 +1,3 @@ Date: Thu, 16 May 2024 21:36:01 +0200 Subject: [PATCH 02/12] Add all_servers property to Kernel class for better code organization --- app/Console/Kernel.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php index 51e4cfc17..23289f90e 100644 --- a/app/Console/Kernel.php +++ b/app/Console/Kernel.php @@ -21,8 +21,10 @@ use Illuminate\Foundation\Console\Kernel as ConsoleKernel; class Kernel extends ConsoleKernel { + private $all_servers; protected function schedule(Schedule $schedule): void { + $this->all_servers = Server::all(); if (isDev()) { // Instance Jobs $schedule->command('horizon:snapshot')->everyMinute(); @@ -56,7 +58,7 @@ class Kernel extends ConsoleKernel } private function pull_helper_image($schedule) { - $servers = Server::all()->where('settings.is_usable', true)->where('settings.is_reachable', true)->where('ip', '!=', '1.2.3.4'); + $servers = $this->all_servers->where('settings.is_usable', true)->where('settings.is_reachable', true)->where('ip', '!=', '1.2.3.4'); foreach ($servers as $server) { if (config('coolify.is_sentinel_enabled')) { $schedule->job(new PullSentinelImageJob($server))->everyFiveMinutes()->onOneServer(); @@ -67,12 +69,12 @@ class Kernel extends ConsoleKernel private function check_resources($schedule) { if (isCloud()) { - $servers = Server::all()->whereNotNull('team.subscription')->where('team.subscription.stripe_trial_already_ended', false)->where('ip', '!=', '1.2.3.4'); + $servers = $this->all_servers->whereNotNull('team.subscription')->where('team.subscription.stripe_trial_already_ended', false)->where('ip', '!=', '1.2.3.4'); $own = Team::find(0)->servers; $servers = $servers->merge($own); $containerServers = $servers->where('settings.is_swarm_worker', false)->where('settings.is_build_server', false); } else { - $servers = Server::all()->where('ip', '!=', '1.2.3.4'); + $servers = $this->all_servers->where('ip', '!=', '1.2.3.4'); $containerServers = $servers->where('settings.is_swarm_worker', false)->where('settings.is_build_server', false); } foreach ($containerServers as $server) { From 10fde1b1efa33024a7d59676fa26a5e92a17cfe7 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Fri, 17 May 2024 08:53:25 +0200 Subject: [PATCH 03/12] feat: shows the latest deployment commit + message on status --- app/Livewire/Project/Application/Heading.php | 7 ++++++- app/Models/Application.php | 4 ++++ .../views/components/resources/breadcrumbs.blade.php | 4 ++-- resources/views/components/status/index.blade.php | 8 ++++++-- .../views/components/status/restarting.blade.php | 12 ++++++++++-- resources/views/components/status/running.blade.php | 12 +++++++++--- .../livewire/project/application/heading.blade.php | 2 +- 7 files changed, 38 insertions(+), 11 deletions(-) diff --git a/app/Livewire/Project/Application/Heading.php b/app/Livewire/Project/Application/Heading.php index 06b9a3c3c..619be693d 100644 --- a/app/Livewire/Project/Application/Heading.php +++ b/app/Livewire/Project/Application/Heading.php @@ -5,7 +5,7 @@ namespace App\Livewire\Project\Application; use App\Actions\Application\StopApplication; use App\Actions\Docker\GetContainersStatus; use App\Events\ApplicationStatusChanged; - use App\Jobs\ContainerStatusJob; +use App\Jobs\ContainerStatusJob; use App\Jobs\ServerStatusJob; use App\Models\Application; use Livewire\Component; @@ -14,6 +14,8 @@ use Visus\Cuid2\Cuid2; class Heading extends Component { public Application $application; + public ?string $lastDeploymentInfo = null; + public ?string $lastDeploymentLink = null; public array $parameters; protected string $deploymentUuid; @@ -28,6 +30,9 @@ class Heading extends Component public function mount() { $this->parameters = get_route_parameters(); + $lastDeployment = $this->application->get_last_successful_deployment(); + $this->lastDeploymentInfo = data_get_str($lastDeployment, 'commit')->limit(7) . ' ' . data_get($lastDeployment, 'commit_message'); + $this->lastDeploymentLink = $this->application->gitCommitLink(data_get($lastDeployment, 'commit')); } public function check_status($showNotification = false) diff --git a/app/Models/Application.php b/app/Models/Application.php index fd3faa166..63ae132b1 100644 --- a/app/Models/Application.php +++ b/app/Models/Application.php @@ -454,6 +454,10 @@ class Application extends BaseModel } return false; } + public function get_last_successful_deployment() + { + return ApplicationDeploymentQueue::where('application_id', $this->id)->where('status', 'finished')->orderBy('created_at', 'desc')->first(); + } public function get_last_days_deployments() { return ApplicationDeploymentQueue::where('application_id', $this->id)->where('created_at', '>=', now()->subDays(7))->orderBy('created_at', 'desc')->get(); diff --git a/resources/views/components/resources/breadcrumbs.blade.php b/resources/views/components/resources/breadcrumbs.blade.php index 1e5aaa997..90477810c 100644 --- a/resources/views/components/resources/breadcrumbs.blade.php +++ b/resources/views/components/resources/breadcrumbs.blade.php @@ -1,5 +1,5 @@ diff --git a/resources/views/components/status/index.blade.php b/resources/views/components/status/index.blade.php index 4ee3319ff..c8a9f9b55 100644 --- a/resources/views/components/status/index.blade.php +++ b/resources/views/components/status/index.blade.php @@ -1,9 +1,13 @@ +@props([ + 'lastDeploymentInfo' => null, + 'lastDeploymentLink' => null, +]) @if (str($resource->status)->startsWith('running')) - + @elseif(str($resource->status)->startsWith('restarting') || str($resource->status)->startsWith('starting') || str($resource->status)->startsWith('degraded')) - + @else @endif diff --git a/resources/views/components/status/restarting.blade.php b/resources/views/components/status/restarting.blade.php index bb555c745..f269b4a5a 100644 --- a/resources/views/components/status/restarting.blade.php +++ b/resources/views/components/status/restarting.blade.php @@ -1,12 +1,20 @@ @props([ 'status' => 'Restarting', + 'lastDeploymentInfo' => null, + 'lastDeploymentLink' => null, ])
-
- {{ str($status)->before(':')->headline() }} +
+ @if ($lastDeploymentLink) + + {{ str($status)->before(':')->headline() }} + + @else + {{ str($status)->before(':')->headline() }} + @endif
@if (!str($status)->startsWith('Proxy') && !str($status)->contains('('))
({{ str($status)->after(':') }})
diff --git a/resources/views/components/status/running.blade.php b/resources/views/components/status/running.blade.php index 52758303b..b22f2d057 100644 --- a/resources/views/components/status/running.blade.php +++ b/resources/views/components/status/running.blade.php @@ -1,12 +1,20 @@ @props([ 'status' => 'Running', + 'lastDeploymentInfo' => null, + 'lastDeploymentLink' => null, ])
-
+
+ @if ($lastDeploymentLink) + + {{ str($status)->before(':')->headline() }} + + @else {{ str($status)->before(':')->headline() }} + @endif
@if (!str($status)->startsWith('Proxy') && !str($status)->contains('(')) @if (str($status)->contains('unhealthy')) @@ -17,8 +25,6 @@ - {{-- @else -
({{ str($status)->after(':') }})
--}} @endif @endif diff --git a/resources/views/livewire/project/application/heading.blade.php b/resources/views/livewire/project/application/heading.blade.php index 7cd686d83..2f0bba535 100644 --- a/resources/views/livewire/project/application/heading.blade.php +++ b/resources/views/livewire/project/application/heading.blade.php @@ -1,5 +1,5 @@