Hello, I’m trying to connect Commento to PostgreSQL. Hopefully someone who’s reading this is familiar with what Commento is, but if not I’ll briefly explain. I’ve been transferring a blog over onto Hugo, which took a bit of learning, but is well worth the effort. I now have my own personal theme, which is nice. The only downside is that because it’s a static site generator there’s no straightforward way to integrate blog comments. Commento is one of the apps that gets you there. There is the option of connecting your site to Commento’s online database, but honestly I can’t afford to be paying a monthly fee for that as long as it’s only a small-scale enterprise, and so I’m trying to install Commento myself (and anyway I like working things out by myself).
The idea is that you create a database with PostgreSQL (which I haven’t used before, but I have used MySQL, so there’s no mystery), and then you install Commento, which is supposed to interact between the db and the website. The online instructions for installing Commento don’t say anything in particular about any required settings for the db, so I just created something completely blank:
CREATE DATABASE "commento";
CREATE USER commento-user WITH PASSWORD 'blablablapassword';
GRANT ALL PRIVILEGES ON DATABASE "commento" TO commento-user;
Then I’ve added a reverse proxy redirect from NGinX to the Commento instance, using this block of code:
location /commento {
proxy_pass http://localhost:34567;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
(Insert any port there - just picking random ports for security reasons)
OK, and then I tried to follow these instructions, using Docker Compose to install the application. Before starting the installation, I configured the docker-compose.yml file. This is where I’m really not sure that I’ve got it right (I can’t see what would be wrong with the previous two settings):
version: '3'
services:
server:
image: registry.gitlab.com/commento/commento:latest
ports:
- 34567:8080
environment:
COMMENTO_ORIGIN: https://hugoblogtest.local/commento
COMMENTO_PORT: 8080
COMMENTO_POSTGRES: postgres://commento-user:blablablapassword@db:5432/commento?sslmode=disable
depends_on:
- db
db:
image: postgres
environment:
POSTGRES_DB: commento
POSTGRES_USER: commento-user
POSTGRES_PASSWORD: blablablapassword
volumes:
- ./docker-entrypoint-initdb.d:/docker-entrypoint-initdb.d
volumes:
postgres_data_volume:
OK, and then when I run the docker-compose command:
sudo docker-compose -f docker-compose.yml up
…this happens .
sudo docker-compose -f docker-compose.yml up !10187
Starting commento_db_1 ... done
Starting commento_server_1 ... done
Attaching to commento_db_1, commento_server_1
db_1 |
db_1 | PostgreSQL Database directory appears to contain a database; Skipping initialization
db_1 |
db_1 | 2024-10-01 21:39:02.998 UTC [1] LOG: starting PostgreSQL 17.0 (Debian 17.0-1.pgdg120+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 12.2.0-14) 12.2.0, 64-bit
db_1 | 2024-10-01 21:39:02.998 UTC [1] LOG: listening on IPv4 address "0.0.0.0", port 5432
db_1 | 2024-10-01 21:39:02.998 UTC [1] LOG: listening on IPv6 address "::", port 5432
db_1 | 2024-10-01 21:39:03.004 UTC [1] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
db_1 | 2024-10-01 21:39:03.018 UTC [28] LOG: database system was shut down at 2024-10-01 21:31:49 UTC
db_1 | 2024-10-01 21:39:03.033 UTC [1] LOG: database system is ready to accept connections
server_1 | 2024/10/01 21:39:03 [INFO] version.go:13 versionPrint(): starting Commento
server_1 | 2024/10/01 21:39:03 [INFO] database_connect.go:20 dbConnect(): opening connection to postgres: postgres://commento-user:redacted@db:5432/commento?sslmode=disable
server_1 | 2024/10/01 21:39:03 [ERROR] database_connect.go:31 dbConnect(): cannot talk to postgres, retrying in 10 seconds (4 attempts left): pq: unknown authentication response: 10
server_1 | 2024/10/01 21:39:13 [INFO] database_connect.go:20 dbConnect(): opening connection to postgres: postgres://commento-user:redacted@db:5432/commento?sslmode=disable
server_1 | 2024/10/01 21:39:13 [ERROR] database_connect.go:31 dbConnect(): cannot talk to postgres, retrying in 10 seconds (3 attempts left): pq: unknown authentication response: 10
server_1 | 2024/10/01 21:39:23 [INFO] database_connect.go:20 dbConnect(): opening connection to postgres: postgres://commento-user:redacted@db:5432/commento?sslmode=disable
server_1 | 2024/10/01 21:39:23 [ERROR] database_connect.go:31 dbConnect(): cannot talk to postgres, retrying in 10 seconds (2 attempts left): pq: unknown authentication response: 10
Clearly failing every time. I spent a whole evening going crazy with it, going round and round in circles asking ChatGPT what was going on, but in my experience going round and round in circles with AI is worse than going round in circles by yourself! And so here I am now.
Any ideas here? I also tried deleting the database, and changing the user to the postgres superuser, with the notion that maybe Commento needs to create the database “in its own image”, but that didn’t work either.