Optimize node images removing the content in /tmp folder
Analyzing the docker layers of node:latest, node:slim and node:alpine images using dive
I found that the Yarn installation adds a /tmp/v8-compile-cache-0 with a size 2.2MiB in all these images and this is not needed for the users of theses images.
node:alpine
node:slim
node:latest

Also, the /var/cache and /var/log folders sounds useless.
Let me know if I can help submitting a PR with
rm -rf /tmp/*
There is an open PR for some of this over here https://github.com/nodejs/docker-node/pull/1283
Not to be rude but why has this not been addressed? To be clear there is nothing the downstream users can do within the standard docker framework to clear tmp of the previous layers even with squash which is still considered experimental.
RUN npm install --omit=dev \
&& npm cache clean --force \
&& rm -rf /tmp/* \
&& rm -rf node_modules/@aws-sdk/client-ec2/dist-types \
&& rm -rf node_modules/@aws-sdk/client-ec2/dist-es \
&& rm -rf node_modules/@types \
&& ls -al /tmp # empty as expected
docker build -t jaspermanager-server . --squash --progress=plain
Inspecting the image still shows /tmp/v8-compile-cache-0
In many ways, this relates to other issues like #777. When you are dealing with slow networks every byte counts.
This issue is now addressed by #2049