moodlehq / moodle-docker

A docker environment for moodle developers
GNU General Public License v3.0
373 stars 244 forks source link

Add MOODLE_DOCKER_DBHOST #238

Open scara opened 1 year ago

scara commented 1 year ago

Hello, while working on MDL-69581 I found an unbalanced situation when playing, better jamming, with the Toolbox environment through an external DB server. Indeed we can set the DB credentials via ENV VAR:

but not the DB Host, not strictly required in the Toolbox ecosystem unless when crossing an external DB instance could be a valuable option still for testing purposes.

Does it make sense? I'd open a PR if it won't hurt adding a new ENV VAR defaulting to db (the service name in the compose file) and mostly unused.

TIA, Matteo

stronk7 commented 1 year ago

That sounds ok for me, can be useful when testing real databases elsewhere (Azure, AWS...) and also local with special debugging, tracing... +1

scara commented 1 year ago

Hi @stronk7, here is the proposal:

  1. the minimum required change: https://github.com/scara/moodle-docker/commit/95b584c07f6fcede76e17ba85d78a835c2aaa03c. The local DB server will be still available and if you keep MOODLE_DOCKER_DB in sync with the type of the external DB server you'll be able to use it e.g. as the local DB client
  2. the change I doubt to be required: https://github.com/scara/moodle-docker/commit/e0bf9bd9130c2e6c50e49a9b20cec9e227aaecdf. This commit prevents the feature to have even the local DB server available for some use cases like the DB client

My feeling is that (2) would be an option not good for a development toolbox like this one is.

HTH, Matteo

stronk7 commented 7 months ago

Exactly one year later (Nov 13th!)...

I think that the 1st option is good enough. It allows, any time, to point to another database elsewhere, without touching the "own" one, and easily go back, or use the database CLI to connect to the external instance or whatever.

So +1 to the 1st approach.

Ciao :-)