Skip to content

Deploying to Heroku

Eric M. Dantas edited this page Feb 1, 2017 · 3 revisions

Having your application working locally, now you want to deploy it to Heroku.

To do so, you'll have to do the following:

After you've done that, go to Heroku and create a simple application - give it any name you want.

Head to your MongoDB host, create a DB, a user and a password. Save the generated uri somewhere, you'll need it.

Go back to Heroku, create two config vars (enviroment variables), one named NODE_ENV and the other named MONGOHQ_URL or MONGOLAB_URI (depending on what host you chose). For NODE_ENV, give the value production. For MONGOHQ_URL or MONGOLAB_URI, give the full uri to access your DB, for example: mongodb://<dbuser>:<dbpassword>@SOMEWHERE:SOME_PORT/<dbname>.

Note: If you're using NewRelic, you'll also have to create two other variables: NEW_RELIC_APP_NAME and NEW_RELIC_LICENSE_KEY

Now, using the Heroku toolbelt, run heroku create - that'll create the repositories in heroku for you (git repositories). Note that you can also use heroku git:remote -a NAME_OF_APP_HERE to create a repo for an already existing app.

Lastly, but not leastly, commit everything you have:

$ git add .
$ git commit -am "here we go"

And push it into the heroku remote:

$ git push heroku master

And access the url you've set up in your Heroku account.

Here's an working example using ng-fullstack:

https://issue-97.herokuapp.com/

NOTE: make sure you've run npm run build-dist before deploying - so you have the distribution version of your app deployed.

Clone this wiki locally