pktippa
pktippa

Reputation: 76

node.js docker image for all environments - including production

Currently we are using node:4.2.3 (LTS) docker image which is around 642 MB in size and node_modules around 140 MB in total ~800MB to build our web application docker image.

Publishing these images to our private registry and pulling them all environments becoming a time taken process.

Since we cant reduce the node_modules size( would be helpful if any reducing methods are avail) looking for suggestions to use any other node docker image for all environments - including production.

Upvotes: 1

Views: 271

Answers (1)

KiwenLau
KiwenLau

Reputation: 2581

You can build your own docker images using following Dockerfile:

FROM ubuntu:14.04

RUN sudo apt-get update && sudo apt-get install -y wget

# install node v4.2.6
RUN wget https://nodejs.org/dist/v4.2.6/node-v4.2.6-linux-x64.tar.gz && \
    tar -C /usr/local --strip-components 1 -xzf node-v4.2.6-linux-x64.tar.gz && \
    rm node-v4.2.6-linux-x64.tar.gz 

# install express 4.13.4
RUN npm install [email protected]

Using following command to build the image:

sudo docker build -t ubuntu-node .

The image is only 255MB

REPOSITORY               TAG                 IMAGE ID            CREATED             SIZE
ubuntu-node              latest              7ed1b88adb46        7 seconds ago       255 MB

Of course, you can install any necessary dependencies.

Upvotes: 1

Related Questions