HomePage | RecentChanges | Preferences

Phoenix on Heroku

Note: page superseded by blog post

and the official guide

Having (finally) gotten the Phoenix Framework for Elixir installed (*stares accusingly at Norton Firewall*) and played with the Hello Phoenix app a bit locally, I decided to deploy it to Heroku.

I started with...

... but apparently that blog post is outdated. Let's start over with:

So now with a sample app created with mix (see [Up And Running]) we'll execute the commands shown in the [Usage] instructions for the Phoenix Static Buildpack:

$ heroku buildpacks:set

$ heroku buildpacks:add --index 1

This puts the Elixir buildpack in the first position, and pushes the Phoenix Static build pack down to second. See this article on [using multiple buildpacks for an app] for more info.

Let's try to deploy and see what happens:

$ git push heroku master
remote: -----> Fetching app dependencies with mix
remote: ** (Mix.Config.LoadError) could not load config config/prod.secret.exs

The file is present, but it is listed in .gitignore and so isn't pushed to Heroku. Let's comment out the import in config/prod.exs (last line). (git add && commit)

Trying again, we get a new and improved error message:

$ git push heroku master
remote: == Compilation error on file lib/phoenix_heroku_wsmoak/repo.ex ==
remote: ** (ArgumentError) missing :adapter configuration in config :phoenix_heroku_wsmoak, PhoenixHerokuWsmoak.Repo

And *that's* because the things in that file we didn't import *are* actually needed. But they aren't things you want to commit to your repository, for security reasons they need to be set in the environment.

So, copy the contents of config/prod.secret.exs into config/prod.exs, and then replace the sensitive values with (for example) System.get_env("DATABASE_PASSWORD")

Next, set the corresponding environment variables in Heroku, for example: heroku config:set DATABASE_PASSWORD=longsecretpassword

Finally, edit (create if necessary) phoenix_static_buildpack.config in the root of your app and specify the environment variables to be exported.

Note that this *overrides* the one from so make sure to include any values in that one, such as DATABASE_URL

My phoenix_static_buildpack.config file now includes:


git add && commit these changes, and then `git push heroku master` again...

... and success! With stylesheets this time!

Thanks to ericmj, HashNuke, and chrismccord in #elixir-lang on freenode as well as gjaldon for the build pack.

Questions or comments? |

Future Topics

HomePage | RecentChanges | Preferences
This page is read-only | View other revisions
Last edited August 10, 2015 4:19 pm by (diff)