Skip to content

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.

fix(application): add functionality to stop and remove Docker containers on server

Andras Bacsai0db28355654b
diff --git a/app/Livewire/Project/Application/Previews.php b/app/Livewire/Project/Application/Previews.php
index e0f517428e..1cb2ef2c5f 100644
--- a/app/Livewire/Project/Application/Previews.php
+++ b/app/Livewire/Project/Application/Previews.php
@@ -231,6 +231,18 @@ class Previews extends Component
$this->parameters['deployment_uuid'] = $this->deployment_uuid;
}
+ private function stopContainers(array $containers, $server)
+ {
+ $containersToStop = collect($containers)->pluck('Names')->toArray();
+
+ foreach ($containersToStop as $containerName) {
+ instant_remote_process(command: [
+ "docker stop --time=30 $containerName",
+ "docker rm -f $containerName",
+ ], server: $server, throwError: false);
+ }
+ }
+
public function stop(int $pull_request_id)
{
$this->authorize('deploy', $this->application);