· 2 min read

Hosting Plausible Analytics on Dokku

Plausible is an application that provides web analytics. These are the instructions on how to install Plausible on Dokku.

Plausible is an application that provides web analytics but actually respects your users privacy. Below are the instructions on how to install Plausible on Dokku.

This is a modified version of the work done by Kevin Langley Jr. I made some modifications to the article and upgraded the Dockerfile to the latest Plausible version.

Installation

First, you need to SSH into your Dokku Host and create the Plausible app:

dokku apps:create plausible

Next, you need to install the PostgreSQL and Clickhouse plugins, if they aren’t already installed.

dokku plugin:install https://github.com/dokku/dokku-postgres.git postgres
dokku plugin:install https://github.com/dokku/dokku-clickhouse.git clickhouse

Create the instances of the PostgresSQL and Clickhouse databases.

dokku postgres:create plausible-db
dokku clickhouse:create plausible-events-db

Then set the environment variables for the database scheme, which just sets it to use the scheme expected within the Plausible Docker image. Then link the databases to the application.

dokku config:set plausible CLICKHOUSE_DATABASE_SCHEME=http
dokku postgres:link plausible-db plausible
dokku clickhouse:link plausible-events-db plausible

Next, you’ll slightly adjust the URL that was provided from linking the Clickhouse database and change the name of the environment variable for it as well to match what is expected within the Plausible docker image.

dokku config:set plausible CLICKHOUSE_DATABASE_URL=$(dokku config:get plausible CLICKHOUSE_URL)/plausible
dokku config:unset plausible CLICKHOUSE_URL

Then you need to generate a secrete key using openssl.

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

And then, we’ll set the BASE_URL environment variable and set the domain for the application — make sure to use your domain here.

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

Set the required SMTP environment variables to set up transactional emails.

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=password \
                           SMTP_HOST_SSL_ENABLED=true

Set up the admin account for the application. And then, we can optionally disable registration, this is especially useful if this is just for you and you aren’t inviting any clients or other users to utilize it.

dokku config:set plausible ADMIN_USER_EMAIL=admin@example.com \
                           ADMIN_USER_NAME=admin \
                           ADMIN_USER_PWD=password

dokku config:set plausible DISABLE_REGISTRATION=true

Next, you need to clone the repository on your local machine.

git clone https://codeberg.org/bart/dokku-plausible.git

Set the Dokku host as the git remote for the repository and push it on up to your Dokku host.git remote add dokku dokku@dokku.example.com:plausible

git push dokku master

Finally, you can generate the Let’s Encrypt SSL certificates.

dokku letsencrypt:enable plausible

You can now access your Plausible instance via the domain you configured.

Back to Blog