matomo-org / docker

Official Docker project for Matomo Analytics
https://matomo.org
Other
832 stars 345 forks source link

Auto-archiving for reports (using cron jobs) is enabled in docker image? #298

Open carromeu opened 1 year ago

carromeu commented 1 year ago

The automatic proccess to archive reports, using command line call to console and Cron, is enable inside image or I need to set another service in stack of containers to activate it?

maathimself commented 1 year ago

I don't believe cron is set to run in the containers. I have add the following command to the host to get cron archiving every hour. Edit the crontab file ( /etc/crontab ) Then paste the following at the bottom

* 1 * * docker exec -u www-data matomo_app_1 php console core:archive

Its not the best way to do it but it works for me.

cseufert commented 1 year ago

You can use docker-compose something like this:

# docker-compose.yaml
version: '3'
services:
  matomo:
    image: matomo
    restart: always
    environment:
     - 'MATOMO_DATABASE_HOST=db
     - ...
    volumes:
      - /home/matomo/data:/var/www/html
      - /home/matomo/php-fpm:/run/php-fpm
    ports:
      - '127.0.0.1:29000:9000'
  cron:
    image: matomo
    restart: always
    environment:
     - 'MATOMO_DATABASE_HOST=db
     - ...
    volumes:
      - /home/matomo/data:/var/www/html
    depends_on: [matomo]
    entrypoint:  "sh -c 'while true; do php console core:archive --url=https://matomo.udo.net.au/; sleep 600; done'"