Dockerizing Node.js
Let’s walk through a Node.js server development process:
- Install the newest Node.js version
- Install a database for your app (Mongo? CouchDB? MySQL?)
- Maybe add ElasticSearch if you want to add some super-fast queries
- Test your app on your machine
- Deploy it
- Watch it fail in production
Well, we all walked this path at least one time, right?
Developing a Node.js app sometimes can be challenging, ’cause you may need a lot of external dependencies (databases, search engines, etc) and sometimes you only test it on your local environment, with different versions of a X database, or the Y service… and then it crashes in production, ’cause the environment is totally different.
Introducing Docker
Docker is a simple but powerful OpenSource project which helps you to develop and deploy any software in any language on a container, which is basically a kind of Virtual Machine.
With Docker, you can run any software/language without even installing it on your machine!
Let’s see an example:
You’ve developed a new incredible chat app with the following stack:
- Database: CouchDB