-
-
Save mikeclarke/f044d4161d36ff864d37 to your computer and use it in GitHub Desktop.
container_commands: | |
sync_db: | |
command: "docker run --env DATABASE_URL=`/opt/elasticbeanstalk/bin/get-config environment | jq -r .DATABASE_URL` aws_beanstalk/current-app:latest lein lobos migrate" | |
leader_only: true |
me gusta! thanks for posting this
Just as a note - EB momentarily runs two containers between deploys - the one with your old application version, and one with a new version. I've been using a similar migration script, and it runs before the new container is renamed to aws_beanstalk/current-app:latest
and deployed. Consequently, the migrations run in the container for the previous application version, which can lead to some inconsistencies (old migrations applied to a fresh deploy).
@Tuuleh do you mind sharing how you solved this problem that you described?
@mikeclarke -- Thank you.
I'm late here, but this was incredibly helpful, thanks!
@xuebingli for you and moreso people who stumble on this in the future, aws_beanstalk/staging-app:latest
would be the incoming app.
I figured this out by adding a 'docker images' command to container_commands, and then pulling the beanstalk logs.
Thanks for the followup @bpicolo, you saved me a bunch of time.
In case this helps anyone else, heres my working version of the .ebextension file for migrating with docker using aws_beanstalk/staging-app:latest
: https://gist.github.com/jschr/873a4ad8591760202c20ea702e6d3c99.
Dumb question, when did this "/opt/elasticbeanstalk/bin/get-config" come into being?!