Commento is a fast, light-weight, privacy-focused and open-source commenting platform. If you want to install the self-hosted version of Commento on your server, you're at the right place.
In this tutorial, we're going to learn how to install Commento on a linux server with the help of Docker and docker-compose. We will also setup a reverse proxy with letsencrypt to securely access our Commento instance with a SSL connection.
To complete this tutorial, you will need:
Step 1 – Creating a DNS record
Login to your domain name provider and create a A record that points to the server you want to use to setup Commento. I suggest you to choose something like commento.example.com.
Step 2 - Creating the docker-compose file
Create a docker-compose.yml file on your server and append the following content to it
version: '3' services: proxy: restart: always image: traefik command: - "--api" - "--entrypoints=Name:http Address::80 Redirect.EntryPoint:https" - "--entrypoints=Name:https Address::443 TLS" - "--defaultentrypoints=http,https" - "--acme" - "--acme.storage=/etc/traefik/acme/acme.json" - "--acme.entryPoint=https" - "--acme.httpChallenge.entryPoint=http" - "--acme.onHostRule=true" - "--acme.onDemand=false" - "--firstname.lastname@example.org" # TODO: Replace with your email address - "--docker" - "--docker.watch" volumes: - /var/run/docker.sock:/var/run/docker.sock:ro - ./traefik/acme:/etc/traefik/acme networks: - web ports: - "80:80" - "443:443" labels: - "traefik.enable=false" server: image: registry.gitlab.com/commento/commento:v1.7.0 environment: COMMENTO_ORIGIN: https://commento.example.com # TODO: Replace commento.example.com with your domain name COMMENTO_PORT: 3298 COMMENTO_POSTGRES: postgres://postgres:STRONG_PASSWORD@db:5432/commento?sslmode=disable #TODO: Replace STRONG_PASSWORD with a random password networks: - web - db labels: - "traefik.enable=true" - "traefik.port=3298" - "traefik.frontend.rule=Host:commento.example.com" # TODO: Replace commento.example.com with your domain name db: image: postgres environment: POSTGRES_DB: commento POSTGRES_USER: postgres POSTGRES_PASSWORD: STRONG_PASSWORD #TODO: Replace STRONG_PASSWORD with the same password you chose earlier networks: - db volumes: - postgres_data_volume:/var/lib/postgresql/data labels: - "traefik.enable=false" volumes: postgres_data_volume: networks: web: external: true db:
In the file above, you need to change every line with a TODO comment.
This docker-compose file consists of 3 services:
- The Commento service
- A postgresql database
- A traefik reverse proxy
I decided to use Traefik because it makes it easy to generate SSL certificates with letsencrypt.
Step 3 - Creating a docker network
To connect the commento service with the traefik reverse proxy, you will have to create a docker network. To do so, run the following command:
docker network create web
Step 4 - Starting Commento
Finally, launch the services by running
If everything started successfully, you should see something like this
Navigate to the subdomain you created and voilà! Commento should be working.
If you want to keep the services running when you close the terminal, start docker-compose in detached mode.
docker-compose up -d
Bonus: Adding Google Sign-In
By default, your readers will have to create an account if they want to comment on your blog or website. Fortunately, Commento implemented Google Sign-In (as well as Twitter, Gitlab and Github) to simplify the process.
Setting up the OAuth client
Navigate to https://developers.google.com/identity/sign-in/web/sign-in and click on "Configure a project"
On the first screen, select "Create a new project" and choose a name. Click Next and choose a product name. Click Next one more time and you will land on a window called "Configure your OAuth client"
In the first input, select "Web server". In the second input, you will have to enter the following URL:
Finally, once you click on the Create button, you will get your Client ID and Client Secret. Save those values as we will need them shortly.
Editing the docker-compose
In you docker compose, add the following environment variable to the "server" service.
COMMENTO_GOOGLE_KEY: YOUR-CLIENT-ID COMMENTO_GOOGLE_SECRET: YOUR-CLIENT-SECRET
The service will look like this:
server: image: registry.gitlab.com/commento/commento:v1.7.0 environment: COMMENTO_ORIGIN: https://commento.example.com COMMENTO_PORT: 3298 COMMENTO_POSTGRES: postgres://postgres:STRONG_PASSWORD@db:5432/commento?sslmode=disable COMMENTO_GOOGLE_KEY: YOUR-CLIENT-ID COMMENTO_GOOGLE_SECRET: YOUR-CLIENT-SECRET networks: - web - db labels: - "traefik.enable=true" - "traefik.port=3298" - "traefik.frontend.rule=Host:commento.example.com"
Restart Commento by running
docker-compose down followed by
docker-compose up -d and you're good to go!
That's it! If you want to receive weekly news digests that will help you create and grow your website, don't hesitate to subscribe to our free newsletter by adding your email address below.