From 546f11a654da738da25d39032e841a6d051caaf9 Mon Sep 17 00:00:00 2001 From: "Simon L." Date: Mon, 16 Sep 2024 17:59:15 +0200 Subject: [PATCH 1/4] add whiteboard container Signed-off-by: Simon L. --- .github/dependabot.yml | 9 ++++ Containers/apache/Caddyfile | 6 +++ Containers/nextcloud/entrypoint.sh | 17 +++++++ Containers/whiteboard/Dockerfile | 8 ++++ Containers/whiteboard/start.sh | 19 ++++++++ php/containers.json | 46 +++++++++++++++++-- php/public/disable-whiteboard.js | 5 ++ php/public/index.php | 1 + php/public/options-form-submit.js | 4 ++ php/src/ContainerDefinitionFetcher.php | 8 ++++ .../Controller/ConfigurationController.php | 5 ++ php/src/Data/ConfigurationManager.php | 15 ++++++ php/src/Docker/DockerActionManager.php | 6 +++ php/templates/containers.twig | 6 +++ 14 files changed, 151 insertions(+), 4 deletions(-) create mode 100644 Containers/whiteboard/Dockerfile create mode 100644 Containers/whiteboard/start.sh create mode 100644 php/public/disable-whiteboard.js diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 16e7a8a1f89..1fb20f9802f 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -183,3 +183,12 @@ updates: labels: - 3. to review - dependencies +- package-ecosystem: "docker" + directory: "/Containers/whiteboard" + schedule: + interval: "daily" + time: "12:00" + open-pull-requests-limit: 10 + labels: + - 3. to review + - dependencies diff --git a/Containers/apache/Caddyfile b/Containers/apache/Caddyfile index 8e7e4a2192c..d635f329f0f 100644 --- a/Containers/apache/Caddyfile +++ b/Containers/apache/Caddyfile @@ -51,6 +51,12 @@ https://{$ADDITIONAL_TRUSTED_DOMAIN}:443, reverse_proxy {$TALK_HOST}:8081 } + # Whiteboard + route /whiteboard/* { + uri strip_prefix /whiteboard + reverse_proxy {$WHITEBOARD_HOST}:3002 + } + # Nextcloud route { header Strict-Transport-Security max-age=31536000; diff --git a/Containers/nextcloud/entrypoint.sh b/Containers/nextcloud/entrypoint.sh index 0d58d02b571..c092d4bf6d0 100644 --- a/Containers/nextcloud/entrypoint.sh +++ b/Containers/nextcloud/entrypoint.sh @@ -851,5 +851,22 @@ else fi fi +# Whiteboard app +if [ "$WHITEBOARD_ENABLED" = 'yes' ]; then + if ! [ -d "/var/www/html/custom_apps/whiteboard" ]; then + php /var/www/html/occ app:install whiteboard + elif [ "$(php /var/www/html/occ config:app:get whiteboard enabled)" != "yes" ]; then + php /var/www/html/occ app:enable whiteboard + php /var/www/html/occ config:app:set whiteboard collabBackendUrl --value="https://$NC_DOMAIN/whiteboard" + php /var/www/html/occ config:app:set whiteboard jwt_secret_key --value="$WHITEBOARD_SECRET" + elif [ "$SKIP_UPDATE" != 1 ]; then + php /var/www/html/occ app:update whiteboard + fi +else + if [ "$REMOVE_DISABLED_APPS" = yes ] && [ -d "/var/www/html/custom_apps/whiteboard" ]; then + php /var/www/html/occ app:remove whiteboard + fi +fi + # Remove the update skip file always rm -f "$NEXTCLOUD_DATA_DIR"/skip.update diff --git a/Containers/whiteboard/Dockerfile b/Containers/whiteboard/Dockerfile new file mode 100644 index 00000000000..d854f53e1c3 --- /dev/null +++ b/Containers/whiteboard/Dockerfile @@ -0,0 +1,8 @@ +# syntax=docker/dockerfile:latest +FROM ghcr.io/nextcloud-releases/whiteboard:v1.0.1 + +COPY --chmod=775 start.sh /start.sh + +ENTRYPOINT ["/start.sh"] + +LABEL com.centurylinklabs.watchtower.enable="false" diff --git a/Containers/whiteboard/start.sh b/Containers/whiteboard/start.sh new file mode 100644 index 00000000000..73a6dd18a7e --- /dev/null +++ b/Containers/whiteboard/start.sh @@ -0,0 +1,19 @@ +#!/bin/bash + +# Only start container if nextcloud is accessible +while ! nc -z "$REDIS_HOST" 6379; do + echo "Waiting for redis to start..." + sleep 5 +done + +# Set a default for redis db index +if [ -z "$REDIS_DB_INDEX" ]; then + REDIS_DB_INDEX=0 +fi + +export REDIS_URL="redis://:$REDIS_HOST_PASSWORD@$REDIS_HOST/$REDIS_DB_INDEX" + +# Run it +npm run server:start + +exec "$@" diff --git a/php/containers.json b/php/containers.json index 4d447d83efa..89d2367973a 100644 --- a/php/containers.json +++ b/php/containers.json @@ -8,7 +8,8 @@ "nextcloud-aio-collabora", "nextcloud-aio-talk", "nextcloud-aio-nextcloud", - "nextcloud-aio-notify-push" + "nextcloud-aio-notify-push", + "nextcloud-aio-whiteboard" ], "display_name": "Apache", "image": "nextcloud/aio-apache", @@ -37,7 +38,8 @@ "TZ=%TIMEZONE%", "APACHE_MAX_SIZE=%APACHE_MAX_SIZE%", "APACHE_MAX_TIME=%NEXTCLOUD_MAX_TIME%", - "NOTIFY_PUSH_HOST=nextcloud-aio-notify-push" + "NOTIFY_PUSH_HOST=nextcloud-aio-notify-push", + "WHITEBOARD_HOST=nextcloud-aio-whiteboard" ], "volumes": [ { @@ -148,7 +150,8 @@ "TURN_SECRET", "SIGNALING_SECRET", "FULLTEXTSEARCH_PASSWORD", - "IMAGINARY_SECRET" + "IMAGINARY_SECRET", + "WHITEBOARD_SECRET" ], "volumes": [ { @@ -224,7 +227,9 @@ "APACHE_PORT=%APACHE_PORT%", "ADDITIONAL_TRUSTED_PROXY=%CADDY_IP_ADDRESS%", "THIS_IS_AIO=true", - "IMAGINARY_SECRET=%IMAGINARY_SECRET%" + "IMAGINARY_SECRET=%IMAGINARY_SECRET%", + "WHITEBOARD_SECRET=%WHITEBOARD_SECRET%", + "WHITEBOARD_ENABLED=%WHITEBOARD_ENABLED%" ], "stop_grace_period": 600, "restart": "unless-stopped", @@ -746,6 +751,39 @@ "cap_drop": [ "NET_RAW" ] + }, + { + "container_name": "nextcloud-aio-whiteboard", + "image_tag": "%AIO_CHANNEL%", + "display_name": "Whiteboard", + "image": "nextcloud/aio-whiteboard", + "init": true, + "expose": [ + "3002" + ], + "internal_port": "3002", + "environment": [ + "TZ=%TIMEZONE%", + "NEXTCLOUD_URL=https://%NC_DOMAIN%", + "JWT_SECRET_KEY=%WHITEBOARD_SECRET%", + "STORAGE_STRATEGY=redis", + "REDIS_HOST=nextcloud-aio-redis", + "REDIS_HOST_PASSWORD=%REDIS_PASSWORD%" + ], + "secrets": [ + "WHITEBOARD_SECRET", + "REDIS_PASSWORD" + ], + "restart": "unless-stopped", + "profiles": [ + "whiteboard" + ], + "networks": [ + "nextcloud-aio" + ], + "cap_drop": [ + "NET_RAW" + ] } ] } diff --git a/php/public/disable-whiteboard.js b/php/public/disable-whiteboard.js new file mode 100644 index 00000000000..50e1215d950 --- /dev/null +++ b/php/public/disable-whiteboard.js @@ -0,0 +1,5 @@ +document.addEventListener("DOMContentLoaded", function(event) { + // Whiteboard + let whiteboard = document.getElementById("whiteboard"); + whiteboard.disabled = true; +}); diff --git a/php/public/index.php b/php/public/index.php index 1c997f3b4dc..9614419eb0d 100644 --- a/php/public/index.php +++ b/php/public/index.php @@ -125,6 +125,7 @@ 'is_dri_device_enabled' => $configurationManager->isDriDeviceEnabled(), 'is_talk_recording_enabled' => $configurationManager->isTalkRecordingEnabled(), 'is_docker_socket_proxy_enabled' => $configurationManager->isDockerSocketProxyEnabled(), + 'is_whiteboard_enabled' => $configurationManager->isWhiteboardEnabled(), ]); })->setName('profile'); $app->get('/login', function (Request $request, Response $response, array $args) use ($container) { diff --git a/php/public/options-form-submit.js b/php/public/options-form-submit.js index 1b70df98053..52f3ca748e8 100644 --- a/php/public/options-form-submit.js +++ b/php/public/options-form-submit.js @@ -66,4 +66,8 @@ document.addEventListener("DOMContentLoaded", function(event) { dockerSocketProxy.addEventListener('change', makeOptionsFormSubmitVisible); // dockerSocketProxy.addEventListener('change', handleDockerSocketProxyWarning); } + + // Whiteboard + let whiteboard = document.getElementById("whiteboard"); + whiteboard.addEventListener('change', makeOptionsFormSubmitVisible); }); diff --git a/php/src/ContainerDefinitionFetcher.php b/php/src/ContainerDefinitionFetcher.php index 57ccd205eb5..1cd4b17cd0e 100644 --- a/php/src/ContainerDefinitionFetcher.php +++ b/php/src/ContainerDefinitionFetcher.php @@ -95,6 +95,10 @@ private function GetDefinition(): array if (!$this->configurationManager->isDockerSocketProxyEnabled()) { continue; } + } elseif ($entry['container_name'] === 'nextcloud-aio-whiteboard') { + if (!$this->configurationManager->isWhiteboardEnabled()) { + continue; + } } $ports = new ContainerPorts(); @@ -200,6 +204,10 @@ private function GetDefinition(): array if (!$this->configurationManager->isDockerSocketProxyEnabled()) { continue; } + } elseif ($value === 'nextcloud-aio-whiteboard') { + if (!$this->configurationManager->isWhiteboardEnabled()) { + continue; + } } $dependsOn[] = $value; } diff --git a/php/src/Controller/ConfigurationController.php b/php/src/Controller/ConfigurationController.php index e786697ae88..835d7b6294f 100644 --- a/php/src/Controller/ConfigurationController.php +++ b/php/src/Controller/ConfigurationController.php @@ -120,6 +120,11 @@ public function SetConfig(Request $request, Response $response, array $args) : R } else { $this->configurationManager->SetDockerSocketProxyEnabledState(0); } + if (isset($request->getParsedBody()['whiteboard'])) { + $this->configurationManager->SetWhiteboardEnabledState(1); + } else { + $this->configurationManager->SetWhiteboardEnabledState(0); + } } if (isset($request->getParsedBody()['delete_collabora_dictionaries'])) { diff --git a/php/src/Data/ConfigurationManager.php b/php/src/Data/ConfigurationManager.php index b20938399ea..527904fbfed 100644 --- a/php/src/Data/ConfigurationManager.php +++ b/php/src/Data/ConfigurationManager.php @@ -164,6 +164,21 @@ public function SetDockerSocketProxyEnabledState(int $value) : void { $this->WriteConfig($config); } + public function isWhiteboardEnabled() : bool { + $config = $this->GetConfig(); + if (isset($config['isWhiteboardEnabled']) && $config['isWhiteboardEnabled'] === 1) { + return true; + } else { + return false; + } + } + + public function SetWhiteboardEnabledState(int $value) : void { + $config = $this->GetConfig(); + $config['isWhiteboardEnabled'] = $value; + $this->WriteConfig($config); + } + public function SetClamavEnabledState(int $value) : void { $config = $this->GetConfig(); $config['isClamavEnabled'] = $value; diff --git a/php/src/Docker/DockerActionManager.php b/php/src/Docker/DockerActionManager.php index 8b2e8a3e848..6bb7f70ee75 100644 --- a/php/src/Docker/DockerActionManager.php +++ b/php/src/Docker/DockerActionManager.php @@ -417,6 +417,12 @@ public function CreateContainer(Container $container) : void { if (in_array('caddy', $communityContainers, true)) { $replacements[1] = gethostbyname('nextcloud-aio-caddy'); } + } elseif ($out[1] === 'WHITEBOARD_ENABLED') { + if ($this->configurationManager->isWhiteboardEnabled()) { + $replacements[1] = 'yes'; + } else { + $replacements[1] = ''; + } } else { $secret = $this->configurationManager->GetSecret($out[1]); if ($secret === "") { diff --git a/php/templates/containers.twig b/php/templates/containers.twig index 1160551b803..3a2eceb0a41 100644 --- a/php/templates/containers.twig +++ b/php/templates/containers.twig @@ -597,6 +597,11 @@ {% else %}

