diff --git a/Containers/apache/Caddyfile b/Containers/apache/Caddyfile index 6006fee4..fb6b80cb 100644 --- a/Containers/apache/Caddyfile +++ b/Containers/apache/Caddyfile @@ -30,7 +30,7 @@ # Notify Push route /push/* { uri strip_prefix /push - reverse_proxy {$NEXTCLOUD_HOST}:7867 + reverse_proxy {$NOTIFY_PUSH_HOST}:7867 } # Onlyoffice diff --git a/Containers/nextcloud/start.sh b/Containers/nextcloud/start.sh index 569652d2..b990d6c5 100644 --- a/Containers/nextcloud/start.sh +++ b/Containers/nextcloud/start.sh @@ -131,14 +131,4 @@ if ! sudo -E -u www-data bash /entrypoint.sh; then exit 1 fi -# Correctly set CPU_ARCH for notify_push -CPU_ARCH="$(uname -m)" -export CPU_ARCH -if [ -z "$CPU_ARCH" ]; then - echo "Could not get processor architecture. Exiting." - exit 1 -elif [ "$CPU_ARCH" != "x86_64" ]; then - export CPU_ARCH="aarch64" -fi - exec "$@" \ No newline at end of file diff --git a/Containers/nextcloud/supervisord.conf b/Containers/nextcloud/supervisord.conf index 23e85ca6..45a6b074 100644 --- a/Containers/nextcloud/supervisord.conf +++ b/Containers/nextcloud/supervisord.conf @@ -25,14 +25,6 @@ stderr_logfile_maxbytes=0 command=/cron.sh user=www-data -[program:notify-push] -stdout_logfile=/dev/stdout -stdout_logfile_maxbytes=0 -stderr_logfile=/dev/stderr -stderr_logfile_maxbytes=0 -command=/var/www/html/custom_apps/notify_push/bin/%(ENV_CPU_ARCH)s/notify_push /var/www/html/config/config.php --port 7867 --redis-url redis://:%(ENV_REDIS_HOST_PASSWORD)s@%(ENV_REDIS_HOST)s -user=www-data - [program:run-exec-commands] stdout_logfile=/dev/stdout stdout_logfile_maxbytes=0 diff --git a/Containers/notify-push/Dockerfile b/Containers/notify-push/Dockerfile new file mode 100644 index 00000000..2a1b7e30 --- /dev/null +++ b/Containers/notify-push/Dockerfile @@ -0,0 +1,20 @@ +FROM alpine:3.18.2 + +COPY --chmod=775 start.sh /start.sh + +RUN set -ex; \ + apk add --no-cache \ + ca-certificates \ + tzdata \ + bash \ + openssl; \ +# Give root a random password + echo "root:$(openssl rand -base64 12)" | chpasswd; \ + apk del --no-cache \ + openssl; + +USER 33 +ENTRYPOINT ["/start.sh"] + +HEALTHCHECK CMD nc -z localhost 7867 || exit 1 +LABEL com.centurylinklabs.watchtower.monitor-only="true" diff --git a/Containers/notify-push/start.sh b/Containers/notify-push/start.sh new file mode 100644 index 00000000..8d10e097 --- /dev/null +++ b/Containers/notify-push/start.sh @@ -0,0 +1,38 @@ +#!/bin/bash + +if [ -z "$NEXTCLOUD_HOST" ]; then + echo "NEXTCLOUD_HOST need to be provided. Exiting!" + exit 1 +elif [ -z "$POSTGRES_HOST" ]; then + echo "POSTGRES_HOST need to be provided. Exiting!" + exit 1 +elif [ -z "$REDIS_HOST" ]; then + echo "REDIS_HOST need to be provided. Exiting!" + exit 1 +fi + +# Only start container if nextcloud is accessible +while ! nc -z "$NEXTCLOUD_HOST" 9000; do + echo "Waiting for Nextcloud to start..." + sleep 5 +done + +# Correctly set CPU_ARCH for notify_push +CPU_ARCH="$(uname -m)" +export CPU_ARCH +if [ -z "$CPU_ARCH" ]; then + echo "Could not get processor architecture. Exiting." + exit 1 +elif [ "$CPU_ARCH" != "x86_64" ]; then + export CPU_ARCH="aarch64" +fi + +# Run it +/nextcloud/custom_apps/notify_push/bin/"$CPU_ARCH"/notify_push \ + --database-prefix="oc_" \ + --nextcloud-url "https://$NC_DOMAIN" \ + --port 7867 \ + --redis-url "redis://:$REDIS_HOST_PASSWORD@$REDIS_HOST" \ + --database-url "postgres://$POSTGRES_USER:$POSTGRES_PASSWORD@$POSTGRES_HOST/$POSTGRES_DB" + +exec "$@" diff --git a/php/containers.json b/php/containers.json index b2e01af2..baa6b50a 100644 --- a/php/containers.json +++ b/php/containers.json @@ -6,6 +6,7 @@ "nextcloud-aio-onlyoffice", "nextcloud-aio-collabora", "nextcloud-aio-talk", + "nextcloud-aio-notify-push", "nextcloud-aio-nextcloud" ], "display_name": "Apache", @@ -27,7 +28,8 @@ "ONLYOFFICE_HOST=nextcloud-aio-onlyoffice", "TZ=%TIMEZONE%", "APACHE_MAX_SIZE=%APACHE_MAX_SIZE%", - "APACHE_MAX_TIME=%NEXTCLOUD_MAX_TIME%" + "APACHE_MAX_TIME=%NEXTCLOUD_MAX_TIME%", + "NOTIFY_PUSH_HOST=nextcloud-aio-notify-push" ], "volumes": [ { @@ -104,8 +106,7 @@ "display_name": "Nextcloud", "image": "nextcloud/aio-nextcloud", "expose": [ - "9000", - "7867" + "9000" ], "internal_port": "9000", "secrets": [ @@ -193,6 +194,41 @@ "nextcloud-aio" ] }, + { + "container_name": "nextcloud-aio-notify-push", + "display_name": "Notify Push", + "image": "nextcloud/aio-notify-push", + "expose": [ + "7867" + ], + "internal_port": "7876", + "secrets": [ + "REDIS_PASSWORD", + "POSTGRES_PASSWORD" + ], + "volumes": [ + { + "source": "nextcloud_aio_nextcloud", + "destination": "/nextcloud", + "writeable": false + } + ], + "environment": [ + "NC_DOMAIN=%NC_DOMAIN%", + "NEXTCLOUD_HOST=nextcloud-aio-nextcloud", + "REDIS_HOST=nextcloud-aio-redis", + "REDIS_HOST_PASSWORD=%REDIS_PASSWORD%", + "POSTGRES_HOST=nextcloud-aio-database", + "POSTGRES_PASSWORD=%DATABASE_PASSWORD%", + "POSTGRES_DB=nextcloud_database", + "POSTGRES_USER=nextcloud" + ], + "restart": "unless-stopped", + "networks": [ + "nextcloud-aio" + ], + "read_only": true + }, { "container_name": "nextcloud-aio-redis", "display_name": "Redis",