May 17, 2015


What is it?

A platform as a service (PaaS) that enables developers to build and run applications entirely in the cloud.

Deploy the app

I am going to create an app. I use my nickname as a namespace.

#create remote
heroku create pearpages-test-app
#deploy the code, same code for pushing changes
git push heroku master

Run and instance and open it

heroku ps:scale web=1
heroku open
#view logs
heroku logs

Define a Procfile

Use a Procfile, a text file in the root directory of your application, to explicitly declare what command should be executed to start your app.

web: node index.js

This declares a single process type, web, and the command needed to run it.

Run the app locally

foreman start web

Just like Heroku, Foreman examines the Procfile to determine what to run.

Start a console

When the console starts, it has nothing loaded other than the Nodee.js standard library. From here you can require some of your application files.

heroku run node

How to Create an Angular App Using Yeoman and Deploy It to Heroku

The point here is to tell heroku to run an static server. This is the key code to accomplish this:

var gzippo = require('gzippo');
var express = require('express');
var morgan = require('morgan');
var app = express();

app.use(gzippo.staticGzip("" + __dirname + "/dist"));
app.listen(process.env.PORT || 5000);

Read the follow post to understand it:

How to Create an Angular App Using Yeoman and Deploy It to Heroku

Github Integration

Heroku integrates with GitHub to make it easy to deploy code living on GitHub to apps running on Heroku. When GitHub integration is configured for a Heroku app, Heroku can automatically build and release (if the build is successful) pushes to the specified GitHub repo.

Github Integration

Learn more about Heroku

How Heroku Works

Deploying Node.js Apps on Heroku

Node.js on Heroku