Docker and Postgres

Hello,

I am trying to run Kanboard inside docker with Postgres DB, but it always show in the settings that it is using sqlite. I am doinig something wrong, but I cannot figure out what.

My .env file (password is a fake):

POSTGRES_PASSWORD=myVeryStrongPassword
DATABASE_URL=postgres://kanboard:myVeryStrongPassword@db:5432/kanboard

Here is my docker-compose file:

---
version: '3'
networks:
  web:
    external: true
services:
  db:
    image: postgres:10-alpine
    restart: unless-stopped
    environment:
      - POSTGRES_DB=kanboard
      - POSTGRES_USER=kanboard
    env_file:
      - ".env"
    volumes:
      - "${CHATONS_ROOT_DIR:-/srv/chatons}/${CHATONS_SERVICE:-kanboard}/db:/var/lib/postgresql/data"
      - "./sql/postgres.sql:/docker-entrypoint-initdb.d/initdb.sql"
  app:
    image: kanboard/kanboard:latest
    restart: unless-stopped
    environment:
      - ".env"
    volumes:
      - "${CHATONS_ROOT_DIR:-/srv/chatons}/${CHATONS_SERVICE:-kanboard}/app/data:/var/www/app/data"
      - "${CHATONS_ROOT_DIR:-/srv/chatons}/${CHATONS_SERVICE:-kanboard}/app/plugins:/var/www/app/plugins"
    labels:
      traefik.enable: 'true'
      traefik.frontend.rule: 'Host: ${CHATONS_SERVICE:-kanboard}.${CHATONS_DOMAIN:-localhost},
    www.${CHATONS_SERVICE:-kanboard}.${CHATONS_DOMAIN-localhost}'
    networks:
      - default
      - web

I have in the sql directory the postgres.sql file which is coming from kanboard/app/Schema/Sql/postgres.sql

Any idea on what I am doing wrong ?
Documentation is only containing example for MariaDB. I’ll update the documentation to add a Postgres example when found.

Edit:
If i create a file /var/www/app/data/config.php with the following content:

define('DB_DRIVER', 'postgres');
define('DB_USERNAME', 'kanboard');
define('DB_PASSWORD', 'myVeryStrongPassword');
define('DB_HOSTNAME', 'db');
define('DB_NAME', 'kanboard');
define('DB_PORT', null);

Then it works.
I thought that setting DATABASE_URL was enough.
Any explanation ?

My initial response was going to ask you to check your config file.

I dont generally use docker compose for kanboard, but my guess is DATABASE_DRIVER Isnt pulled out of the url.

Actually, looking at libs/picodb/lib/PicoDb/UrlParser.php, it seems that driver is extracted from the URL.
I’ll open an issue on github.

I see in your docker-compose file that you are using

    environment:
      - ".env"

In the app service.
It should be like the db section:

    env_file:
      - ".env"

environment is used to set the variables directly in the docker-compose file, env_file to load variables from a file.

1 Like

@rafaelcamargo, thanks a lot for pointing this typo out.
Indeed, I used environment for app instead of env_file.
Now it is working fine.
Thanks again for the time you took to look at my issue.

1 Like