Skip to content

Instantly share code, notes, and snippets.

@mgiacomini
Created September 20, 2018 14:25
Show Gist options
  • Save mgiacomini/d5b8c468316cc9898242abfe1bc31961 to your computer and use it in GitHub Desktop.
Save mgiacomini/d5b8c468316cc9898242abfe1bc31961 to your computer and use it in GitHub Desktop.
Heroku elixir setup

How configure heroku with elixir umbrella apps.

  1. The first step is create the app.json file that will be used by heroku when create your app (and review apps) This file contains dyno formation, addons, env vars definitions and buildpacks needed to run the app. The post-deploy script will be used when create review apps.

  2. Create the elixir_buildpack.config file for config erlang and elixir versions. This file is used by the elixir buildpack. If the file not exists the buildpack will use some default versions.

  3. Create the phoenix_static_buildpack.config file for config where your assets and web app lives. Note that is important configure this file for the static buildpack locate assets and set node versions. (This will change if is not an umbrella app)

  4. At the end, just create the Procfile for start your web server.

{
"name": "sherclockex",
"description": "",
"scripts": {
"postdeploy": "POOL_SIZE=1 mix do ecto.migrate, run apps/sherclock/priv/repo/seeds.exs"
},
"env": {
"MIX_ENV": {
"description": "The environment.",
"required": true,
"value": "prod"
},
"SECRET_KEY_BASE": {
"description": "The phoenix secret key.",
"required": true,
"generator": "secret"
},
"SENDGRID_KEY": {
"description": "SendGrid api key",
"required": true,
"generator": "secret"
},
"POOL_SIZE": {
"description": "The pool size for postgres.",
"required": true,
"value": "5"
}
},
"formation": {
"web": {
"quantity": 1
}
},
"addons": [
{
"plan": "heroku-postgresql",
"options": {
"version": "9.5"
}
}
],
"buildpacks": [
{"url": "https://github.com/HashNuke/heroku-buildpack-elixir.git"},
{"url": "https://github.com/gjaldon/heroku-buildpack-phoenix-static.git"}
],
"environments": {
"test": {
"addons": ["heroku-postgresql:in-dyno"],
"env": {
"MIX_ENV": "test"
},
"scripts": {
"test": "mix test"
}
}
}
}
erlang_version=21.0
elixir_version=1.7.2
always_rebuild=true
clean_cache=true
compile="compile"
node_version=10.8.0
phoenix_relative_path=./apps/sherclock_web
remove_node=false
assets_path=./apps/sherclock_web
phoenix_ex=phoenix
web: MIX_ENV=prod mix phx.server
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment