2024-01-12 07:45:24 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Actions\Server;
|
|
|
|
|
|
|
|
use App\Models\Server;
|
2024-06-10 20:43:34 +00:00
|
|
|
use Lorisleiva\Actions\Concerns\AsAction;
|
2024-01-12 07:45:24 +00:00
|
|
|
|
|
|
|
class CleanupDocker
|
|
|
|
{
|
|
|
|
use AsAction;
|
2024-06-10 20:43:34 +00:00
|
|
|
|
2024-01-12 07:45:24 +00:00
|
|
|
public function handle(Server $server, bool $force = true)
|
|
|
|
{
|
|
|
|
if ($force) {
|
|
|
|
instant_remote_process(['docker image prune -af'], $server, false);
|
|
|
|
instant_remote_process(['docker container prune -f --filter "label=coolify.managed=true"'], $server, false);
|
|
|
|
instant_remote_process(['docker builder prune -af'], $server, false);
|
|
|
|
} else {
|
|
|
|
instant_remote_process(['docker image prune -f'], $server, false);
|
|
|
|
instant_remote_process(['docker container prune -f --filter "label=coolify.managed=true"'], $server, false);
|
|
|
|
instant_remote_process(['docker builder prune -f'], $server, false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|