feat: get command and output for logs from CleanupDocker

This commit is contained in:
peaklabs-dev 2025-01-15 19:54:58 +01:00
parent 85f38b7cb5
commit 7bdef134e6
No known key found for this signature in database

View file

@ -25,17 +25,25 @@ public function handle(Server $server)
"docker images --filter before=$helperImageWithVersion --filter reference=$helperImage | grep $helperImage | awk '{print $3}' | xargs -r docker rmi -f",
];
$serverSettings = $server->settings;
if ($serverSettings->delete_unused_volumes) {
if ($server->settings->delete_unused_volumes) {
$commands[] = 'docker volume prune -af';
}
if ($serverSettings->delete_unused_networks) {
if ($server->settings->delete_unused_networks) {
$commands[] = 'docker network prune -f';
}
$cleanupLog = [];
foreach ($commands as $command) {
instant_remote_process([$command], $server, false);
$commandOutput = instant_remote_process([$command], $server, false);
if ($commandOutput !== null) {
$cleanupLog[] = [
'command' => $command,
'output' => $commandOutput,
];
}
}
return $cleanupLog;
}
}