Setting up a Node.js production environment and the continuous deployment pipeline for that is not a trivial task to do. Also, if you don't have enough DevOps personnel, it may be impossible to achieve.

In this article, I am going to show you how you can easily setup a build pipeline, a staging and a production environment. The process shouldn't take more than a couple of hours.

What We Are Going to Build

By the end of this tutorial, you will be able to set up your production Node.js environment. This will include a continuous delivery (CD) tool, a staging and a production environment where successful builds will be automatically deployed to the staging environment.

Before deploying to production, human interaction is needed to verify if everything is ok.

node.js production environment pipeline

Tools Involved

For this setup, we are going to use the following products:

Codeship

Heroku

CloudFlare

GitHub

Why Codeship?

Codeship is a continuous delivery tool that runs your tests and deploys your application to different cloud providers - like Heroku.

It makes configuring of pipelines really easy, you can think of it like Jenkins, but with a more intuitive UI - but also a more limited feature set.

Why Heroku?

Heroku is a platform as a service that runs your applications, whether it is written in PHP, Ruby or Node.js.

Heroku has a friendly pricing model; you can easily extend its functionality with third-party add-ons, like databases. They also provide lots of security features out of the box. Long story short, while you don't have / can't afford someone dealing with your infrastructure full-time, they got your back.

Why CloudFlare?

CloudFlare protects and accelerates your web applications by providing a CDN (Content Delivery Network), DNS, optimized delivery of web content (like minifying JS/CSS content). After you set up CloudFlare with your domain, they also provide SSL certificates for you.