A smaller Docker image for Node.js
https://hub.docker.com/r/urbanmassage/node/
Here at Urban Massage, we use Docker to containerise + deploy all of our websites & services.
The majority of our apps are written in Node.js, and like a lot of other engineering teams, we picked the default Node.js Docker image.
With small microservices, build times are naturally pretty low, which is great — however we quickly realised that a significant amount of time was being taken up dealing with fetching + pushing Docker images, as the default Node.js Docker image is nearly 200mb!
What about native modules?
As long as you build on the same architecture as the image, you’ll be fine — your built modules will be copied into the image.
We use CircleCI for our build process, which uses Ubuntu, so we just make sure to run npm install
on the build machine, before the docker build
runs.
How do I use it?
All you need to do is make your base image urbanmassage/node:VERSION-slim
(where VERSION is the node version you wish to target). We currently have tags for a number of major versions ranging from 0.10
all the way to 8
. See below for an example Dockerfile
:
FROM urbanmassage/node:8-slimWORKDIR /usr/src/myservice
COPY . /usr/src/myservice
Want to see the code?
Take a look here — https://github.com/urbanmassage/docker-node