Docker Community Forums

Share and learn in the Docker community.

Swarm with database migration


(Thibaud Lepretre) #1

I would use Swarm (1.12) to deploy Java application (Spring). Moreover I would take advantage of healthchecking and load-balancing features.

However my app is using database migration tools named Flyway. When new migration is written, Flyway will apply migration during deployment, thus application will not be available until migration successfully completed.

So between each app version (depending of migration present or not), application deployment can take different time to deploy from less than 1 min (without migration) to more than hour (when migration).

Is there a good practice to manage such case? Because if I set HEALTHCHECK swarm will consider application has unhealthy and restart it again and again (depending on restart-policies.

  1. Should database migration be outside of application? Deploy app-v1, then deploy migrator-v1-v2, wait migration then upgrade app-v1 to app-v2
  2. Other way?