I'm currently running a Dockerized NodeJS application that's using Postgres. The Postgres database url is coming as an environment variable, as set by Heroku. While this works great inside my container, I'm wondering how I should go ahead about running database migrations.

At which stage should I be doing this? I suppose I can't do this as part of my docker build process, as this happens outside of the Heroku environment.

What's the correct process for something like this?


Take a look at the new heroku.yml preview: https://devcenter.heroku.com/articles/heroku-yml-build-manifest

You'll need to move to that in order to have release phase support with containers.

You can add this to heroku.yml:

  image: web
    - migrateScriptYoureUsing

More info: https://devcenter.heroku.com/articles/buildpack-builds-heroku-yml#release-release-phase

Alternatively, you can do this by pushing a release image. That image will be used as the release phase one whenever any process type is deployed.

Not the answer you're looking for? Browse other questions tagged or ask your own question.