Live data from Hacker News

Show HN: Smallest Node.js Docker images

github.com

1–10 of 66 posts

Re: Show HN: Smallest Node.js Docker images

#3
A scratch container doesn't even have busybox in it, does it? If not, this wouldn't be able to run npm, much less install anything which has bindings to other libraries.

Definitely a cute experiment, but probably of limited real-world use. I wonder what the smallest _practical_ node container would look like?

Re: Show HN: Smallest Node.js Docker images

#4

A scratch container doesn't even have busybox in it, does it? If not, this wouldn't be able to run npm, much less install anything which has bindings to other libraries. Definitely a cute experiment, but probably of limited real-world use. I wonder what the smallest _practical_ node container would look like?

I suppose you could apply the same builder/scrstch separation as this Dockerfile and install using npm/yarn/etc and copy over the result

It's certainly only practical when every byte matters. At that point it might also make sense to prebundle the dependencies and copy that over.

It'd be interesting to see whether this becomes relevant if serverless-like constraints suddenly apply to a Docker cloud service

Re: Show HN: Smallest Node.js Docker images

#5

A scratch container doesn't even have busybox in it, does it? If not, this wouldn't be able to run npm, much less install anything which has bindings to other libraries. Definitely a cute experiment, but probably of limited real-world use. I wonder what the smallest _practical_ node container would look like?

I suppose you could apply the same builder/scrstch separation as this Dockerfile and install using npm/yarn/etc and copy over the result It's certainly only practical when every byte matters. At that point it might also make sense to prebundle the dependencies and copy that over. It'd be interesting to see whether this becomes relevant if serverless-like constraints suddenly apply to a Docker cloud service

wait, do you mean adding another layer for npm installing other deps?

Re: Show HN: Smallest Node.js Docker images

#6

A scratch container doesn't even have busybox in it, does it? If not, this wouldn't be able to run npm, much less install anything which has bindings to other libraries. Definitely a cute experiment, but probably of limited real-world use. I wonder what the smallest _practical_ node container would look like?

I suppose you could apply the same builder/scrstch separation as this Dockerfile and install using npm/yarn/etc and copy over the result It's certainly only practical when every byte matters. At that point it might also make sense to prebundle the dependencies and copy that over. It'd be interesting to see whether this becomes relevant if serverless-like constraints suddenly apply to a Docker cloud service

That's exactly what the README suggests to do under 'Usage'. First it says 'FROM node', which is the regular 'fat' image. In this image it then runs `npm install`. Further on there is another 'FROM' which starts from the minimal image and copies over all the JS code (including the node_modules directory which has been populated by npm) from the 'fat' image (this of course would fail for bindings that require libraries outside the node_modules directory, although it is relatively easy to add more COPY statements to also put these in the appropriate locations).

Re: Show HN: Smallest Node.js Docker images

#8

Earlier quoted context omitted.

I suppose you could apply the same builder/scrstch separation as this Dockerfile and install using npm/yarn/etc and copy over the result It's certainly only practical when every byte matters. At that point it might also make sense to prebundle the dependencies and copy that over. It'd be interesting to see whether this becomes relevant if serverless-like constraints suddenly apply to a Docker cloud service

wait, do you mean adding another layer for npm installing other deps?

No, doing npm install in a different container and copying over the result. Docker has multi-stage build, which allows using a container to build and copying over in a different result container..

I suspect this could be relevant many place, keeping images small also hardens security.

Re: Show HN: Smallest Node.js Docker images

#10
The new game of Docker Golf. I once spent like a day trying to debug an issue with pruning dev dependencies from my prod docker image before I stopped to realized how much money I was wasting to save $0.0001 of cloud disk space. It is kinda fun though.
Post reply on HN