fix: docker cleanup job

This commit is contained in:
Andras Bacsai
2024-08-26 12:23:03 +02:00
parent 4d7877ce1d
commit 3d73c98779
10 changed files with 231 additions and 179 deletions

View File

@@ -12,29 +12,21 @@ class CleanupDocker
public function handle(Server $server)
{
$commands = $this->getCommands($force);
$commands = $this->getCommands();
foreach ($commands as $command) {
instant_remote_process([$command], $server, false);
}
}
private function getCommands(bool $force): array
private function getCommands(): array
{
$commonCommands = [
'docker container prune -f --filter "label=coolify.managed=true"',
'docker image prune -f',
'docker builder prune -f',
'docker image prune -af',
'docker builder prune -af',
];
if ($force) {
return array_merge([
'docker container prune -f --filter "label=coolify.managed=true"',
'docker image prune -af',
'docker builder prune -af',
], $commonCommands);
}
return $commonCommands;
}
}