a blog for those who code

Tuesday 22 December 2015

Automated Deployment of Nodejs Application

In this post we will be discussing about automated web application deployment using Shipit in Node.js. According to Shipit, it is an automation engine and a deployment tool written for node / iojs. ShipIt was built to be a Capistrano alternative for people who don't know ruby, or who experienced some issues with it.


npm install -g shipit-cli
npm install --save-dev shipit-deploy

shipit-deploy : It is a set of deployment tasks for Shipit based on git and rsync commands.

PC : https://github.com/shipitjs/shipit

Getting Started : Creating Deployment file

Then we need to create our deployment file (shipitfile.js)

module.exports = function(shipit) {

  shipit.initConfig( {
    default: {
      workspace: '/tmp/workspace',
      deployTo : '/tmp/deployto',
      repositoryUrl: 'GitHub Reporsitory URL',
      ignores: ['.git', 'node_modules'],
      keepReleases: 2,
      deleteOnRollback: false,
      key: 'path/to/key',
      shallowClone: true
    dev: {
      servers: 'devserver.com'
    prod: {
      servers: 'prodserver.com'

  shipit.blTask('build', function() {
   //build the project

In the ShipIt Configuration file we need to add some default parameters to begin with, they are :

workspace : ShipIt uses to prepare to deploy, will wipe of folder after deployment
deployTo : where the deployment file will be going
repositoryURL : the github repository
ignores : an array of what to ignore from your repository
keepReleases : how many releases to store on the server before deleting them
key : key to login to github
shallowClone : to perform shallow clean or not

We have also used tasks which we will do to build the project everytime before deployment. We can even use grunt to build our project before deployment.

For Deployment

npm dev deploy // deployment to dev server
npm prod deploy // deployment to prod server

Please Like and Share CodingDefined.com Blog, if you find it interesting and helpful.

No comments:

Post a Comment