├── LICENSE └── README.md /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 Romain Clement 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Run Matomo on Dokku 2 | 3 | Deploy your own instance of [Matomo](https://matomo.org) on 4 | [Dokku](https://github.com/dokku/dokku). 5 | 6 | This setup is makes use of the great ready-to-use 7 | [`matomo-docker`](https://github.com/crazy-max/docker-matomo) image by 8 | [crazy-max](https://github.com/crazy-max), which does all of the heavy-lifting 9 | to properly deploy Matomo without too much headache. 10 | 11 | ## What you get 12 | 13 | We will deploy [Matomo 14 | 3.13.5](https://github.com/matomo-org/matomo/releases/tag/3.13.5) onto your own 15 | Dokku server. 16 | 17 | ## Limitations 18 | 19 | Currently the following features are not supported: 20 | 21 | - Archive via cron 22 | - Redis cache 23 | 24 | Contributions are welcome! 25 | 26 | # Requirements 27 | 28 | - [Dokku](https://github.com/dokku/dokku) 29 | - [dokku-mariadb](https://github.com/dokku/dokku-mariadb) 30 | - [dokku-letsencrypt](https://github.com/dokku/dokku-letsencrypt) 31 | 32 | # Upgrading 33 | 34 | You to pull the latest image from Docker Hub and re-deploy it over Dokku. 35 | Updating over the web interface is not supported. The upgrade will result in a 36 | short downtime of Matomo. 37 | 38 | ``` 39 | docker pull crazymax/matomo:3.14.0 # This version does not exist yet, its just an example 40 | docker tag crazymax/matomo:3.14.0 dokku/matomo:v3.14.0 41 | dokku tags:deploy matomo v3.14.0 42 | ``` 43 | 44 | # Setup 45 | 46 | ## Pull image and tag it 47 | 48 | We pull the `matomo` image from Docker Hub and tag it properly for Dokku. 49 | 50 | ``` 51 | docker pull crazymax/matomo:3.13.5 52 | docker tag crazymax/matomo:3.13.5 dokku/matomo:v3.13.5 53 | ``` 54 | 55 | ## App and database 56 | 57 | First create a new Dokku app. We will call it `matomo`. 58 | 59 | ``` 60 | dokku apps:create matomo 61 | ``` 62 | 63 | Next create the MariaDB database required by Matomo and link it to the app. 64 | 65 | ``` 66 | dokku mariadb:create mariadb-matomo 67 | dokku mariadb:link mariadb-matomo matomo 68 | ``` 69 | 70 | ## Configuration 71 | 72 | ## Main configuration 73 | 74 | ``` 75 | dokku config:set --no-restart matomo TZ=Europe/Berlin 76 | dokku config:set --no-restart matomo MEMORY_LIMIT=256M 77 | dokku config:set --no-restart matomo UPLOAD_MAX_SIZE=16M 78 | dokku config:set --no-restart matomo OPCACHE_MEM_SIZE=128 79 | dokku config:set --no-restart matomo REAL_IP_FROM=0.0.0.0/32 80 | dokku config:set --no-restart matomo REAL_IP_HEADER=X-Forwarded-For 81 | dokku config:set --no-restart matomo LOG_LEVEL=WARN 82 | ``` 83 | 84 | ## Persistent storage 85 | 86 | You need to mount a volume on your host (the machine running Dokku) to persist 87 | all settings that you set in the Matomo interface. 88 | 89 | ``` 90 | mkdir /var/lib/dokku/data/storage/matomo 91 | # UID:GUID are set to 101. These are the values the nginx image uses, 92 | # that is used by crazymax/matomo 93 | chown 101:101 /var/lib/dokku/data/storage/matomo 94 | dokku storage:mount matomo /var/lib/dokku/data/storage/matomo:/data 95 | ``` 96 | 97 | ## Domain setup 98 | 99 | To get the routing working, we need to apply a few settings. First we set the 100 | domain. 101 | 102 | ``` 103 | dokku domains:set matomo matomo.example.com 104 | ``` 105 | 106 | We also need to update the ports set by Dokku. 107 | 108 | ``` 109 | dokku proxy:ports-add matomo http:80:8000 110 | dokku proxy:ports-remove matomo http:80:5000 111 | ``` 112 | 113 | If Dokku proxy:report sentry shows more than one port mapping, remove all port 114 | mappings except the added above. 115 | 116 | ## Email settings (optional) 117 | 118 | You need to set the following settings if you want to receive emails from 119 | Matomo. 120 | 121 | ``` 122 | dokku config:set --no-restart SSMTP_HOST=smtp.example.com 123 | dokku config:set --no-restart SSMTP_PORT=587 124 | dokku config:set --no-restart SSMTP_HOSTNAME=matomo.example.com 125 | dokku config:set --no-restart SSMTP_USER=user@example.com 126 | dokku config:set --no-restart SSMTP_PASSWORD=yoursmtppassword 127 | dokku config:set --no-restart SSMTP_TLS=YES 128 | ``` 129 | 130 | ## GeoIP2 131 | 132 | The GeoIP2 plugin is already installed but needs to be configured. [Follow the 133 | instructions in the crazymax/docker-matomo 134 | repository](https://github.com/crazy-max/docker-matomo#geoip2) to enable it. 135 | 136 | ## Advanced configuration 137 | 138 | If needed, the Matomo configuration file is located at 139 | `/var/lib/dokku/data/storage/matomo/config/config.ini.php` and can be manually 140 | edited. 141 | 142 | # Deploy 143 | 144 | ## Deploy app for the first time 145 | 146 | Deploy Matomo from the previously tagged docker image. 147 | 148 | ``` 149 | dokku tags:deploy matomo v3.13.5 150 | ``` 151 | 152 | ## Setup Let's Encrypt 153 | 154 | Setup an SSL certificate via Let's Encrypt. 155 | 156 | ``` 157 | dokku config:set --no-restart matomo DOKKU_LETSENCRYPT_EMAIL=letsencrypt@example.com 158 | dokku letsencrypt matomo 159 | dokku letsencrypt:auto-renew matomo 160 | ``` 161 | 162 | # Grep MariaDB information for the setup 163 | 164 | We will need to set up Matomo in the web interface and provide the database 165 | details. You should be able to access the page via 166 | [`https://matomo.example.com`](https://matomo.example.com). 167 | 168 | Run the command below to retrieve the DSN. 169 | 170 | ``` 171 | dokku mariadb:info mariadb-matomo 172 | ``` 173 | 174 | An example DSN might look like this: 175 | `mysql://mariadb:ffd4fc238ba8adb3@dokku-mariadb-mariadb-matomo:3306/mariadb_matomo`. 176 | Copy and paste the details as follows: 177 | 178 | ``` 179 | Hostname: dokku-mariadb-mariadb-matomo 180 | Username: mariadb 181 | Password: ffd4fc238ba8adb3 182 | Database Name: mariadb_matomo 183 | ``` 184 | 185 | After going through the setup, you should be able to use Matomo. 186 | --------------------------------------------------------------------------------