Skip to content

Add PostgreSQL automatic database initialization support#63

Merged
H2CK merged 3 commits intoH2CK:webtrees-2.2from
meyeringh:postgres-initialize-db
Dec 19, 2025
Merged

Add PostgreSQL automatic database initialization support#63
H2CK merged 3 commits intoH2CK:webtrees-2.2from
meyeringh:postgres-initialize-db

Conversation

@meyeringh
Copy link
Contributor

Hey man, love your work on this. I have been using your container in my cluster, but im trying to move away from mysql and only use postgres in there. For k8s i need the automatic db init feature. So here is the PR for it :D.

Summary

  • Extends automatic database initialization to support PostgreSQL (in addition to MySQL/MariaDB)
  • Database type is now configurable via DB_TYPE environment variable (mysql, postgres)
  • Added PostgreSQL client and schema file for automated setup (I just dumped this from an up to date instance of webtrees + postgres. )

Basically: the change is backwards compatible: If you dont do anything different you use mysql, if you specify postgres as DB_TYPE you get the db init for postgres. Let me know if you want me to change anything on this.

btw, this is the docker-compose I used to test this. Not sure if you want this in your repo so im leaving this here:

services:
  postgres:
    image: postgres:18
    container_name: webtrees-postgres
    environment:
      POSTGRES_DB: webtrees
      POSTGRES_USER: webtrees
      POSTGRES_PASSWORD: webtrees1234
    ports:
      - "5432:5432"
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U webtrees"]
      interval: 5s
      timeout: 5s
      retries: 5

  webtrees:
    build:
      context: .
      dockerfile: Dockerfile
    container_name: webtrees-app
    ports:
      - "8080:80"
    environment:
      - DB_HOST=postgres
      - DB_USER=webtrees
      - DB_PASSWORD=webtrees1234
      - DB_NAME=webtrees
      - DB_TYPE=postgres
      - WT_ADMIN=admin
      - WT_ADMINPW=admin12345
      - WT_ADMINMAIL=admin@webtrees.local
      - DISABLE_SSL=TRUE
      - PORT=80
    depends_on:
      postgres:
        condition: service_healthy

@H2CK
Copy link
Owner

H2CK commented Dec 12, 2025

Thank you for this PR. Could you additionally add a folder docker-compose were you add your docker-compose example.

Btw. the pipeline for this PR currently fails due to some problems in the Github Actions. I will take care for this later, but it should not affect your changes.

@meyeringh
Copy link
Contributor Author

Alright, i added the docker compose to a folder 👍

@H2CK
Copy link
Owner

H2CK commented Dec 19, 2025

I will release a new version, which contains these changes in the next days.

@H2CK H2CK merged commit 0ec4a6f into H2CK:webtrees-2.2 Dec 19, 2025
1 of 6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants