From c7036c04d50fc56d42f9f2c7ebc0cf4fbe56f84f Mon Sep 17 00:00:00 2001 From: FoggyMtnDrifter Date: Sun, 22 Nov 2026 13:18:16 -0500 Subject: [PATCH] Remove Matomo code that an upgrade drops (#25) Every start copied the image's code over the volume, so files upstream deleted stayed behind, possibly as old PHP. Record the image's file list and, on the next start, delete files the previous image shipped but the new one doesn't. Config, misc/user and Marketplace plugins were never shipped by the image, so they're kept. --- apps/matomo/template.yml | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/apps/matomo/template.yml b/apps/matomo/template.yml index 10cf0c5..00fd21d 100644 --- a/apps/matomo/template.yml +++ b/apps/matomo/template.yml @@ -1,15 +1,16 @@ # Matomo: web analytics, with MariaDB for storage. # The official image copies Matomo into /var/www/html only on first start, so # later image updates would never reach the code. Here, as www-data, every start -# copies the image's code over the volume (config.ini.php and other files you -# create are kept), applies any database update, runs report archiving hourly, +# copies the image's code over the volume and deletes code files the previous image +# shipped but this one doesn't (config.ini.php and other files you create are kept), +# applies any database update, runs report archiving hourly, # and serves Apache on 8080 from copies of the stock config with only the port # changed. x-harbor: slug: matomo name: Matomo description: Web analytics that keeps your visitors' data in your hands. - version: "5.14.3-c1" + version: "5.14.3-c2" primary: { service: app, port: 8080 } # A static file: PHP pages here would belong to the installer until setup is done. health_path: /matomo.js @@ -42,7 +43,18 @@ services: - | set -e cd /var/www/html + # Remember which files the image ships. On the next start, delete the ones the + # new image no longer has, so code upstream removed can't linger after an + # upgrade. Files that never came from the image (config, misc/user, plugins + # from the Marketplace) are never in the list, so they're never touched. + (cd /usr/src/matomo && find . \( -type f -o -type l \) -print | LC_ALL=C sort) > /tmp/image-files + if [ -f .cottage-image-files ]; then + LC_ALL=C comm -23 .cottage-image-files /tmp/image-files | while IFS= read -r f; do + case "$$f" in ./config/config.ini.php|./misc/user/*) ;; *) rm -f -- "$$f" ;; esac + done + fi tar cf - --one-file-system -C /usr/src/matomo . | tar xf - --no-same-owner + cp /tmp/image-files .cottage-image-files if [ -f config/config.ini.php ]; then php console core:update --yes --no-interaction || true (while true; do sleep 3600; php console core:archive --no-interaction > /dev/null || true; done) &