This is my default template for web apps using my favorite tools:
- Phoenix
- Haml
- Elm (via elm-brunch)
- Heroku
Below are instructions for
- creating a new app from the template
- deploying the app to Heroku
Suppose you are starting a new project named "PlumCake".
-
Clone this repository and give your folder a name:
git clone https://github.com/stefankreitmayer/elm-heroku-template.git plum_cake
-
cd plum_cake
-
Batch-replace the strings
ElmHeroku
andelm_heroku
respectively. I use the following Vim commands that I learned from here. NB the second line requres vim-abolish.:args {config,lib,priv,test,web}/**/**.ex{,s} mix.exs
:argdo %S/elm_heroku/plum_cake/g
:argdo update
-
Verify that the substitution went OK, e.g. in Vim
:Ack elm_heroku
/:Ack ElmHeroku
-
Rename the contents of
lib
:mv lib/elm_heroku lib/plum_cake
mv lib/elm_heroku.ex lib/plum_cake.ex
-
Replace the string MY_APPLICATION in
config/prod.exs
-
Run
mix deps.get
-
Run
npm install
-
Run
mix ecto.create
-
Run
mix phoenix.server
-
In a browser, go to
localhost:4000
and expect a basic single-page application with client-side navigation. -
Run
./run-elm-tests.sh
and expect all tests to be green. -
Update README.md
-
Commit your changes
Finally, disconnect your project from the template repository
git remote remove origin
The following instructions are a summary of this official guide, from where I also copied the modifications to config/prod.exs
, web/channels/user_socket
, and Procfile
. You can probably leave these files unchanged.
heroku create MY_APPLICATION_NAME
heroku buildpacks:add https://github.com/gjaldon/heroku-buildpack-phoenix-static.git
heroku buildpacks:add --index 1 https://github.com/HashNuke/heroku-buildpack-elixir
DATABASE_URL
heroku addons:create heroku-postgresql:hobby-dev
POOL_SIZE
heroku config:set POOL_SIZE=18
SECRET_KEY_BASE
mix phoenix.gen.secret
...and copy the resulting string to...
heroku config:set SECRET_KEY_BASE="PASTE_THE_STRING_HERE"
git push heroku master
heroku run "POOL_SIZE=2 mix ecto.migrate"
heroku logs
Expect no errors.
heroku open
You should now see the example Elm app.
See the official guide for deploying Phoenix apps to Heroku: http://www.phoenixframework.org/docs/heroku
I recommend having a look at the elm-brunch plugin and why it's a great idea to use it.
NB This template reflects my personal preference of tools. It was built for my own purposes.
That said, feel free to use it at your own peril :) Any feedback, comments, bug reports, etc. are highly welcome.
I will try to keep the template up to date with the latest releases of Phoenix, Elm, etc.