Ruby on Rails

How to add a post deployment script to run Rails migrations on a dokku server

Dokku provides limited support to the app.json manifest file, that describes the web application in a heroku environment. This minipost, with demonstrate the required setup in order to run the Rails migrations upon deployment using app.json file on a dokku server.

To the root of your Ruby on Rails application, add the file app.json and paste the following:

  "scripts": {
    "dokku": {
      "postdeploy": "bundle exec rake db:migrate"

At , dokku only supports predeploy and postdeploy scripts to be executed to the dokku server prior or upon deployment accordingly. When all the actions that are occuring during dokku deployment finish, dokku will run the postdeploy tasks to the app container, before releasing the new application version. Having the above postdeploy script to app.json, your dokku deployment logs will output the following:

-----> Running 'bundle exec rake db:migrate' in app container

In the same manner, you can also add predeploy scripts to your app.json.

Additional information: