It wasn't terribly easy to find the supported builds for OTP. While the url below from the Phoenix Framework documentation points to the Github repository, the Version Support heading is what we're really after as we're currently on the heroku-20
stack.
Supported Erlang/OTP versions.
We're following along with the official documentation with supplemental notes from Deploy Elixir Phoenix to Heroku Containers with Docker on StakNine.
-
Get the
heroku
CLI installed locally -
Run
heroku create --buildpack hashnuke/elixir
to add theElixir Buildpack
.- This should create a new host url. Replace
pacific-savannah-85771.herokuapp.com
with this value in all places used below.
- This should create a new host url. Replace
-
Create
elixir_buildpack.config
that matches our.tool-versions
file used by theasdf
version manager.# Elixir version elixir_version=1.12.2 # Erlang version # available versions https://github.com/HashNuke/heroku-buildpack-elixir-otp-builds/blob/master/otp-versions erlang_version=24.0.3
-
Run
heroku buildpacks:add https://github.com/gjaldon/heroku-buildpack-phoenix-static.git
to add thePhoenix Server and Assets Buildpack
. -
Create
phoenix_static_buildpack.config
that adds our Node.js version.# Node.js version node_version=10.23.0
-
Create
Procfile
with our startup commandweb: mix phx.server
. -
Update
config/prod.exs
with our Heroku url.http: [port: {:system, "PORT"}], url: [scheme: "https", host: "pacific-savannah-85771.herokuapp.com", port: 443], force_ssl: [rewrite_on: [:x_forwarded_proto]],
-
Turn on SSL in
config/prod.secret.exs
by uncommentingssl: true
. -
Configure websocket timeout in
lib/todo_mvc_web/endpoint.ex
by replacingwebsocket: true,
withwebsocket: [timeout: 45_000],
. -
Configured the Heroku Postgres hobby database via
heroku addons:create heroku-postgresql:hobby-dev
. -
Configured the
POOL_SIZE
variable asheroku config:set POOL_SIZE=8
. May attempt to reuse this database as multitenancy for other apps. -
Generated a new secret key base via
mix phx.gen.secret
. -
Configure Heroku's
SECRET_KEY_BASE
environment variable viaheroku config:set SECRET_KEY_BASE="(key)"
. -
Deploy via
git push heroku master
. -
Visit [https://pacific-savannah-85771.herokuapp.com/] to receive
Internal Server Error
message.- Investigate problem by looking at the Postgres data store.
- The utilization section showed
0 tables
.
-
Create the database table structure using
heroku run "POOL_SIZE=2 mix ecto.migrate"
. -
The site [https://pacific-savannah-85771.herokuapp.com/] now works as expected.