mirror of
https://github.com/nextcloud/all-in-one.git
synced 2026-05-30 15:30:08 +00:00
aio-interface: offer system prune button
Signed-off-by: Simon L. <szaimen@e.mail.de>
This commit is contained in:
@@ -66,6 +66,7 @@ $app->post('/api/docker/backup-check-repair', AIO\Controller\DockerController::c
|
||||
$app->post('/api/docker/backup-test', AIO\Controller\DockerController::class . ':StartBackupContainerTest');
|
||||
$app->post('/api/docker/restore', AIO\Controller\DockerController::class . ':StartBackupContainerRestore');
|
||||
$app->post('/api/docker/stop', AIO\Controller\DockerController::class . ':StopContainer');
|
||||
$app->post('/api/docker/prune', AIO\Controller\DockerController::class . ':SystemPrune');
|
||||
$app->get('/api/docker/logs', AIO\Controller\DockerController::class . ':GetLogs');
|
||||
$app->post('/api/auth/login', AIO\Controller\LoginController::class . ':TryLogin');
|
||||
$app->get('/api/auth/getlogin', AIO\Controller\LoginController::class . ':GetTryLogin');
|
||||
|
||||
@@ -285,6 +285,11 @@ readonly class DockerController {
|
||||
return $response->withStatus(201)->withHeader('Location', '.');
|
||||
}
|
||||
|
||||
public function SystemPrune(Request $request, Response $response, array $args) : Response {
|
||||
$this->dockerActionManager->SystemPrune();
|
||||
return $response->withStatus(201)->withHeader('Location', '.');
|
||||
}
|
||||
|
||||
public function stopTopContainer() : void {
|
||||
$id = self::TOP_CONTAINER;
|
||||
$this->PerformRecursiveContainerStop($id);
|
||||
|
||||
@@ -983,4 +983,36 @@ readonly class DockerActionManager {
|
||||
return $this->dockerHubManager->GetLatestDigestOfTag($imageName, $tag);
|
||||
}
|
||||
}
|
||||
|
||||
public function SystemPrune(): void {
|
||||
$endpoints = [
|
||||
// Remove stopped containers
|
||||
'containers/prune',
|
||||
// Remove unused images
|
||||
'images/prune',
|
||||
// Remove unused volumes
|
||||
'volumes/prune',
|
||||
// Remove unused networks
|
||||
'networks/prune',
|
||||
// Prune build cache
|
||||
'build/prune',
|
||||
];
|
||||
|
||||
foreach ($endpoints as $endpoint) {
|
||||
// Special-case images prune to include the dangling filter as requested
|
||||
if ($endpoint === 'images/prune') {
|
||||
$filters = json_encode(['dangling' => ['false']]);
|
||||
$url = $this->BuildApiUrl($endpoint . '?filters=' . urlencode($filters));
|
||||
} else {
|
||||
$url = $this->BuildApiUrl($endpoint);
|
||||
}
|
||||
|
||||
try {
|
||||
$this->guzzleClient->post($url);
|
||||
} catch (RequestException $e) {
|
||||
error_log(sprintf('Docker prune (%s) failed: %s', $endpoint, $e->getMessage()));
|
||||
// continue with next prune step
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -322,6 +322,11 @@
|
||||
<input type="hidden" name="{{csrf.keys.value}}" value="{{csrf.value}}">
|
||||
<input type="submit" value="Stop containers" />
|
||||
</form>
|
||||
<form method="POST" action="api/docker/prune" class="xhr">
|
||||
<input type="hidden" name="{{csrf.keys.name}}" value="{{csrf.name}}">
|
||||
<input type="hidden" name="{{csrf.keys.value}}" value="{{csrf.value}}">
|
||||
<input type="submit" value="Run docker system prune" onclick="return confirm('Run docker system prune? This will remove unused images, containers and volumes. Continue?')" />
|
||||
</form>
|
||||
{% endif %}
|
||||
{% else %}
|
||||
{% if isBackupOrRestoreRunning == true %}
|
||||
|
||||
Reference in New Issue
Block a user