Skip to main content

Configuration local database

While testing in any environment we may feel the need to update database or create new database etc, but we can’t do it in acceptance or production environment directly right?

Well, we’ve wrote a sweet short script in side the Configuration repository’s docker-compose folder which is in the root of repository.

There is a entrypoint file which if you run locally while your docker-daemon is running, it will setup database and tables etc.

Notes:

  • docker-compose.yml may show run button in advanced IDE, but do not use that. I may cause scripts to fail sometimes.
  • Before running it for the first time make sure that, docker-compose/init-scripts/ each .sh file has end_of_line=LF. To check this, you can see at the right bottom quick settings you’ll see LF or CRLF. It should always be LF for it to run in linux images.

Setup:​

  1. Delete all the existing container, volume, images in docker if you’re running scripts for the first time as it may cause PORT busy error or start using the existing images resulting in outdated updates.
  2. Open terminal at docker-compose folder and run the command below:
docker compose up
  1. Now everything is setup.
  2. If you’re struggling to connect with database you may want to change ports: 5432:5432 line in docker-compose.yml. Note that the port on left of ":" is external system port and on the right it’s a docker container internal port. So you may only want to change left port to some value like 5433 and it will resolve the issue on next docker compose up.