0

We need to deploy our 4 applications (3 spring boot apps and 1 zookeper) with docker stack. As our DevOps guy told us, there is no way how to define in docker stack which application will be depending on another like in docker compose, so we as developers need to solve it in code.

Can you tell me how to do that or what is the best way? One of our applications have to be started as first because that app manage database (migration and so on). Next can start other applications when database is prepared. Any ideas? Thanks.

Ahmed Ashour
  • 5,179
  • 10
  • 35
  • 56
Denis Stephanov
  • 4,563
  • 24
  • 78
  • 174

1 Answers1

0

if you want to run all the 4 applications in one docker container, you can refer to this postRun multiple services in a container

if you want to docker compose the 4 applications, you can refer to this post startup order, it use depends_on your other app images

no matter what the way is, you must write a script to check if your first app has already finish to manage the database, you can refer wait-for-postgres.sh to learn how to use sleep in shell to repeatedly check your first app status

the more precisely way i can suggest one is for example:

  1. put a shared static variable to false public static boolean is_app_start = false;
  2. when you finish to manage your database, change this value to true;
  3. write a @RequestMapping("/is_app_start") in your controller to return this value
  4. use curl in your shell script to check the value
clevertension
  • 6,929
  • 3
  • 28
  • 33