TL:DR; Not all node images are equal. Just because one doesn't work doesn't mean another won't.

I want to deploy a container running the highcharts node export server, which should be super easy and is exactly what Docker was designed for.

I found an existing github project that already has this functionality. It runs perfectly but:

1) The node version is very old (7.7)

2) It is based on a large Linux container at 800MB

So I thought it would be easy to update the version and also use something like Alpine or Buster-slim to make it better. Note that I have already installed the server onto a new installation of node latest version on Windows server and it does run as-designed.

First problem

I tried using a really new image (15.12-buster). When I did this, it built OK but I got some sort of node error when calling the server: "TypeError: worker.restart(...).work is not a function".

I tried reducing the version one-by-one assuming that the export server was based on some older functionality (even though I had installed it fine on node 15 recently). No dice. There are hundreds of tags for node images and not all versions include all versions of the linux kernels (obviously) but eventually I got back to using the original 800MB 7.7 bare image, just to prove I hadn't gone mad.

Second problem

I then tried the Alpine image. This really is the daddy because it is really small (100MB) and suited to a really small node app. Or not.

Alpine uses a different c library to Ubuntu/Debian (for size presumably), but this doesn't work with Phantomjs, which although derided in some circles is used by the export server that I need to install.

I tried a hack to download and install it directly before running npm install but for some reason, npm install didn't find the installed version and tried to download and install it. This lead to my...

Third problem

The node base images have everything installed as root, including the global node modules, but NOT /home/node which is the location you are supposed to install your apps at.

This was really confusing because running npm install caused permission errors even though I was running as root (afaik) and installing a global module. Since the permission error is logged without showing which user was denied, it was hard to know if I had to fiddle with the node user or whether it was another issue that looked like a permissions issue: for example a missing directory that needed creating.

Fourth problem

I then thought I would try each different image to find one that worked and was the smallest. I attempted to use the slim/buster-slim libraries and then got an error with bzip2. It seems this is not installed on buster or buster slim so I added an apt-get update and install but then had the same permission problem with it trying to install.

Fifth problem

When I tried the wheezy image (using the old version of node), running npm install segfaulted. An issue I found was along the lines of "never mind, we won't be supporting this any more", so no real help there.

Eventually

I had to accept that for now, I had to use the original old version at 800MB and just deal with it! I could probably spend some more time and try and build up my own node image manually but I'm not sure if that is time worth spending since it is only to save a couple of GB.

Conclusion

Although I have reasonable experience with Docker and Linux, this has used up a couple of hours for something that should have been much easier than this. You might need to build your own images from alpine or you might have to spend a lot of time trying different images, it is up to you!