From 2552c24c6f5503f449abdf692864b4159df651a3 Mon Sep 17 00:00:00 2001 From: Apoorv Parle <19315187+apparle@users.noreply.github.com> Date: Fri, 20 Jun 2025 01:17:45 -0700 Subject: [PATCH] Merge pull request #5568 from apparle/enable_local_testability mastercontainer: enable local testability --- Containers/mastercontainer/Dockerfile | 5 ++++- develop.md | 10 ++++++++++ php/public/index.php | 7 ++++++- 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/Containers/mastercontainer/Dockerfile b/Containers/mastercontainer/Dockerfile index f798254d..3a61e718 100644 --- a/Containers/mastercontainer/Dockerfile +++ b/Containers/mastercontainer/Dockerfile @@ -8,6 +8,9 @@ FROM caddy:2.10.0-alpine AS caddy # From https://github.com/docker-library/php/blob/master/8.4/alpine3.21/fpm/Dockerfile FROM php:8.4.8-fpm-alpine3.21 +ARG AIO_GIT_URL="https://github.com/nextcloud-releases/all-in-one.git" +ARG AIO_GIT_BRANCH="main" + EXPOSE 80 EXPOSE 8080 EXPOSE 8443 @@ -64,7 +67,7 @@ RUN set -ex; \ wget https://getcomposer.org/installer -O - | php -- --install-dir=/usr/local/bin --filename=composer; \ chmod +x /usr/local/bin/composer; \ cd /var/www/docker-aio; \ - git clone https://github.com/nextcloud-releases/all-in-one.git --depth 1 .; \ + git clone "$AIO_GIT_URL" --depth 1 --single-branch --branch "$AIO_GIT_BRANCH" .; \ find ./ -maxdepth 1 -mindepth 1 -not -path ./php -not -path ./community-containers -exec rm -r {} \; ; \ rm -r ./php/tests; \ chown www-data:www-data -R /var/www/docker-aio; \ diff --git a/develop.md b/develop.md index b6aa031d..abf52208 100644 --- a/develop.md +++ b/develop.md @@ -47,3 +47,13 @@ This is documented here: https://github.com/nextcloud-releases/all-in-one/tree/m ## How to connect to the database? Simply run `sudo docker exec -it nextcloud-aio-database psql -U oc_nextcloud nextcloud_database` and you should be in. + +## How to locally build and test changes to mastercontainer? +1. Push changes to your own git fork and branch. +1. Use below commands to build mastercontainer image for a custom git url and branch: +``` +cd Containers/mastercontainer +docker buildx build -t ghcr.io/nextcloud-releases/all-in-one:latest --build-arg AIO_GIT_URL="https://github.com/my-fork-repo/all-in-one.git" --build-arg AIO_GIT_BRANCH="my-feature-branch" --load . +``` +1. Start a container with above built image. +1. Since the hash of a locally built image doesn't match the latest release mastercontainer, it prompts for a mandatory update. To temporarily bypass the update suffix `?bypass_mastercontainer_update` to the URL. Eg: `https://localhost:8080/containers?bypass_mastercontainer_update` diff --git a/php/public/index.php b/php/public/index.php index 60440805..712f1463 100644 --- a/php/public/index.php +++ b/php/public/index.php @@ -82,6 +82,11 @@ $app->get('/containers', function (Request $request, Response $response, array $ $dockerController = $container->get(\AIO\Controller\DockerController::class); $dockerActionManger->ConnectMasterContainerToNetwork(); $dockerController->StartDomaincheckContainer(); + + // Check if bypass_mastercontainer_update is provided on the URL, a special developer mode to bypass a mastercontainer update and use local image. + $params = $request->getQueryParams(); + $bypass_mastercontainer_update = isset($params['bypass_mastercontainer_update']); + return $view->render($response, 'containers.twig', [ 'domain' => $configurationManager->GetDomain(), 'apache_port' => $configurationManager->GetApachePort(), @@ -91,7 +96,7 @@ $app->get('/containers', function (Request $request, Response $response, array $ 'nextcloud_password' => $configurationManager->GetAndGenerateSecret('NEXTCLOUD_PASSWORD'), 'containers' => (new \AIO\ContainerDefinitionFetcher($container->get(\AIO\Data\ConfigurationManager::class), $container))->FetchDefinition(), 'borgbackup_password' => $configurationManager->GetAndGenerateSecret('BORGBACKUP_PASSWORD'), - 'is_mastercontainer_update_available' => $dockerActionManger->IsMastercontainerUpdateAvailable(), + 'is_mastercontainer_update_available' => ( $bypass_mastercontainer_update ? false : $dockerActionManger->IsMastercontainerUpdateAvailable() ), 'has_backup_run_once' => $configurationManager->hasBackupRunOnce(), 'is_backup_container_running' => $dockerActionManger->isBackupContainerRunning(), 'backup_exit_code' => $dockerActionManger->GetBackupcontainerExitCode(),