IBM/container-service-getting-started-wt

Slenderize Docker images by building upon Alpine Linux

apophizzz opened this issue · 4 comments

Hey there,
I'd like to propose a change related to the base images used in the Node.js apps' Dockerfiles. Since they are currently derived from the node:6 Docker image, which is about 660MB in size, the final application image shows a total size of about 700MB.


$ docker images node:6 --format "table {{.Repository}}\t{{.Tag}}\t{{.Size}}"
REPOSITORY          TAG                 SIZE
node                6                   662MB

$ docker images registry.ng.bluemix.net/hdmdemo/helloworld:1 --format "table {{.Repository}}\t{{.Tag}}\t{{.Size}}"
REPOSITORY                                   TAG                 SIZE
registry.ng.bluemix.net/hdmdemo/helloworld   1                   702MB

Swapping the base image and using node:6-alpine instead reduces the overall image size by about 640MB:

$ docker images node:6-alpine --format "table {{.Repository}}\t{{.Tag}}\t{{.Size}}"
REPOSITORY          TAG                 SIZE
node                6-alpine            54.7MB

$ docker images registry.ng.bluemix.net/hdmdemo/helloworld:alpine-1 --format "table {{.Repository}}\t{{.Tag}}\t{{.Size}}"
REPOSITORY                                   TAG                 SIZE
registry.ng.bluemix.net/hdmdemo/helloworld   alpine-1            62.2MB

The modified Dockerfile I used for my experiments looks like this:

FROM node:6-alpine
COPY app.js .
COPY package.json .
RUN npm install
EXPOSE  8080
CMD node app.js

This makes creating and uploading images for the IBM Cloud tutorials much faster.
I'd gladly volunteer to prepare the necessary Dockerfile patches as a PR if you also consider this a valuable change.

Cheers,
Patrick

Thanks @apophis90. I'll take a look at this

We've updated the image to use IBM's ibm-node image. While not as small as alpine, it is smaller than the base node image, so it should help a bit with the size of the original.

Thanks again for opening this issue. Please feel free to open other issues or PRs as you work through the labs.

Thx @bhpratt.
Saw you changed the base image for Lab 1, while Lab 2 still has the old one in its Dockerfile. Is that on purpose?

@apophis90 Not intentional. Thanks for the catch. I'll update that one as well.