Heroku & App Deployment

I attended a cloud training at my office recently for basic understandings of cloud & the training was really an eye opener for me in the cloud world. Further, I am involved in a POC project where we are deploying our node-express application in Heroku. So I thought of penning down my learnings in this article.

What is Cloud Computing?

Cloud computing is a way of delivering services over network. It is a ubiquitous IT services over the network.

 What are Cloud Services Characteristics?

  • On Demand Self Service Provisioning
  • Broad Network Access
  • Resource Pooling
  • Measured & Metered Service
  • Rapid Elasticity

What are the types of Service model available in Cloud?

  • Saas (Software as a Service)
  • Paas (Platform as a Service)
  • Iaas (Infrastructure as a Service)

What is Paas?

Paas is an application development and deployment environment on the cloud where you can run your application without the hassle of maintaining the hardware and software infrastructure.

Heroku:

Heroku is an example of Paas.

Setup:
Download HerokuToolbelt for

  • Mac OS X
  • Windows
  • Debian/Ubuntu
  • Standalone

This provides you access to the Heroku Command Line utility, as well as git and Foreman, tools you’ll use in later steps.

Link: https://devcenter.heroku.com/articles/getting-started-with-nodejs#set-up

Login:
$ heroku login

Prepare the App (without DB Interaction):
$ git clone https://github.com/heroku/node-js-getting-started.git
$ cd node-js-getting-started

Deploy the App:
$ heroku create
$ git push heroku master

Now visit the app at the URL generated by its app name. As a handy shortcut, you can open the website as follows:
$ heroku open

Deploying Local folder(without DB Interaction):
cd <<FOLDER_NAME>>
$ git init
It initialized empty Git repository in .git/
$ git add .
$ git commit -m “committing first time ”
$ heroku create
$ git remote -v
It verifies the remote in your git configuration
$ git push heroku master

Concepts to understand:

What is a Procfile?

A Procfile is a text file which is put in the application root directory. It lists the process types such as ‘web’, ‘worker’ in an application.

Define a Procfile:

web: node app.js

The above line declares a singles process type, web and the command required to run it. It is important to declared the name web here as this process will be attached to the HTTP routing stack of Heroku and will receive web traffic upon deploying.

You can add more than one processes in this file.

web:

This special process type receives HTTP traffic from Heroku’s routers.

Package.json:

Create a package.json file to list download all your node module dependencies. When you deploy your app in Heroku, the platform will run ‘npm install’ command to install all the specified node modules.

Foreman:

It is a service that manages processes (specified in Procfile) for an application to run properly. In other words, it manages profile-based applications. It will start all of the processes associated with your app and display stdout and stderr of each process. Processes are color-coded by type to make them easy to read. $PORT will be automatically assigned by foreman and made available to each underlying process.

Push Local Changes:

With the following three lines, you can push your local updates to Heroku:

$ git add – A
$ git commit -m “comments”
$ git push heroku master

In the second part of ‘Heroku & App Deployment’, we will be talking about database interaction using MongoDB.

6 thoughts on “Heroku & App Deployment

Add Comment Register



Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">