I have a Django service running inside Docker that I deploy to AWS Elastic Beanstalk.
I would like to run my database migrations at deploy-time
If I were deploying to EB as "a Python project", I could have the following in my .ebextensions:
$ cat .ebextensions/01run.config
container_commands:
01migrate:
command: "python manage.py migrate --noinput"
leader_only: true
However, container_commands are for the EC2 instances - and it's inside the Docker container that I have my code etc.
Things I've already looked at
-
I can't just add it to my Dockerfile, because applying migrations is all about operating on the attached RDS instance (supplied by the environment) - not really "part of building the Docker image"
-
There doesn't seem to be anything useful I can add to Dockerrun.aws.json
Ideas very much welcomed please!