Skip to content

Feature: Add external database volume and external database connection#155

Open
nshandra wants to merge 10 commits intodevelopmentfrom
feature/external-database
Open

Feature: Add external database volume and external database connection#155
nshandra wants to merge 10 commits intodevelopmentfrom
feature/external-database

Conversation

@nshandra
Copy link
Copy Markdown
Contributor

@nshandra nshandra commented Dec 5, 2025

📌 References

📝 Implementation

Add parameters to d2-docker start to allow either:

  • Store the DB in an external persistent volume
  • Use an external DB instead of a container

Testing

External Persistent Volume Case

This case will store the DB volume at the specified absolute path.

./d2-docker-dev.sh --log-level=DEBUG start <data_image> --external-db-volume="/absolute/path/to/volume_dir"

External DB Case

This case needs a psql DB runnig in the machine hosting the dockers or in a accessible network.

This DB has to have the correct settings:

  • /etc/postgresql/{ver}/main/postgresql.conf

    Set listen_addresses to:

    • '*' (easiest for testing)
    • 'localhost,172.17.0.1' (docker and DB in same system)
    • 'localhost,<reachable_ip>'
  • /etc/postgresql/{ver}/main/pg_hba.conf

    Add an entry to allow the connection. Example:

    # Docker bridge subnet (check with: docker network inspect bridge)
    host    dhis2           dhis            172.17.0.0/16           scram-sha-256
    # LAN
    host    dhis2           dhis            192.168.0.0/24          scram-sha-256

Running d2-cloner:

./d2-docker-dev.sh --log-level=DEBUG start <data_image> --external-db-url="postgresql://user:pass@host:port/db"

#1ck80y8

@nshandra nshandra requested a review from tokland December 5, 2025 08:55
@nshandra nshandra self-assigned this Dec 5, 2025
@nshandra nshandra marked this pull request as draft December 5, 2025 13:06
@nshandra nshandra marked this pull request as ready for review January 21, 2026 21:28
@tokland
Copy link
Copy Markdown
Contributor

tokland commented Jan 26, 2026

@nshandra Sorry, I had this pending. Can you merge with development? (re-add me when done)

@nshandra
Copy link
Copy Markdown
Contributor Author

@tokland done.

@tokland tokland requested review from tokland and removed request for tokland January 26, 2026 09:13
Copy link
Copy Markdown
Contributor

@tokland tokland left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Features worked for me (only I had to add a trailing comma, probably a merge artifact)

In-line comments about the code:

Comment thread src/d2_docker/utils.py Outdated
Comment thread src/d2_docker/commands/start.py
Comment thread src/d2_docker/commands/start.py
Comment thread src/d2_docker/commands/start.py
Comment thread src/d2_docker/config/dhis2-core-start.sh Outdated
Comment thread src/d2_docker/utils.py Outdated
Comment thread src/d2_docker/utils.py Outdated
Comment thread src/d2_docker/commands/start.py
Comment thread src/d2_docker/config/dhis2-core-start.sh Outdated
Comment thread src/d2_docker/utils.py Outdated
@nshandra nshandra requested a review from tokland April 17, 2026 07:24
Copy link
Copy Markdown
Contributor

@tokland tokland left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All good as far as I can see and test 👍

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