Deploy Express(node) app on heroku

September 11, 2013

Reading time ~1 minute

Prerequisite

  • created heroku account.
  • installed heroku toolbelt.
  • develop express app and commit git repository (e.g. github).

Process (Command)

1. login by using heroku command

heroku login

Input email address and password of heroku account.

Enter your Heroku credentials. Email: XXXXXX Password (typing will be hidden):

2. create public key

ssh-keygen -t rsa -C "mail address"
heroku keys:add ~/.ssh/id_rsa.pub

3. clone Express app

$ git clone XXXXXXXXXXXXX ${appname} $ cd ${appname}

4. edit .gitignore

vi .gitignore

Add follows text in .gitignore.

node_modules

5. edit package.json

You have to add follows settings to deploy your app on heroku in package.json.

vi .gitignore
vi package.json
"engines": {
    "node": "XXX",
    "npm": "XXX"
}

6. create web server process setting config

On hreoku, You have to create Procfile. It is process configuration file you will start your app.

vi Procfile

Write follows text.

web: node app.js

8. create app on heroku

heroku create ${appname}

Creating ${appname}… done, stack is cedar http://${appname}.herokuapp.com/ | git@heroku.com:${appname}.git Git remote heroku added

9. push Express app code to heroku git repository

When you push code to heroku git repository. All npm dependency resources are installed.

git push heroku master

Reference

Other heroku command

start app on local

foreman start

check web server process

heroku ps:scale web=1

check heroku logs

Including access log.

heroku logs

run command on heroku

heroku run ${command}

add ticket number to git commit automatically

Most of ticket tracker like Github, pivotal tracker have function to connect your commit to ticket(story).But every time when you commit ...… Continue reading

I will build frontend and backend separately

Published on September 28, 2016

order of angular controller's initialisation

Published on October 05, 2015