An open-source, self-hostable PaaS alternative to Vercel, Heroku & Netlify that lets you easily deploy static sites, databases, full-stack applications and 360+ one-click services on your own servers.
PHP coolifydatabasesdeploymentdockerdocker-composeinertiajslaravelmariadbmysqlnextjsnodejsphppostgresredisself-hostedself-hostingserverstatic-sitesveltesvelte5
feat: pull latest images for services
Andras Bacsai75d1ec4f42c8
diff --git a/app/Actions/Service/StartService.php b/app/Actions/Service/StartService.phpindex dc722aa830..a90b368abc 100644--- a/app/Actions/Service/StartService.php+++ b/app/Actions/Service/StartService.php@@ -11,6 +11,7 @@ class StartServiceuse AsAction;public function handle(Service $service){+ ray('Starting service: ' . $service->name);$network = $service->destination->network;$service->saveComposeConfigs();$commands[] = "cd " . $service->workdir();diff --git a/app/Actions/Service/StopService.php b/app/Actions/Service/StopService.phpindex f7de50165d..d9ac6376e8 100644--- a/app/Actions/Service/StopService.php+++ b/app/Actions/Service/StopService.php@@ -10,6 +10,7 @@ class StopServiceuse AsAction;public function handle(Service $service){+ ray('Stopping service: ' . $service->name);$applications = $service->applications()->get();foreach ($applications as $application) {instant_remote_process(["docker rm -f {$application->name}-{$service->uuid}"], $service->server);diff --git a/app/Actions/Shared/PullImage.php b/app/Actions/Shared/PullImage.phpnew file mode 100644index 0000000000..42713b2273--- /dev/null+++ b/app/Actions/Shared/PullImage.php@@ -0,0 +1,25 @@+<?php++namespace App\Actions\Shared;++use App\Models\Service;+use Lorisleiva\Actions\Concerns\AsAction;++class PullImage+{+ use AsAction;+ public function handle(Service $resource)+ {+ $resource->saveComposeConfigs();++ $commands[] = "cd " . $resource->workdir();+ $commands[] = "echo 'Saved configuration files to {$resource->workdir()}.'";+ $commands[] = "docker compose pull";++ $server = data_get($resource, 'server');++ if (!$server) return;++ instant_remote_process($commands, $resource->server);+ }+}diff --git a/app/Livewire/Project/Service/Navbar.php b/app/Livewire/Project/Service/Navbar.phpindex 3e2c3485c7..d401a10221 100644--- a/app/Livewire/Project/Service/Navbar.php+++ b/app/Livewire/Project/Service/Navbar.php@@ -2,6 +2,7 @@namespace App\Livewire\Project\Service;+use App\Actions\Shared\PullImage;use App\Actions\Service\StartService;use App\Actions\Service\StopService;use App\Events\ServiceStatusChanged;@@ -69,4 +70,18 @@ class Navbar extends Component}ServiceStatusChanged::dispatch();}+ public function restart()+ {+ $this->checkDeployments();+ if ($this->isDeploymentProgress) {+ $this->dispatch('error', 'There is a deployment in progress.');+ return;+ }+ PullImage::run($this->service);+ $this->dispatch('image-pulled');+ StopService::run($this->service);+ $this->service->parse();+ $activity = StartService::run($this->service);+ $this->dispatch('newMonitorActivity', $activity->id);+ }}diff --git a/resources/views/components/services/navbar.blade.php b/resources/views/components/services/navbar.blade.phpindex 84ad7c6e1f..c25bb3eac2 100644--- a/resources/views/components/services/navbar.blade.php+++ b/resources/views/components/services/navbar.blade.php@@ -1,4 +1,4 @@-<div class="navbar-main">+<div class="navbar-main" x-data><a wire:navigate class="{{ request()->routeIs('project.service.configuration') ? 'text-white' : '' }}"href="{{ route('project.service.configuration', $parameters) }}"><button>Configuration</button>@@ -27,6 +27,16 @@</button>@endif@if (serviceStatus($service) === 'running')+ <button wire:click='restart' class="flex items-center gap-2 cursor-pointer hover:text-white text-neutral-400">+ <svg class="w-5 h-5 text-warning" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">+ <g fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round"+ stroke-width="2">+ <path d="M19.933 13.041a8 8 0 1 1-9.925-8.788c3.899-1 7.935 1.007 9.425 4.747" />+ <path d="M20 4v5h-5" />+ </g>+ </svg>+ Pull Latest Images & Restart+ </button><button wire:click='stop' class="flex items-center gap-2 cursor-pointer hover:text-white text-neutral-400"><svg xmlns="http://www.w3.org/2000/svg" class="w-5 h-5 text-error" viewBox="0 0 24 24" stroke-width="2"stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round">@@ -58,3 +68,11 @@</button>@endif</div>++@script+<script>+ $wire.on('image-pulled', () => {+ startService.showModal();+ });+</script>+@endscript