项目作者: rclement

项目描述 :
Deploy Matomo on Dokku
高级语言:
项目地址: git://github.com/rclement/dokku-matomo.git
创建时间: 2018-06-05T12:05:11Z
项目社区:https://github.com/rclement/dokku-matomo

开源协议:MIT License

下载


Run Matomo on Dokku

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.

What you get

We will deploy Matomo
3.13.5
onto your own
Dokku server.

Limitations

Currently the following features are not supported:

  • Archive via cron
  • Redis cache

Contributions are welcome!

Requirements

Upgrading

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.

  1. docker pull crazymax/matomo:3.14.0 # This version does not exist yet, its just an example
  2. docker tag crazymax/matomo:3.14.0 dokku/matomo:v3.14.0
  3. dokku tags:deploy matomo v3.14.0

Setup

Pull image and tag it

We pull the matomo image from Docker Hub and tag it properly for Dokku.

  1. docker pull crazymax/matomo:3.13.5
  2. docker tag crazymax/matomo:3.13.5 dokku/matomo:v3.13.5

App and database

First create a new Dokku app. We will call it matomo.

  1. dokku apps:create matomo

Next create the MariaDB database required by Matomo and link it to the app.

  1. dokku mariadb:create mariadb-matomo
  2. dokku mariadb:link mariadb-matomo matomo

Configuration

Main configuration

  1. dokku config:set --no-restart matomo TZ=Europe/Berlin
  2. dokku config:set --no-restart matomo MEMORY_LIMIT=256M
  3. dokku config:set --no-restart matomo UPLOAD_MAX_SIZE=16M
  4. dokku config:set --no-restart matomo OPCACHE_MEM_SIZE=128
  5. dokku config:set --no-restart matomo REAL_IP_FROM=0.0.0.0/32
  6. dokku config:set --no-restart matomo REAL_IP_HEADER=X-Forwarded-For
  7. dokku config:set --no-restart matomo LOG_LEVEL=WARN

Persistent storage

You need to mount a volume on your host (the machine running Dokku) to persist
all settings that you set in the Matomo interface.

  1. mkdir /var/lib/dokku/data/storage/matomo
  2. # UID:GUID are set to 101. These are the values the nginx image uses,
  3. # that is used by crazymax/matomo
  4. chown 101:101 /var/lib/dokku/data/storage/matomo
  5. dokku storage:mount matomo /var/lib/dokku/data/storage/matomo:/data

Domain setup

To get the routing working, we need to apply a few settings. First we set the
domain.

  1. dokku domains:set matomo matomo.example.com

We also need to update the ports set by Dokku.

  1. dokku proxy:ports-add matomo http:80:8000
  2. 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.

Email settings (optional)

You need to set the following settings if you want to receive emails from
Matomo.

  1. dokku config:set --no-restart SSMTP_HOST=smtp.example.com
  2. dokku config:set --no-restart SSMTP_PORT=587
  3. dokku config:set --no-restart SSMTP_HOSTNAME=matomo.example.com
  4. dokku config:set --no-restart SSMTP_USER=user@example.com
  5. dokku config:set --no-restart SSMTP_PASSWORD=yoursmtppassword
  6. dokku config:set --no-restart SSMTP_TLS=YES

GeoIP2

The GeoIP2 plugin is already installed but needs to be configured. Follow the
instructions in the crazymax/docker-matomo
repository
to enable it.

Advanced configuration

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

Deploy app for the first time

Deploy Matomo from the previously tagged docker image.

  1. dokku tags:deploy matomo v3.13.5

Setup Let’s Encrypt

Setup an SSL certificate via Let’s Encrypt.

  1. dokku config:set --no-restart matomo DOKKU_LETSENCRYPT_EMAIL=letsencrypt@example.com
  2. dokku letsencrypt matomo
  3. dokku letsencrypt:auto-renew matomo

Grep MariaDB information for the setup

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.

  1. 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:

  1. Hostname: dokku-mariadb-mariadb-matomo
  2. Username: mariadb
  3. Password: ffd4fc238ba8adb3
  4. Database Name: mariadb_matomo

After going through the setup, you should be able to use Matomo.