Skip to content

mastercontainer: enable local testability #5568

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 13 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 19 additions & 10 deletions Containers/mastercontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
# syntax=docker/dockerfile:latest

# Create a minimal stage to just clone the repo
FROM alpine/git:2.47.2 AS aio_clone
WORKDIR /
RUN git clone https://github.com/nextcloud-releases/all-in-one.git --depth 1

# Create an empty image with just the source. This is useful stage that can be overridden to local path for testing with command: docker buildx build --build-context aio_root=../../ -t nextcloud/all-in-one:latest .
FROM scratch AS aio_root
COPY --from=aio_clone all-in-one /

# Docker CLI is a requirement
FROM docker:28.2.1-cli AS docker

Expand All @@ -15,6 +25,10 @@ EXPOSE 8443
COPY --from=caddy /usr/bin/caddy /usr/bin/caddy
COPY --from=docker /usr/local/bin/docker /usr/local/bin/docker

COPY --from=aio_root /php /var/www/docker-aio/php
RUN rm -r /var/www/docker-aio/php/tests
COPY --from=aio_root /community-containers /var/www/docker-aio/community-containers

WORKDIR /var/www/docker-aio

# hadolint ignore=SC2086,DL3047,DL3003,DL3004
Expand Down Expand Up @@ -60,15 +74,10 @@ RUN set -ex; \
grep -q ';listen.allowed_clients' /usr/local/etc/php-fpm.d/www.conf; \
sed -i 's|;listen.allowed_clients.*|listen.allowed_clients = 127.0.0.1,::1|' /usr/local/etc/php-fpm.d/www.conf; \
\
apk add --no-cache git; \
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 .; \
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; \
cd php; \
cd /var/www/docker-aio/php; \
sudo -u www-data composer install --no-dev; \
sudo -u www-data composer clear-cache; \
cd ..; \
Expand Down Expand Up @@ -117,10 +126,10 @@ RUN set -ex; \
mkdir /var/log/supervisord; \
mkdir /var/run/supervisord;

COPY --chmod=775 *.sh /
COPY --chmod=664 Caddyfile /Caddyfile
COPY --chmod=664 supervisord.conf /supervisord.conf
COPY mastercontainer.conf /etc/apache2/sites-available/mastercontainer.conf
COPY --from=aio_root --chmod=775 /Containers/mastercontainer/*.sh /
COPY --from=aio_root --chmod=664 /Containers/mastercontainer/Caddyfile /Caddyfile
COPY --from=aio_root --chmod=664 /Containers/mastercontainer/supervisord.conf /supervisord.conf
COPY --from=aio_root /Containers/mastercontainer/mastercontainer.conf /etc/apache2/sites-available/mastercontainer.conf

LABEL org.label-schema.vendor="Nextcloud"

Expand Down
9 changes: 9 additions & 0 deletions develop.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,12 @@ 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. To build mastercontainer image with local changes:
```
cd Containers/mastercontainer
docker buildx build --build-context aio_root=../../ -t ghcr.io/nextcloud-releases/all-in-one:latest --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 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`
7 changes: 6 additions & 1 deletion php/public/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,11 @@
$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(),
Expand All @@ -91,7 +96,7 @@
'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(),
Expand Down