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.ymlmay 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.shfile hasend_of_line=LF. To check this, you can see at the right bottom quick settings you’ll seeLForCRLF. It should always beLFfor it to run in linux images.
Setup:
- 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.
- Open terminal at
docker-composefolder and run the command below:
docker compose up
- Now everything is setup.
- If you’re struggling to connect with database you may want to change
ports: 5432:5432line indocker-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 like5433and it will resolve the issue on next docker compose up.