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) &