This post is old and probably irrelevant today.

19 August 2019

How to install Commento on Dokku

Commento's hosted plan is pretty cheap — but where's the fun if we can't mess up with it?

Fortunately it's also open-source, and available as a Docker image. Let's deploy it on our server using Dokku!

Update in April 2021

Use git:from-image instead of tags:deploy since Dokku 0.24.0.

Commento: "A fast, privacy-focused commenting platform" Commento is also open-source — meaning we can install it on our Dokku!

Log in to your server

You'll need a box with Dokku already installed. We're using DigitalOcean's $5/m droplet, which is enough to start.

First step: SSH to your server.

All the commands below are to be run on your server. Nothing will be done on your local machine, not even a local git repo — we'll be using Dokku's ability to deploy via a Docker image.

Create a Dokku app for Commento

Adapted from

Make sure to install dokku-postgres plugin first.

Create an app and set its domain

Replace with your own domain:

dokku apps:create commento
dokku domains:set commento

Create the database

Commento needs a PostgreSQL database to hold all its data. Let's create it and link it to our app.

dokku postgres:create commento
dokku postgres:link commento commento

Set up ports

Dokku usually discovers itself which ports to expose. However, we need to explicitely declare it as we'll deploy using Docker image, cf. this documentation.

dokku proxy:ports-set commento http:80:8080

Commento config

We need to set COMMENTO_ORIGIN to the domain where Commento is hosted — the same one set in the first step.

dokku config:set --no-restart commento COMMENTO_ORIGIN=

When linking the database with dokku, a default DATABASE_URL is set with the connection info. Unfortunately, Commento doesn't use that variable. Instead it expects COMMENTO_POSTGRES.

We could manually set COMMENTO_POSTGRES, but instead we'll set it at runtime using docker options, and some command substitution to dynamically get the connection info for the commento dokku app. Note that we need to escape the $(...) as we don't want to substitute the command now — instead we want it to be substitued when dokku starts the app and adds that option.

dokku docker-options:add commento run,deploy "-e COMMENTO_POSTGRES=\$(dokku postgres:info commento --dsn)"

Note that it shouldn't matter if your shell supports $() command substitution or not (e.g. Fish does not), as Dokku will use bash under the hood.

If, however, there's any issue when starting Commento (check dokku logs commento output), you should first try to set COMMENTO_POSTGRES manually:

# Clean up the docker-options set before
dokku docker-options:remove commento run,deploy "-e COMMENTO_POSTGRES=\$(dokku postgres:info commento --dsn)"
# And set the ENV var manually
dokku config:set --no-restart commento COMMENTO_POSTGRES=$(dokku postgres:info commento --dsn)

If you do that, don't forget that you'll have to manually update COMMENTO_POSTGRES if the DB connection info changes.

Deploy using Docker image tags

We're deploying the official Commento docker image:

dokku git:from-image commento

This is also how Commento can be updated.

Enable SSL

Install dokku-letsencrypt first, then:

dokku config:set --no-restart commento DOKKU_LETSENCRYPT_EMAIL=[email protected]
dokku letsencrypt commento

Finish Commento setup

By this point, Commento should be up and running. If you can't access it at the domain you set, review the previous steps and try setting COMMENTO_POSTGRES manually, then restart the app (dokku ps:restart commento).

Your very own dashboard!

Then, follow these instructions to create an account, log in, and register your domain where to display comments:

Enable / disable options

Some additional Commento features can be enabled using environment variables, like this:

dokku config:set commento COMMENTO_FORBID_NEW_OWNERS=true COMMENTO_GZIP_STATIC=true

Here's the one you might want to enable:

# Disable new accounts - to be done AFTER you've created your account

# Optimize assets

# Send email alerts (e.g. we use Mailgun)
COMMENTO_SMTP_USERNAME=[email protected]

# Akismet anti-spam, cf.

# To let users log in using known oAuth providers, you'll need to create your own apps

When creating the oAuth apps, use this pattern as callback URLs:


Commento stores all its settings and comments in the DB. This is the only thing we have to back up.

Automatic DB backup on Amazon S3

We use AWS S3 because it's cheap and the dokku-postgres' backup feature is working out-of-the-box with it.

On your AWS account:

We then use Dokku's built-in backup feature (commento is the name of the DB linked to the commento app, and our S3 bucket exists in the eu-central-1 region):

dokku postgres:backup-auth commento AWS_ACCESS_KEY_ID AWS_SECRET_ACCESS_KEY eu-central-1

For added security, let's encrypt the backup files. Use your password manager to generate a new, strong password and save it:

dokku postgres:backup-set-encryption commento "YOUR_GPG_PASSPHRASE_SAVED_IN_1PASSWORD"

Let's schedule the DB backup twice a day. We want to save it in the backups/ "folder" of the S3 bucket:

dokku postgres:backup-schedule commento "0 */12 * * *" yourdomain-commento-dokku-postgres-backups-12345678-abcd-90/backups

To keep things clean, you can create an S3 lifecycle rule and delete old backups after 180 days (about 6 months).

How to recover a crashed DB from a backup

In any case, you should take advantage of your server provider's backup feature. E.g. DigitalOcean takes a weekly snapshot of the whole state of our server.

  1. Download the latest backup file from your S3 bucket.

  2. Make sure you have GPG installed locally. Easiest solution on macOS is to use GPG Suite:

    brew cask install gpg-suite

    You'll need to install first.

  3. Decrypt the .gpg backup file (remember the passphrase you saved in your password manager earlier?):

    gpg -o postgres-commento.tgz -d postgres-commento-timestamp.tgz.gpg
  4. Expand the .tgz to get the decrypted DB dump, transfer it to your server, and import it to PostgreSQL. BEWARE: this will overwrite the current DB, make sure you also backed it up manually:

    dokku postgres:import commento < db_export.dump

How to update Commento

Just update the Docker image for Commento and deploy it:

dokku git:from-image commento