fix delte networks and unused images of services when deleted

This commit is contained in:
ayntk-ai 2024-08-08 01:02:48 +02:00
parent 10b9c4bcfa
commit df796dffa2
No known key found for this signature in database

View file

@ -3,6 +3,7 @@
namespace App\Actions\Service;
use App\Models\Service;
use App\Actions\Server\CleanupDocker;
use Lorisleiva\Actions\Concerns\AsAction;
class DeleteService
@ -33,6 +34,11 @@ public function handle(Service $service)
foreach ($storagesToDelete as $storage) {
$commands[] = "docker volume rm -f $storage->name";
}
$uuid = $service->uuid;
instant_remote_process(["docker network disconnect {$uuid} coolify-proxy"], $server, false);
instant_remote_process(["docker network rm {$uuid}"], $server, false);
$commands[] = "docker rm -f $service->uuid";
instant_remote_process($commands, $server, false);
@ -50,6 +56,9 @@ public function handle(Service $service)
$task->delete();
}
$service->tags()->detach();
$service->forceDelete();
CleanupDocker::run($server, true);
}
}
}