Deploying my little node.js server to Heroku

Once I got every piece of my app in node.js working. 
I though on deploying  and the best way to do so for me for the scalability and easiness only Heroku comes to my mind:











So lets prepare the environment:

First we open an account on https://www.heroku.com/

Once we have it we need to install the Heroku client the tools for making a deploy https://toolbelt.heroku.com/

Now lest start...

Lets strep into the folder :
>cd myapp

Add everyting to git:
>git init
>git add .
>git commit -m "first commit"

In case of not having an app 
>heroku create

In the case of having an app lets add it wit the name
>heroku git:remote -a myapp

The app needs two things before the upload a:  


  • Procfile : A single file indicating wich file the server must start, with the command web: node server.js 

  • And a Package.json a json structured file indicating name version and package dependencies it must be something like this
        {
            "name": "NodejsServer",
            "version": "0.0.1",
            "dependencies": {
                "express": "3.1.x"
            },
            "engines": {
                "node": "0.10.x",
                "npm": "1.2.x"
            }
        }


Now lets deploy, it's so simple as this...
>git push heroku master

Heroku alone will install the dependencies via the data in the Package.js and then run the app from server.js as it says in the Procfile.


Happy deploy.... bye!

Comments

Popular posts from this blog

Free DNS setup for a domain showing a Blogger web page

I hate the PDF format