From 26ec46a6a7e328672c83602ff413d1e7f7dca349 Mon Sep 17 00:00:00 2001 From: Zoey Date: Sat, 8 Aug 2026 20:56:46 +0200 Subject: [PATCH] precompress static files Signed-off-by: Zoey --- Containers/apache/nextcloud.conf | 22 ++++++++++++++++++++ Containers/nextcloud/Dockerfile | 3 +++ Containers/nextcloud/entrypoint.sh | 1 + Containers/nextcloud/upgrade-latest-major.sh | 1 + 4 files changed, 27 insertions(+) diff --git a/Containers/apache/nextcloud.conf b/Containers/apache/nextcloud.conf index b09e86b1..9703914e 100644 --- a/Containers/apache/nextcloud.conf +++ b/Containers/apache/nextcloud.conf @@ -17,6 +17,28 @@ Listen 8000 + + RewriteEngine On + RewriteCond %{HTTP:Accept-Encoding} br + RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI}.br -s + RewriteRule ^ %{REQUEST_URI}.br [END] + + + + AddEncoding br .br + + + + + + Header set Cache-Control "max-age=15778463, immutable" + + + Header set Cache-Control "max-age=15778463" + + + + # Nextcloud dir DocumentRoot /var/www/html/ diff --git a/Containers/nextcloud/Dockerfile b/Containers/nextcloud/Dockerfile index 576bae86..5ebcdfc2 100644 --- a/Containers/nextcloud/Dockerfile +++ b/Containers/nextcloud/Dockerfile @@ -228,6 +228,7 @@ RUN set -ex; \ \ apk add --no-cache \ bash \ + brotli \ netcat-openbsd \ openssl \ gnupg \ @@ -269,6 +270,8 @@ RUN set -ex; \ \ echo "[ -n \"\$TERM\" ] && [ -f /root.motd ] && cat /root.motd" >> /root/.bashrc; \ \ + find /usr/src/nextcloud/apps /usr/src/nextcloud/core /usr/src/nextcloud/dist \( -name "*.js" -o -name "*.mjs" -o -name "*.css" -o -name "*.html" -o -name "*.svg" -o -name "*.ico" \) -type f -print0 | xargs -r0 -P "$(nproc)" -n 1 brotli -q 11; \ + \ chown www-data:root -R /usr/src && \ chmod 777 -R /usr/local/etc/php/conf.d && \ chmod 777 -R /usr/local/etc/php-fpm.d && \ diff --git a/Containers/nextcloud/entrypoint.sh b/Containers/nextcloud/entrypoint.sh index c3fddad5..67c75c50 100644 --- a/Containers/nextcloud/entrypoint.sh +++ b/Containers/nextcloud/entrypoint.sh @@ -223,6 +223,7 @@ if ! [ -f "$NEXTCLOUD_DATA_DIR/skip.update" ]; then mv /usr/src/tmp/nextcloud "$SOURCE_LOCATION" rm -r /usr/src/tmp rm -r /usr/src/temp-nextcloud + find "$SOURCE_LOCATION/apps" "$SOURCE_LOCATION/core" "$SOURCE_LOCATION/dist" \( -name "*.js" -o -name "*.mjs" -o -name "*.css" -o -name "*.html" -o -name "*.svg" -o -name "*.ico" \) -type f -print0 | xargs -r0 -P "$(nproc)" -n 1 brotli -q 11; # shellcheck disable=SC2016 image_version="$(php -r "require '$SOURCE_LOCATION/version.php'; echo implode('.', \$OC_Version);")" IMAGE_MAJOR="${image_version%%.*}" diff --git a/Containers/nextcloud/upgrade-latest-major.sh b/Containers/nextcloud/upgrade-latest-major.sh index f066ac4a..026d571b 100644 --- a/Containers/nextcloud/upgrade-latest-major.sh +++ b/Containers/nextcloud/upgrade-latest-major.sh @@ -36,6 +36,7 @@ if ! $PHP_CLI -r "version_compare(getenv('INSTALLED_MAJOR'), getenv('IMAGE_MAJOR exit 1 fi fi +find /var/www/html/apps /var/www/html/core /var/www/html/dist \( -name "*.js" -o -name "*.mjs" -o -name "*.css" -o -name "*.html" -o -name "*.svg" -o -name "*.ico" \) -type f -print0 | xargs -r0 -P "$(nproc)" -n 1 brotli -q 11; $PHP_CLI /var/www/html/occ config:system:set updatechecker --type=bool --value=true $PHP_CLI /var/www/html/occ app:enable nextcloud-aio --force $PHP_CLI /var/www/html/occ db:add-missing-columns