by techgaun

GitHub Readme.md


A simple buildpack that just runs mix commands on deployment


This buildpack is intended to be used after heroku buildpack for elixir to run arbitrary commands during deployment.


Make sure your app has heroku-buildpack-elixir configured.

heroku create --buildpack "https://github.com/HashNuke/heroku-buildpack-elixir.git" # for new app

heroku config:set BUILDPACK_URL="https://github.com/HashNuke/heroku-buildpack-elixir.git" # for existing app

Set this buildpack after the heroku-buildpack-elixir.

# Set the buildpack for your Heroku app
heroku buildpacks:set https://github.com/techgaun/heroku-buildpack-mix-tasks.git

# Add this buildpack after the Elixir buildpack
heroku buildpacks:add --index 1 https://github.com/HashNuke/heroku-buildpack-elixir.git


Configure the MIX_DEPLOY_TASKS environment variable with the tasks you want to run.

heroku config:set MIX_DEPLOY_TASKS='ecto.migrate'

You can separate tasks with semicolon if you want to run multiple tasks. Note that they will run in a sequential order.

heroku config:set MIX_DEPLOY_TASKS='ecto.drop;ecto.create;ecto.migrate'

On a side note, I do not recommend running ecto.migrate, db related commands and other various time consuming commands on Production. Esp. running ecto.migrate on Production can become a nightmare when you have grown to big database.