Skip to content

Code examples and demonstration apps built in Phoenix 1.3

License

Notifications You must be signed in to change notification settings

smeade/hellophoenix

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Hello Phoenix

Code examples and demonstration apps built in Phoenix 1.3 while reading through the Phoenix Guides.

A Cheat-Sheet of Sorts

This is not a tutorial. :) I made these code examples in order to have a direct link between content in the guides and code in a working and deployed Phoenix app.

Note that while Phoenix apps are very responsive, these demo apps are deployed to free Heroku dynos which go to sleep after 30 minutes of inactivity. When you click on a demo link, there will be a delay while the dyno activates.

Contact: @smeade.

Guides

Testing

Deployment

Deploying each branch to its own Heroku app

We'll create a demo app for each branch of this repo. To do so, we need to:

  1. Tell Phoenix of the updated Heroku URL
  2. Create the Heroku application and add buildpacks
  3. Create environment variables in the new app in Heroku
  4. Add a git remote and deploy

Tell Phoenix of the updated Heroku URL

Update the host in prod.exs.

url: [scheme: "https", host: "phx-010-ecto.herokuapp.com", port: 443],

Create the Heroku application and add buildpacks

$ heroku create phx-010-ecto --buildpack "https://github.com/HashNuke/heroku-buildpack-elixir.git"
$ heroku buildpacks:add https://github.com/gjaldon/heroku-buildpack-phoenix-static.git -a phx-010-ecto

Create environment variables in Heroku

$ heroku addons:create heroku-postgresql:hobby-dev -a phx-010-ecto
$ heroku config:set POOL_SIZE=18 -a phx-010-ecto
$ mix phx.gen.secret
$ heroku config:set  -a phx-010-ecto SECRET_KEY_BASE="insertkeyhere"

Add a git remote and deploy

$ git remote add phx-010-ecto https://git.heroku.com/phx-010-ecto.git
$ git push phx-010-ecto phx-010-ecto:master
$ heroku open -a phx-010-ecto

Migrate database as required

heroku run "POOL_SIZE=2 mix ecto.migrate" -a phx-011-contexts

Learn more