I'm deploying a Django app to EB - my first EB deployment - and I'm confused about the order of things.
My container commands are these:
container_commands:
01_migrate:
command: "django-admin.py migrate"
leader_only: true
02_collectstatic:
command: "django-admin.py collectstatic --noinput"
leader_only: true
What I've noticed, however, is that each time I deploy, these container commands are run on my old codebase. Suppose my current code is app-v1.zip. I update my models.py, and create a migration. I then eb deploy, which creates app-v2.zip. The migrate command is run on the EB environment, but is run on the old codebase (app-v1.zip), before app-v2.zip is unpacked into /var/app/current, and so my migration isn't applied.
If I then run another eb deploy, it will create app-v3.zip, but will run migrate on the code in app-v2.zip. So, it works, but it means I have to run eb deploy twice any time I want to change either data models or static files (the same issue applies to collectstatic).
There is more explanation and a workaround on this blog post and this SO question, but all the "deploy Django to EB" tutorials do things the way I've done it with container_commands.
What's the correct way?