Skip to content

studiowolf/plausible_on_dokku

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

33 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Plausible Dokku Maintenance

Run Plausible on Dokku

Perquisites

What is Plausible?

Plausible is a lightweight and open-source website analytics tool. No cookies and fully compliant with GDPR, CCPA and PECR.

What is Dokku?

Dokku is the smallest PaaS implementation you've ever seen - Docker powered mini-Heroku.

Requirements

Setup

Note : We are going to use the domain plausible.example.com for demonstration purposes. Make sure to replace it with your own domain name.

App and plugins

Create the app

Log onto your Dokku Host to create the Plausible app :

dokku apps:create plausible

Install, create and link PostgreSQL and Clickhouse plugins

# Install Dokku plugins
dokku plugin:install https://github.com/dokku/dokku-postgres.git postgres
dokku plugin:install https://github.com/dokku/dokku-clickhouse.git clickhouse
# Create running plugins
dokku postgres:create plausible -I 14.6
dokku clickhouse:create plausible -i clickhouse/clickhouse-server -I 22.9.7.34
# Link plugins to the main app
dokku postgres:link plausible plausible
dokku clickhouse:link plausible plausible

Configuration

Setting up secret key

dokku config:set plausible SECRET_KEY_BASE=$(openssl rand -base64 64 | tr -d '\n')

Setting up BASE_URL

dokku config:set plausible BASE_URL=https://plausible.example.com

Setting up smtp information

dokku config:set plausible MAILER_EMAIL=admin@example.com \
                           SMTP_HOST_ADDR=mail.example.com \
                           SMTP_HOST_PORT=465 \
                           SMTP_USER_NAME=admin@example.com \
                           SMTP_USER_PWD=example1234 \
                           SMTP_HOST_SSL_ENABLED=true

Disable registration (optional)

dokku config:set plausible DISABLE_REGISTRATION=true

Domain

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

dokku domains:set plausible plausible.example.com

Push Plausible to Dokku

Grabbing the repository

First clone this repository onto your machine.

# Via SSH
git clone git@github.com:d1ceward/plausible_on_dokku.git

# Via HTTPS
git clone https://github.com/d1ceward/plausible_on_dokku.git

Set up your Dokku server as a Git remote

git remote add dokku dokku@example.com:plausible

Push Plausible to Dokku

git push dokku master

SSL certificate

Last but not least, we can go an grab the SSL certificate from Let's Encrypt.

# Install letsencrypt plugin
dokku plugin:install https://github.com/dokku/dokku-letsencrypt.git

# Set certificate contact email
dokku config:set --no-restart plausible DOKKU_LETSENCRYPT_EMAIL=you@example.com

# Generate certificate
dokku letsencrypt:enable plausible

Wrapping up

Your Plausible instance should now be available on https://plausible.example.com.

Possible issue with proxy ports mapping

If the Plausible instance is not available at the address https://plausible.example.com check the return of this command :

dokku proxy:ports plausible
### Valid return
-----> Port mappings for plausible
    -----> scheme  host port  container port
    http           80         5000

### Invalid return
-----> Port mappings for plausible
    -----> scheme  host port  container port
    http           5000       5000

If the return is not the expected one, execute this command :

dokku proxy:ports-set plausible http:80:5000

If the return of the command was valid and Plausible is still not available, feel free to fill an issue in the issue tracker.

Bonus : Rename script file

By default, Plausible will use a file called /js/plausible.js which is blocked by most adblockers (Adblock business lets you pay to display your ads, but privacy-focused analytics are blocked by default. Yay).

Since Plausible respects user privacy, it seems fair to collect anonymous traffic data. You can add a nginx config file: vi /home/dokku/plausible/nginx.conf.d/rewrite.conf:

rewrite ^/js/pls.js$ /js/plausible.js last;

Rename pls.js to whatever fits your need, and use this file name from now on.

About

Dockerfile to run Plausible (analytics) on Dokku (mini-Heroku)

Resources

Code of conduct

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Shell 77.1%
  • Dockerfile 22.9%