# Elixir Today: Deploying Phoenix App on Heroku

#### 1. Create an app using Phoenix Framework

```
> mix phx.new app-name
> mix ecto.create
> mix ecto.migrate
> npm install --prefix assets

```
#### 2. Initialize local and remote Repository

```
> git init
> git add .
> git commit -m "Initial commit"
> git remote set-url origin <url>
> git push -U main

```

#### 3. Sign up for a Heroku Account
#### 4. Install Heroku CLI
#### 5. Create and Setup a Heroku App

In your terminal.

* via browser

```
> heroku login

```

* via CLI

```
> heroku login -i

```
create heroku app

```
> heroku create

```

In your phoenix app directory

```
> heroku git:remote -a < heroku-app-name >

```

In your phoenix app directory

```
> heroku create --buildpack hashnuke/elixir

```

Create a new file `elixir_buildpack.config` in your app home folder and write this code. Be vigilant with your elixir and erlang versions.

```

# Elixir version
elixir_version=1.12.2

# Erlang version
# https://github.com/HashNuke/heroku-buildpack-elixir-otp-builds/blob/master/otp-versions
erlang_version=24.0.3

```

Create a `Procfile` and write this code

```
web: mix phx.server

```

At this moment, we are going to use Node, npm and Phoenix Static buildpack

```

> heroku buildpacks:add https://github.com/gjaldon/heroku-buildpack-phoenix-static.git

Buildpack added. Next release on < app-name > will use:
  1. https://github.com/HashNuke/heroku-buildpack-elixir.git
  2. https://github.com/gjaldon/heroku-buildpack-phoenix-static.git

```

Create a `phoenix_static_buildpack.config` file and write this code.

```
# Node.js version
node_version=10.20.1

```

#### Making our Project Ready for Heroku

[Refer on the Phoenix Document](https://hexdocs.pm/phoenix/heroku.html#making-our-project-ready-for-heroku)


#### Create Env variables on Heroku

[Refer on the Phoenix Document](https://hexdocs.pm/phoenix/heroku.html#creating-environment-variables-in-heroku)


#### Deploy Time


```
> git add .
> git commit -m "deployment time"
> git push 
> git push heroku main

```

#### References

[Phoenix Framework Docs](https://hexdocs.pm/phoenix/heroku.html#content)
[Heroku Docs](https://devcenter.heroku.com/articles/heroku-cli)

> Did I lack something on this write up? comment down below. 




> Happy Coding!
