mbucc / shmig

Database migration tool written in BASH.
BSD 3-Clause "New" or "Revised" License
461 stars 50 forks source link

Entrypoint retries #67

Closed swingingsimian closed 2 years ago

swingingsimian commented 2 years ago

Hi

I have added a simple retry/back off loop to the entrypoint script. This is very useful when developing in docker-compose or an other environment where there maybe temporary DB connection issues.

It has 4 tries in total, with the 3 retries at 5, 10 and 30 seconds. Which should be enough for a DB container to be ready.

mbucc commented 2 years ago

@swingingsimian Thanks, this sounds very useful.

Curious about your docker usage, do you build your own image or do you use the one I published way back when?

I'm not a big docker user and I'm curious to learn more how people are using this in a container environment.

swingingsimian commented 2 years ago

I am using a simple docker wrapper which bakes in some config as well as copying in the migration files. This image can then be used:

This PR is primarly enabling the former, as the containers/pods all start together, hence the DB is normally not ready for migrations and the job which is defined as a 'migration' service has to be restarted. Although a little flexiblity around DB connections is not a bad thing for CD either.

swingingsimian commented 2 years ago

@mbucc Fab! Thanks for the merge, and chance this might get pushed to docker hub too?

https://hub.docker.com/r/mkbucc/shmig/tags