diff --git a/php/public/index.php b/php/public/index.php index eb2a7878ac6..eaf02fa0713 100644 --- a/php/public/index.php +++ b/php/public/index.php @@ -105,6 +105,7 @@ $app->post('/api/docker/stop', AIO\Controller\DockerController::class . ':StopContainer'); $app->post('/api/docker/backup-reset-location', AIO\Controller\DockerController::class . ':DeleteBorgBackupConfig'); $app->post('/api/docker/prune', AIO\Controller\DockerController::class . ':SystemPrune'); +$app->post('/api/docker/pull-images', AIO\Controller\DockerController::class . ':PullImages'); $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'); diff --git a/php/src/Controller/DockerController.php b/php/src/Controller/DockerController.php index 66e8a3e2edf..94b78213af8 100644 --- a/php/src/Controller/DockerController.php +++ b/php/src/Controller/DockerController.php @@ -45,15 +45,15 @@ private function PerformRecursiveContainerStart(string $id, bool $pullImage = tr $this->dockerActionManager->ConnectContainerToNetwork($container); } - private function PerformRecursiveImagePull(string $id) : void { + private function PerformRecursiveImagePull(string $id, ?\Closure $addToStreamingResponseBody = null) : void { $container = $this->containerDefinitionFetcher->GetContainerById($id); // Pull all dependencies first and then itself foreach($container->dependsOn as $dependency) { - $this->PerformRecursiveImagePull($dependency); + $this->PerformRecursiveImagePull($dependency, $addToStreamingResponseBody); } - $this->dockerActionManager->PullImage($container, true); + $this->dockerActionManager->PullImage($container, true, $addToStreamingResponseBody); } public function PullAllContainerImages(): void { @@ -63,6 +63,19 @@ public function PullAllContainerImages(): void { $this->PerformRecursiveImagePull($id); } + public function PullImages(Request $request, Response $response, array $args) : Response { + // Get streaming response start and closure + $nonbufResp = $this->startStreamingResponse($response); + $addToStreamingResponseBody = $this->getAddToStreamingResponseBody($nonbufResp); + + $id = self::TOP_CONTAINER; + $this->PerformRecursiveImagePull($id, $addToStreamingResponseBody); + + // End streaming response + $this->finalizeStreamingResponse($nonbufResp); + return $nonbufResp; + } + public function GetLogs(Request $request, Response $response, array $args) : Response { $requestParams = $request->getQueryParams(); diff --git a/php/templates/containers.twig b/php/templates/containers.twig index 8faa4474f74..d40ae3fad8c 100644 --- a/php/templates/containers.twig +++ b/php/templates/containers.twig @@ -291,6 +291,14 @@ {% if has_update_available == true %} {% if is_mastercontainer_update_available == false %}

⚠️ Container updates are available. Click on Stop containers and Start and update containers to update them. You should consider creating a backup first.

+ {% if isAnyRunning == true and isApacheStarting != true %} +

Alternatively, you can already pull the new images now while the containers are still running. Depending on your internet connection and image sizes, this can take a few minutes. The new images will automatically be used whenever the containers are recreated – either manually via Stop containers + Start and update containers, or automatically via AIO's daily backup/update schedule.

+
+ + + +
+ {% endif %} {% endif %} {% else %} {% if is_mastercontainer_update_available == false %}