Skip to content

Instantly share code, notes, and snippets.

@ventsislaf
Last active August 29, 2015 14:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ventsislaf/e1deb7c390fd0a49e37b to your computer and use it in GitHub Desktop.
Save ventsislaf/e1deb7c390fd0a49e37b to your computer and use it in GitHub Desktop.
Create Phoenix app on Heroku

Initialize your git repository git init. This would save you later a step to add heroku as remote.

Move configuration from config/prod.secret.exs to config/prod.exs and replace the following parts:

config :app_name, AppName.Endpoint,
  secret_key_base: System.get_env("SECRET_KEY_BASE")

# Configure your database
config :app_name, AppName.Repo,
  adapter: Ecto.Adapters.Postgres,
  url: System.get_env("DATABASE_URL"),
  size: 20 # The amount of database connections in the pool

Remove import_config "prod.secret.exs" from config/prod.exs.

Remove config/prod.secret.exs file and its line in .gitignore.

Create Heroku App:

heroku create app-name --region eu

Set the buildpacks stack:

heroku buildpacks:set https://github.com/gjaldon/phoenix-static-buildpack
heroku buildpacks:add --index 1 https://github.com/HashNuke/heroku-buildpack-elixir

# Buildpack added. Next release on app-name will use:
#    1. https://github.com/HashNuke/heroku-buildpack-elixir
#    2. https://github.com/gjaldon/phoenix-static-buildpack

Create Procfile:

mix phoenix.server

Create elixir_buildpack.config:

erlang_version=17.5
elixir_version=1.0.5
always_rebuild=true
config_vars_to_export=(DATABASE_URL SECRET_KEY_BASE)

Create phoenix_static_buildpack.config:

node_version=0.12.7
npm_version=2.11.3
config_vars_to_export=(DATABASE_URL SECRET_KEY_BASE)

Set SECRET_KEY_BASE ENV variable in Heroku:

heroku config:set SECRET_KEY_BASE=some_secret_key

Commit the changes:

git commit -m "Configure app to run on Heroku"

Push to Heroku:

git push heroku
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment