dwyl / learn-heroku

:checkered_flag: Learn how to deploy your web application to Heroku from scratch step-by-step in 7 minutes!
153 stars 395 forks source link

How to deploy a Phoenix Web Application to Heroku? #17

Closed nelsonic closed 6 years ago

nelsonic commented 6 years ago

The example in this repo/tutorial is a basic Node.js (static) page which is a good start ... Most apps will have a bit more functionality ... Given our choice of "stack": https://github.com/dwyl/technology-stack I feel it would be good to have a walkthrough of deploying a Phoenix App.

Todo:

nelsonic commented 6 years ago

Sample (successful) Heroku Build log:

-----> Elixir app detected
-----> Checking Erlang and Elixir versions
       WARNING: elixir_buildpack.config wasn't found in the app
       Using default config from Elixir buildpack
       Will use the following versions:
       * Stack heroku-16
       * Erlang 20.1
       * Elixir 1.5.0 
-----> Will export the following config vars:
DATABASE_URL
SECRET_KEY_BASE
       * MIX_ENV=prod
-----> Stack changed, will rebuild
-----> Fetching Erlang 20.1
-----> Installing Erlang 20.1 (changed)
-----> Fetching Elixir v1.5.0 for OTP 20
-----> Installing Elixir v1.5.0 (changed)
-----> Installing Hex
* creating /app/.mix/archives/hex-0.17.3
-----> Installing rebar
* creating /app/.mix/rebar
* creating /app/.mix/rebar3
-----> Fetching app dependencies with mix
Resolving Hex dependencies...
Dependency resolution completed:
  connection 1.0.4
  cowboy 1.1.2
  cowlib 1.0.2
  db_connection 1.1.2
  decimal 1.4.1
  ecto 2.2.7
  gettext 0.14.0
  mime 1.2.0
  phoenix 1.3.0
  phoenix_ecto 3.3.0
  phoenix_html 2.10.5
  phoenix_pubsub 1.0.2
  plug 1.4.3
  poison 3.1.0
  poolboy 1.5.1
  postgrex 0.13.3
  ranch 1.3.2
* Getting phoenix (Hex package)
* Getting phoenix_pubsub (Hex package)
* Getting phoenix_ecto (Hex package)
* Getting postgrex (Hex package)
* Getting phoenix_html (Hex package)
* Getting gettext (Hex package)
* Getting cowboy (Hex package)
* Getting cowlib (Hex package)
* Getting ranch (Hex package)
* Getting plug (Hex package)
* Getting mime (Hex package)
* Getting connection (Hex package)
* Getting db_connection (Hex package)
* Getting decimal (Hex package)
* Getting ecto (Hex package)
* Getting poolboy (Hex package)
* Getting poison (Hex package)
-----> Copying hex from /app/.mix/archives/hex-0.17.3
-----> Compiling
==> connection
Compiling 1 file (.ex)
Generated connection app
==> gettext
Compiling 1 file (.yrl)
Compiling 1 file (.erl)
Compiling 20 files (.ex)
warning: function Kernel.ParallelCompiler.async/1 is undefined or private
  lib/gettext/compiler.ex:281
Generated gettext app
===> Compiling ranch
==> poolboy (compile)
Compiled src/poolboy_worker.erl
Compiled src/poolboy_sup.erl
Compiled src/poolboy.erl
==> decimal
Compiling 1 file (.ex)
Generated decimal app
warning: String.strip/1 is deprecated, use String.trim/1
  /tmp/build_52101126308d466173905972d8a51123/dwyl-phoenix-chat-example-1c308f7/deps/poison/mix.exs:4
==> poison
Compiling 4 files (.ex)
warning: Integer.to_char_list/2 is deprecated, use Integer.to_charlist/2
  lib/poison/encoder.ex:173
Generated poison app
==> db_connection
Compiling 23 files (.ex)
Generated db_connection app
==> phoenix_pubsub
Compiling 12 files (.ex)
Generated phoenix_pubsub app
===> Compiling cowlib
src/cow_multipart.erl:392: Warning: call to crypto:rand_bytes/1 will fail, since it was removed in 20.0; use crypto:strong_rand_bytes/1
===> Compiling cowboy
==> mime
Compiling 1 file (.ex)
Generated mime app
==> plug
Compiling 1 file (.erl)
Compiling 44 files (.ex)
Generated plug app
==> phoenix_html
Compiling 8 files (.ex)
Generated phoenix_html app
==> phoenix
Compiling 74 files (.ex)
Generated phoenix app
==> postgrex
Compiling 62 files (.ex)
Compiling lib/postgrex/default_types.ex (it's taking more than 10s)
Generated postgrex app
==> ecto
Compiling 70 files (.ex)
Compiling lib/ecto/repo/queryable.ex (it's taking more than 10s)
Compiling lib/ecto/adapters/postgres/connection.ex (it's taking more than 10s)
Generated ecto app
==> phoenix_ecto
Compiling 6 files (.ex)
Generated phoenix_ecto app
==> chat
Compiling 15 files (.ex)
Generated chat app
-----> Creating .profile.d with env vars
-----> Writing export for multi-buildpack support
-----> Discovering process types
       Procfile declares types     -> (none)
       Default types for buildpack -> web
-----> Compressing...
       Done: 65.6M
-----> Launching...
       Released v5
       https://phxchat.herokuapp.com/ deployed to Heroku