0

I have a djanog application. I have created an Docker image and pushed to ECR

My docker image, has an entryscript which runs the

python manage.py migrate

I am planning to have a 4 tasks/containers of DJango running simultaneously

So when each container is getting started, it will run the entrypoint script.

Assume two containers are starting in parallel, each will try to run the entrypoint script. i.e the migrate

So I am thinking this will collide with the database tables creation properly

How to solve this issue

Santhosh
  • 9,965
  • 20
  • 103
  • 243
  • Does this answer your question? [Django migrations deployment strategy with AWS ECS Fargate?](https://stackoverflow.com/questions/75406805/django-migrations-deployment-strategy-with-aws-ecs-fargate) – Mark B Apr 04 '23 at 11:31
  • What i understand is, 1) stop all the containers. 2) trigger migrations from outside ECS, i.e deploy independently on a EC2 instance, and run migration from there and shut it down. 3) restart service: Force new deployment – Santhosh Apr 04 '23 at 12:30
  • (i think this is the only way) Or you could just accept some down-time during deployments by configuring ECS to stop all old tasks before starting new ones. – Santhosh Apr 04 '23 at 12:31
  • whenever its related to migrations then we have stop all old tasks and do migraitons and start new ones. But when the code changes are not related to any migrations we can use ECS as it is – Santhosh Apr 04 '23 at 12:33
  • https://engineering.instawork.com/elegant-database-migrations-on-ecs-74f3487da99f (i found this also useful, but have to try this) – Santhosh Apr 04 '23 at 12:39
  • You don't appear to have read my answer that I linked, if you that is your understanding. – Mark B Apr 04 '23 at 12:39
  • I have read that answer. based on that only i was replying. Basically we have to have a downtime, if dealing with migrations. – Santhosh Apr 05 '23 at 05:15

0 Answers0