From 2a746863b9b32f97b2dc09eab0ca23a9f2a06840 Mon Sep 17 00:00:00 2001 From: Simon L Date: Wed, 27 Sep 2023 17:40:42 +0200 Subject: [PATCH] allow to specify AIO_COMMUNITY_CONTAINERS Signed-off-by: Simon L --- Containers/mastercontainer/Dockerfile | 2 +- Containers/mastercontainer/start.sh | 14 ++++++++++++++ community-containers/readme.md | 2 ++ php/src/Data/ConfigurationManager.php | 11 +++++++++++ php/src/Data/DataConst.php | 4 ++++ tests/QA/060-environmental-variables.md | 1 + 6 files changed, 33 insertions(+), 1 deletion(-) diff --git a/Containers/mastercontainer/Dockerfile b/Containers/mastercontainer/Dockerfile index 52172ae2..4e35534b 100644 --- a/Containers/mastercontainer/Dockerfile +++ b/Containers/mastercontainer/Dockerfile @@ -65,7 +65,7 @@ RUN set -ex; \ 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 -exec rm -r {} \; ; \ + find ./ -maxdepth 1 -mindepth 1 -not -path ./php -not -path ./community-containers -exec rm -r {} \; ; \ chown www-data:www-data -R /var/www/docker-aio; \ cd php; \ sudo -u www-data composer install --no-dev; \ diff --git a/Containers/mastercontainer/start.sh b/Containers/mastercontainer/start.sh index 470d5ea4..1c26b099 100644 --- a/Containers/mastercontainer/start.sh +++ b/Containers/mastercontainer/start.sh @@ -241,6 +241,20 @@ It is set to '$NEXTCLOUD_ADDITIONAL_PHP_EXTENSIONS'." exit 1 fi fi +if [ -n "$AIO_COMMUNITY_CONTAINERS" ]; then + read -ra AIO_CCONTAINERS <<< "$AIO_COMMUNITY_CONTAINERS" + for container in "${AIO_CCONTAINERS[@]}"; do + if ! [ -d "/var/www/docker-aio/community-containers/$container" ]; then + echo "The community container $container was not found!" + FAIL_CCONTAINERS=1 + fi + done + if [ -n "$FAIL_CCONTAINERS" ]; then + print_red "You've set AIO_COMMUNITY_CONTAINERS but at least one container was not found. +It is set to '$AIO_COMMUNITY_CONTAINERS'." + exit 1 + fi +fi # Check DNS resolution # Prevents issues like https://github.com/nextcloud/all-in-one/discussions/565 diff --git a/community-containers/readme.md b/community-containers/readme.md index 19877266..a5ecce85 100644 --- a/community-containers/readme.md +++ b/community-containers/readme.md @@ -1 +1,3 @@ ## This is a WIP and not working yet! + +You might want to add additional community containers to the default AIO stack. You can do so by adding `--env AIO_COMMUNITY_CONTAINERS="container1 container2"` to the docker run command of the mastercontainer (but before the last line `nextcloud/all-in-one:latest`! If it was started already, you will need to stop the mastercontainer, remove it (no data will be lost) and recreate it using the docker run command that you initially used) and customize the value to your fitting. It must match the folder names in this directory! ⚠️⚠️⚠️ Please review the folder for documentation on each of the containers before adding them! Not reviewing the documentation for each of them first might break starting the AIO containers because e.g. fail2ban only works on Linux and not on Docker Desktop! diff --git a/php/src/Data/ConfigurationManager.php b/php/src/Data/ConfigurationManager.php index 0116a780..5bb295b5 100644 --- a/php/src/Data/ConfigurationManager.php +++ b/php/src/Data/ConfigurationManager.php @@ -874,6 +874,17 @@ class ConfigurationManager } } + private function GetCommunityContainers() : string { + $envVariableName = 'AIO_COMMUNITY_CONTAINERS'; + $configName = 'aio_community_containers'; + $defaultValue = ''; + return $this->GetEnvironmentalVariableOrConfig($envVariableName, $configName, $defaultValue); + } + + public function GetEnabledCommunityContainers() : array { + return explode(' ', $this->GetCommunityContainers()); + } + private function GetEnabledDriDevice() : string { $envVariableName = 'NEXTCLOUD_ENABLE_DRI_DEVICE'; $configName = 'nextcloud_enable_dri_device'; diff --git a/php/src/Data/DataConst.php b/php/src/Data/DataConst.php index 7ac3527e..2512b7fb 100644 --- a/php/src/Data/DataConst.php +++ b/php/src/Data/DataConst.php @@ -50,4 +50,8 @@ class DataConst { public static function GetSessionDateFile() : string { return self::GetDataDirectory() . '/session_date_file'; } + + public static function GetCommunityContainersDirectory() : string { + return realpath(__DIR__ . '/../../../community-containers/'); + } } diff --git a/tests/QA/060-environmental-variables.md b/tests/QA/060-environmental-variables.md index f61efefe..488ae8e0 100644 --- a/tests/QA/060-environmental-variables.md +++ b/tests/QA/060-environmental-variables.md @@ -21,5 +21,6 @@ See https://github.com/nextcloud/all-in-one#how-to-trust-user-defined-certificat - [ ] When starting the mastercontainer with `--env NEXTCLOUD_ADDITIONAL_PHP_EXTENSIONS=inotify`, the resulting Nextcloud container should have the inotify extension installed and not the imagick extension. - [ ] When starting the mastercontainer with `--env NEXTCLOUD_ENABLE_DRI_DEVICE=true`, the resulting Nextcloud container should have the /dev/dri device mounted into the container. (Only works if a `/dev/dri` device is present on the host) - [ ] When starting the mastercontainer with `--env NEXTCLOUD_KEEP_DISABLED_APPS=true` it should keep apps in Nextcloud that are disabled in the AIO interface. For example if Collabora is disabled in the AIO interface and you install the richdocuments app in Nextcloud, a restart should not uninstall the richdocuments app in Nextcloud anymore. +- [ ] When starting the mastercontainer with `--env AIO_COMMUNITY_CONTAINERS="fail2ban"`, it should add the fail2ban container to the container stack and show it in the AIO interface as well as start it, etc. You can now continue with [070-timezone-change.md](./070-timezone-change.md)