photonix icon indicating copy to clipboard operation
photonix copied to clipboard

Postgres authentication fails in docker container

Open logburn opened this issue 3 years ago • 3 comments

Describe the bug After creating the service as per the docs, logs show that password authentication fails. The Photonix service does run and is accessible, but login is impossible

To Reproduce Steps to reproduce the behavior:

  1. Follow docs on installation
  2. Only change essential variables (no variables were added)
  3. Start docker container and follow logs

Expected behavior Container should connect to postgres without error

Screenshots If applicable, add screenshots to help explain your problem.

Server (please complete the following information):

Desktop (please complete the following information):

  • OS: Fedora 34 GNOME
  • Browser: Firefox
  • Version: :latest as of Aug 2

Additional context Changing the postgres username changes the password, evidence that it is the postgres connection that is the issue. Adding POSTGRES_USER and PASSWORD_AUTHENTICATION: md5 do not help. Installation is behind reverse proxy, and is on a network with other apps. All containers (postgres, redis, and photonix) are on this same network. Below is the docker-compose.yml after some attempts to fix the issue.

version: '3'

services:
  postgres:
    container_name: photonix-postgres
    image: postgres:11.1-alpine
    environment:
      POSTGRES_DB: photonix
      POSTGRES_USER: photonix
      POSTGRES_PASSWORD: photonix
    volumes:
      - ./data/db:/var/lib/postgresql/data
    networks:
      - proxy

  redis:
    container_name: photonix-redis
    image: redis:6.2.2
    networks:
      - proxy

  photonix:
    container_name: photonix
    image: photonixapp/photonix:latest
    environment:
      ENV: prd
      POSTGRES_HOST: photonix-postgres
      POSTGRES_DB: photonix
      POSTGRES_USER: photonix
      POSTGRES_PASSWORD: photonix
      REDIS_HOST: redis
      ALLOWED_HOSTS: '*'
      VIRTUAL_PORT: 80
      VIRTUAL_HOST: photonix.myurl.tld
      LETSENCRYPT_HOST: photonix.myurl.tld
      ADMIN_USERNAME: admin
      ADMIN_PASWORD: admin
      # More configuration options here: https://photonix.org/docs/configuration/
    volumes:
      - ./data/photos:/data/photos
      - ./data/raw-photos-processed:/data/raw-photos-processed
      - ./data/cache:/data/cache
      - ./data/models:/data/models
    links:
      - postgres
      - redis
    networks:
      - proxy

networks:
  proxy:
    external: true

logburn avatar Aug 02 '21 23:08 logburn

I saw somewhere else that there was interest in using MySQL or MariaDB. I'll add here that this would likely help this issue in my case since I already have a working instance of MariaDB and could easily add Photonix to it.

logburn avatar Aug 02 '21 23:08 logburn

Hi @logburn. Thanks for reporting this. Could you try exposing the Postgres port by adding this under image: postgres:11.1-alpine:

    ports:
      - '5432:5432'

Could you then try confirm you can connect with the psql CLI tool (psql -h localhost -p 5432 -U photonix photonix). Thanks.

Another thing to note is that the Postgres username/password only gets created on the first run of the Postgres container so if you changed that it would still be the original value. To get back to a clean DB state and recreate user you can do:

  1. Kill docker compose
  2. sudo rm -rf data/db
  3. Start docker compose again (make start)

damianmoore avatar Aug 17 '21 18:08 damianmoore

i also cannot change the username it is hard-coded to 'postgres' that's all

audioscavenger avatar Nov 08 '21 23:11 audioscavenger