{% endif %} + {% if is_whiteboard_enabled == true %} +

+ {% else %} +

+ {% endif %} @@ -612,6 +617,7 @@ + {% endif %} {% if is_collabora_enabled == true and isAnyRunning == false and was_start_button_clicked == true %} From 2ed94446d7c12f12111b897afc9ac2958ae503c1 Mon Sep 17 00:00:00 2001 From: "Simon L." Date: Mon, 16 Sep 2024 18:05:46 +0200 Subject: [PATCH 2/4] add whiteboard also to manual-install readme Signed-off-by: Simon L. --- manual-install/readme.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/manual-install/readme.md b/manual-install/readme.md index 26e802e9e29..26aaabf1435 100644 --- a/manual-install/readme.md +++ b/manual-install/readme.md @@ -30,9 +30,9 @@ Now copy the provided yaml file to a compose.yaml file by running `cp latest.yml Now you should be ready to go with `sudo docker compose up`. ## Docker profiles -The default profile of `latest.yml` only provide the minimum necessary services: nextcloud, database, redis and apache. To get optional services collabora, talk, talk-recording, clamav, imaginary or fulltextsearch use additional arguments for each of them, for example `--profile collabora`. (Note: there is no clamav image for arm64). +The default profile of `latest.yml` only provide the minimum necessary services: nextcloud, database, redis and apache. To get optional services collabora, talk, whiteboard, talk-recording, clamav, imaginary or fulltextsearch use additional arguments for each of them, for example `--profile collabora`. (Note: there is no clamav image for arm64). -For a complete all-in-one with collabora use `sudo docker compose --profile collabora --profile talk --profile talk-recording --profile clamav --profile imaginary --profile fulltextsearch up`. (Note: there is no clamav image for arm64). +For a complete all-in-one with collabora use `sudo docker compose --profile collabora --profile talk --profile talk-recording --profile clamav --profile imaginary --profile fulltextsearch --profile whiteboard up`. (Note: there is no clamav image for arm64). ## How to update? Since the AIO containers may change in the future, it is highly recommended to strictly follow the following procedure whenever you want to upgrade your containers. From 3218e429ec457107543bba9dfe5b30786c56282e Mon Sep 17 00:00:00 2001 From: "Simon L." Date: Mon, 16 Sep 2024 18:08:35 +0200 Subject: [PATCH 3/4] add whiteboard to readme Signed-off-by: Simon L. --- readme.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/readme.md b/readme.md index 88e4bfba4a9..e02f03ea4aa 100644 --- a/readme.md +++ b/readme.md @@ -11,6 +11,8 @@ Included are: - Imaginary (optional, for previews of heic, heif, illustrator, pdf, svg, tiff and webp) - ClamAV (optional, Antivirus backend for Nextcloud) - Fulltextsearch (optional) +- Whiteboard (optional) +- Docker Socket Proxy (optional, needed for [Nextcloud App API](https://github.com/cloud-py-api/app_api#nextcloud-appapi))
And much more: - Simple web interface included that enables easy installation and maintenance From 8d062f7461aac8a35be672ba6d330784299863d8 Mon Sep 17 00:00:00 2001 From: "Simon L." Date: Tue, 17 Sep 2024 10:10:54 +0200 Subject: [PATCH 4/4] use exec for npm run Signed-off-by: Simon L. --- Containers/whiteboard/start.sh | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Containers/whiteboard/start.sh b/Containers/whiteboard/start.sh index 73a6dd18a7e..8816ee7f80c 100644 --- a/Containers/whiteboard/start.sh +++ b/Containers/whiteboard/start.sh @@ -14,6 +14,4 @@ fi export REDIS_URL="redis://:$REDIS_HOST_PASSWORD@$REDIS_HOST/$REDIS_DB_INDEX" # Run it -npm run server:start - -exec "$@" +exec npm run server:start