fly-apps/dockerfile-rails

Will there be multiple db migrations running if multiple rails servers started?

konami99 opened this issue · 2 comments

So the dockerfile has this line

ENTRYPOINT ["/rails/bin/docker-entrypoint"]

It will run migration when rails server being started. My question is, if auto-scaling triggers multiple web instances, will that run multiple db migrations at the same time? I think it would be nice if the migration could only run just once, after deployment, not everytime when a web server starts.

rubys commented

That is correct, and that is how the rails 7.1 dockerfiles are structured, so by default I'm matching that. If your deployment destination supports a "release" step (many do), you can provide an option to not do the prepare. Here's the instructions provided for fly.io: https://fly.io/docs/rails/getting-started/dockerfiles/#scaling

Interesting, thank you