Deploy your own instance of Matomo on Dokku.
This setup is makes use of the great ready-to-use
matomo-docker
image by
crazy-max, which does all of the heavy-lifting
to properly deploy Matomo without too much headache.
We will deploy Matomo 3.13.5 onto your own Dokku server.
Currently the following features are not supported:
- Archive via cron
- Redis cache
Contributions are welcome!
You to pull the latest image from Docker Hub and re-deploy it over Dokku. Updating over the web interface is not supported. The upgrade will result in a short downtime of Matomo.
docker pull crazymax/matomo:3.14.0 # This version does not exist yet, its just an example
docker tag crazymax/matomo:3.14.0 dokku/matomo:v3.14.0
dokku tags:deploy matomo v3.14.0
We pull the matomo
image from Docker Hub and tag it properly for Dokku.
docker pull crazymax/matomo:3.13.5
docker tag crazymax/matomo:3.13.5 dokku/matomo:v3.13.5
First create a new Dokku app. We will call it matomo
.
dokku apps:create matomo
Next create the MariaDB database required by Matomo and link it to the app.
dokku mariadb:create mariadb-matomo
dokku mariadb:link mariadb-matomo matomo
dokku config:set --no-restart matomo TZ=Europe/Berlin
dokku config:set --no-restart matomo MEMORY_LIMIT=256M
dokku config:set --no-restart matomo UPLOAD_MAX_SIZE=16M
dokku config:set --no-restart matomo OPCACHE_MEM_SIZE=128
dokku config:set --no-restart matomo REAL_IP_FROM=0.0.0.0/32
dokku config:set --no-restart matomo REAL_IP_HEADER=X-Forwarded-For
dokku config:set --no-restart matomo LOG_LEVEL=WARN
You need to mount a volume on your host (the machine running Dokku) to persist all settings that you set in the Matomo interface.
mkdir /var/lib/dokku/data/storage/matomo
# UID:GUID are set to 101. These are the values the nginx image uses,
# that is used by crazymax/matomo
chown 101:101 /var/lib/dokku/data/storage/matomo
dokku storage:mount matomo /var/lib/dokku/data/storage/matomo:/data
To get the routing working, we need to apply a few settings. First we set the domain.
dokku domains:set matomo matomo.example.com
We also need to update the ports set by Dokku.
dokku proxy:ports-add matomo http:80:8000
dokku proxy:ports-remove matomo http:80:5000
If Dokku proxy:report sentry shows more than one port mapping, remove all port mappings except the added above.
You need to set the following settings if you want to receive emails from Matomo.
dokku config:set --no-restart SSMTP_HOST=smtp.example.com
dokku config:set --no-restart SSMTP_PORT=587
dokku config:set --no-restart SSMTP_HOSTNAME=matomo.example.com
dokku config:set --no-restart SSMTP_USER=user@example.com
dokku config:set --no-restart SSMTP_PASSWORD=yoursmtppassword
dokku config:set --no-restart SSMTP_TLS=YES
The GeoIP2 plugin is already installed but needs to be configured. Follow the instructions in the crazymax/docker-matomo repository to enable it.
If needed, the Matomo configuration file is located at
/var/lib/dokku/data/storage/matomo/config/config.ini.php
and can be manually
edited.
Deploy Matomo from the previously tagged docker image.
dokku tags:deploy matomo v3.13.5
Setup an SSL certificate via Let's Encrypt.
dokku config:set --no-restart matomo DOKKU_LETSENCRYPT_EMAIL=letsencrypt@example.com
dokku letsencrypt matomo
dokku letsencrypt:auto-renew matomo
We will need to set up Matomo in the web interface and provide the database
details. You should be able to access the page via
https://matomo.example.com
.
Run the command below to retrieve the DSN.
dokku mariadb:info mariadb-matomo
An example DSN might look like this:
mysql://mariadb:ffd4fc238ba8adb3@dokku-mariadb-mariadb-matomo:3306/mariadb_matomo
.
Copy and paste the details as follows:
Hostname: dokku-mariadb-mariadb-matomo
Username: mariadb
Password: ffd4fc238ba8adb3
Database Name: mariadb_matomo
After going through the setup, you should be able to use Matomo.