I’ve just moved my TwitterBot from Ruby/Rails to Elixir/Phoenix and I tend to always miss a step, so here is the process, which is a mix of the Phoenix deploy-to-Heroku page and the Heroku not-officially-supported reference:
mix phx.new zero_to_heroku --no-ecto --module ZeroToHeroku
(note: it is extra-simple without LiveView or a database -
YMMV--no-ecto
then I have you covered, below)cd zero_to_heroku
git init .
.gitignore
to include /.idea
(the Rubymine Dir) and
/junk
(where I move random files that I’ll likely never need again):
echo "/.idea" >> .gitignore
echo "/junk" >> .gitignore
.tool-versions
to configure asdf with the in-use versions
of erlang, elixir, and node
(node is used for compilation of client-side assets, also called “static assets”).
Here is mine right now:
nodejs 14.3.0
elixir 1.10.3-otp-23
erlang 23.0.1
asdf install
to ensure we’re using the correct versions.heroku create zero-to-heroku
(note that one has to use dashes instead of underscores)zero-to-heroku.herokuapp.com
so you can now add that host in the config/prod.exs
file. Without it, the websocket connection will fail.heroku git:remote --app zero-to-heroku
echo 'web: mix phx.server --no-halt' > Procfile
(--no-halt
tells it to ignore some stop signals)heroku buildpacks:set hashnuke/elixir
elixir_buildpack.config
to specific
language versions you’ve been using. Mine:
erlang_version=23.0.1
elixir_version=1.10.3
heroku buildpacks:add https://github.com/gjaldon/heroku-buildpack-phoenix-static.git
phoenix_static_buildpack.config
file,
containing your node version:
node_version=14.3.0
git add * .gitignore .tool-versions .formatter.exs
heroku config:set SECRET_KEY_BASE=`mix phx.gen.secret`
git push heroku master
--no-ecto
part of the command)
then this deploy will probably fail with a DATABASE_URL
error.
Running heroku addons:create heroku-postgresql
should
build a database for it and set the missing DATABASE_URL
value.ecto.create
or
ecto.migrate
in the original instructions - which is nice to see -
it validates that the focus was on getting to heroku,
not any iterating on your local dev machine.