Using Docker

Introduction

Docker is a production service management tool. Before proceeding forward with this tutorial, install Docker for your platform.

Docker Compose is supplementary tool that works with Docker to orchestrate containers and services. To install Docker Compose, follow the official documentation for your platform. Note that Docker Compose is entirely optional; you can run Commento containerised with just vanilla Docker.

With Vanilla Docker

First, pull the docker image.

  1. $ docker pull registry.gitlab.com/commento/commento

Then start a container with the appropriate ports. Note that this method requires you to have a running PostgreSQL server somewhere with access to.

  1. $ docker run -it \
  2. -p 80:8080 \
  3. -e COMMENTO_ORIGIN=http://commento.example.com \
  4. -e COMMENTO_POSTGRES=postgres://username:password@ipaddr:port/commento \
  5. registry.gitlab.com/commento/commento

Again, remember to change COMMENTO_ORIGIN and COMMENTO_POSTGRES to appropriate values. Open http://commento.example.com on web browser and you should be greeted with the login page. Go to the next step to create an account and register your website.

With Docker Compose

With Docker Compose it’s easy to orchestrate multiple services with a single configuration file. And with a single docker-compose up command, you can start everything, including a PostgreSQL server. If you don’t have a running PostgreSQL server around, this is recommend.

An example and reference docker-compose.yml for Commento is given below. The latest version of the configuration file can always be found in the source repository (change SET_VERSION below appropriately).

  1. version: '3'
  2. services:
  3. server:
  4. image: registry.gitlab.com/commento/commento:SET_VERSION
  5. ports:
  6. - 8080:8080
  7. environment:
  8. COMMENTO_ORIGIN: http://commento.example.com:8080
  9. COMMENTO_PORT: 8080
  10. COMMENTO_POSTGRES: postgres://postgres:postgres@db:5432/commento?sslmode=disable
  11. depends_on:
  12. - db
  13. db:
  14. image: postgres
  15. environment:
  16. POSTGRES_DB: commento
  17. POSTGRES_USER: postgres
  18. POSTGRES_PASSWORD: postgres
  19. volumes:
  20. - postgres_data_volume:/var/lib/postgresql/data
  21. volumes:
  22. postgres_data_volume:

Remember to change COMMENTO_ORIGIN to the domain where you want to host Commento (if you’re locally testing out, localhost is fine). If you want Commento exposed on a port other than 80, change 80:8080.

The above configuration pulls and sets up Commento and PostgreSQL in two separate containers with a persistent database volume. Save the docker-compose.yml file somewhere and run the following command to start the services.

  1. $ docker-compose -f /path/to/docker-compose.yml up

Open http://commento.example.com on web browser and you should be greeted with the login page. Go to the next step to create an account and register your website.