Posts

Showing posts from 2016

Minimize your nodejs docker image size with these hacks

Image
Note: If you are developing and deploying applications using node.js and docker, this is a post you must not miss.




Docker images have layered filesystems which the docker engine automatically reuses from other images if they are similar. So, in order to even save more filesize from your images, you can follow these steps:
1. Use alpine images Docker images usually come with an alpine image as well. Alpine images are stripped down linux kernel which has nothing but a barebones OS container in it. I would be writing more about the alpine linux in a future post. But the images of alpine linux do not exceed 5 MB which is a huge life saver when you shipping images to and fro your teams and to production.
Node has a alpine version from its official repository with various versions that are tagged. You can have a look at https://hub.docker.com/r/mhart/alpine-node/
Please be aware that they are just plain node and it will not even contain npm. You can install npm within it as required and the…

node.js npm install --save. What does the --save mean?

Image
Have you ever wondered what does "--save" does in the npm install command?

It adds a line into the dependencies.json file of the current project with package name which you are trying to install and saves you a few manual labor of writing it yourself.

Try it out yourself.

$ npm install sequelize --save