GoogleChrome / lighthouse-ci

Automate running Lighthouse for every commit, viewing the changes, and preventing regressions
Apache License 2.0
6.33k stars 632 forks source link

LHCI won't connect to postgres socket connection #1002

Closed michielmetcake closed 5 months ago

michielmetcake commented 6 months ago

When trying to connect to a postgres socket it keeps trying to connect to the localhost port. There're not much examples on how to connect to a db with a socket. So I'm asking if someone could please help me out here with understanding the issue and guide me into the right direction.

Our docker-compose file:

---
version: '3'
services:
    lhserver:
        image: patrickhulce/lhci-server
        ports:
            - 9001:9001
        volumes:
            - lhci-data:/data
            - database-socket:/var/run/postgresql
        environment:
            LHCI_NO_LIGHTHOUSERC: 1
            LHCI_STORAGE__SQL_DIALECT: postgres
            LHCI_STORAGE__SQL_DIALECT_OPTIONS__SOCKET_PATH: /var/run/postgresql
            LHCI_STORAGE__SEQUELIZE_OPTIONS__USERNAME: your_username
            LHCI_STORAGE__SEQUELIZE_OPTIONS__PASSWORD: your_password
            LHCI_STORAGE__SEQUELIZE_OPTIONS__DATABASE: your_database_name
    postgres:
        image: postgres
        volumes:
            - database-socket:/var/run/postgresql
        environment:
            POSTGRES_DB: your_database_name
            POSTGRES_USER: your_username
            POSTGRES_PASSWORD: your_password
        expose:
            - 5432
volumes:
    lhci-data:
    database-socket:

Logs returned in the terminal:

lighthouse-server-postgres-1  | 
lighthouse-server-postgres-1  | PostgreSQL Database directory appears to contain a database; Skipping initialization
lighthouse-server-postgres-1  | 
lighthouse-server-postgres-1  | 2024-01-04 10:34:10.452 UTC [1] LOG:  starting PostgreSQL 16.1 (Debian 16.1-1.pgdg120+1) on aarch64-unknown-linux-gnu, compiled by gcc (Debian 12.2.0-14) 12.2.0, 64-bit
lighthouse-server-postgres-1  | 2024-01-04 10:34:10.463 UTC [1] LOG:  listening on IPv4 address "0.0.0.0", port 5432
lighthouse-server-postgres-1  | 2024-01-04 10:34:10.463 UTC [1] LOG:  listening on IPv6 address "::", port 5432
lighthouse-server-postgres-1  | 2024-01-04 10:34:10.466 UTC [1] LOG:  listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
lighthouse-server-postgres-1  | 2024-01-04 10:34:10.469 UTC [29] LOG:  database system was shut down at 2024-01-04 10:34:07 UTC
lighthouse-server-postgres-1  | 2024-01-04 10:34:10.473 UTC [1] LOG:  database system is ready to accept connections
lighthouse-server-lhserver-1  | 
lighthouse-server-lhserver-1  | > lhci@0.0.0 start
lighthouse-server-lhserver-1  | > lhci server --config=./lighthouserc.json
lighthouse-server-lhserver-1  | 
lighthouse-server-lhserver-1  | SequelizeConnectionRefusedError: connect ECONNREFUSED 127.0.0.1:5432
lighthouse-server-lhserver-1  |     at Client._connectionCallback (/usr/src/lhci/node_modules/sequelize/lib/dialects/postgres/connection-manager.js:131:24)
lighthouse-server-lhserver-1  |     at Client._handleErrorWhileConnecting (/usr/src/lhci/node_modules/pg/lib/client.js:327:19)
lighthouse-server-lhserver-1  |     at Client._handleErrorEvent (/usr/src/lhci/node_modules/pg/lib/client.js:337:19)
lighthouse-server-lhserver-1  |     at Connection.emit (node:events:517:28)
lighthouse-server-lhserver-1  |     at Socket.reportStreamError (/usr/src/lhci/node_modules/pg/lib/connection.js:58:12)
lighthouse-server-lhserver-1  |     at Socket.emit (node:events:517:28)
lighthouse-server-lhserver-1  |     at emitErrorNT (node:internal/streams/destroy:151:8)
lighthouse-server-lhserver-1  |     at emitErrorCloseNT (node:internal/streams/destroy:116:3)
lighthouse-server-lhserver-1  |     at process.processTicksAndRejections (node:internal/process/task_queues:82:21)npm notice 
lighthouse-server-lhserver-1  | npm notice New patch version of npm available! 10.2.3 -> 10.2.5
lighthouse-server-lhserver-1  | npm notice Changelog: <https://github.com/npm/cli/releases/tag/v10.2.5>
lighthouse-server-lhserver-1  | npm notice Run `npm install -g npm@10.2.5` to update!
lighthouse-server-lhserver-1  | npm notice