2024-01-12 08:45:24 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Actions\Server;
|
|
|
|
|
|
|
|
use App\Models\Server;
|
2024-06-10 22:43:34 +02:00
|
|
|
use Lorisleiva\Actions\Concerns\AsAction;
|
2024-01-12 08:45:24 +01:00
|
|
|
|
|
|
|
class CleanupDocker
|
|
|
|
{
|
|
|
|
use AsAction;
|
2024-06-10 22:43:34 +02:00
|
|
|
|
2024-08-21 10:50:05 +02:00
|
|
|
public function handle(Server $server)
|
2024-08-18 22:41:06 +02:00
|
|
|
{
|
2024-08-26 11:13:40 +02:00
|
|
|
|
2024-08-26 12:23:03 +02:00
|
|
|
$commands = $this->getCommands();
|
2024-08-18 22:41:06 +02:00
|
|
|
|
|
|
|
foreach ($commands as $command) {
|
|
|
|
instant_remote_process([$command], $server, false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-08-26 12:23:03 +02:00
|
|
|
private function getCommands(): array
|
2024-01-12 08:45:24 +01:00
|
|
|
{
|
2024-08-09 23:27:39 +02:00
|
|
|
$commonCommands = [
|
|
|
|
'docker container prune -f --filter "label=coolify.managed=true"',
|
2024-08-26 12:23:03 +02:00
|
|
|
'docker image prune -af',
|
|
|
|
'docker builder prune -af',
|
2024-08-09 23:27:39 +02:00
|
|
|
];
|
|
|
|
|
2024-08-18 22:41:06 +02:00
|
|
|
return $commonCommands;
|
2024-01-12 08:45:24 +01:00
|
|
|
}
|
|
|
|
}
|