docker-node icon indicating copy to clipboard operation
docker-node copied to clipboard

minor image cleanup

Open rockdrilla opened this issue 2 years ago • 8 comments

Description

Perform minor image cleanup.

Motivation and Context

Reduce image size by removing temporary/meaningless files.

Testing Details

I've manually rebuilt node:18-bullseye-slim - all works as expected.

Types of changes

  • [ ] Documentation
  • [ ] Version change (Update, remove or add more Node.js versions)
  • [ ] Variant change (Update, remove or add more variants, or versions of variants)
  • [ ] Bug fix (non-breaking change which fixes an issue)
  • [ ] New feature (non-breaking change which adds functionality)
  • [ ] Breaking change (fix or feature that would cause existing functionality to change)
  • [x] Others (non of above)

Checklist

  • [x] My code follows the code style of this project.
  • [ ] My change requires a change to the documentation.
  • [ ] I have updated the documentation accordingly.
  • [x] I have read the CONTRIBUTING.md document.
  • [ ] All new and existing tests passed.

rockdrilla avatar Apr 10 '23 05:04 rockdrilla

Relates to #1326.

rockdrilla avatar Apr 10 '23 05:04 rockdrilla

This seems like a more slim version of https://github.com/nodejs/docker-node/pull/1283 which is fine. There was discussion of the value of v8-compile-cache there too.

ttshivers avatar Apr 10 '23 18:04 ttshivers

Image may be further reduced with following script:

find /usr/local/lib/node_modules/ -name 'README*' -type f -exec rm -f '{}' +
find /usr/local/lib/node_modules/ -name 'CHANGELOG*' -type f -exec rm -f '{}' +
find /usr/local/lib/node_modules/ -path '*/bin/*.cmd' -type f -exec rm -f '{}' +
find /usr/local/lib/node_modules/ -path '*/test*/*' -type f -exec rm -f '{}' +
find /usr/local/lib/node_modules/ -type d | sort -V | while read -r d ; do
    [ -d "$d" ] || continue
    find "$d/" ! -type d -printf . -quit | grep -Fq . || rm -rf "$d"
done

But I'm not sure does it works with Alpine (i.e. find).

rockdrilla avatar Apr 11 '23 07:04 rockdrilla

How much was the image size reduced by this?

ttshivers avatar Apr 12 '23 00:04 ttshivers

Less than 1 MiB.

rockdrilla avatar Apr 12 '23 02:04 rockdrilla

Hey @rockdrilla,

Thanks for your contribution, and I am sorry for the late review. Are you still interested in revising it to get it merged? We need to modify the Dockerfile templates first and then generate the Dockerfiles with changes automatically.

Let me know if you want my help ;)

PeterDaveHello avatar Apr 08 '24 16:04 PeterDaveHello

Hi @PeterDaveHello, I'm still interested in this PR but I may late to respond too. :)

rockdrilla avatar Apr 08 '24 17:04 rockdrilla

Thanks. Let me know if you have some spare time to resolve the conflicts, or maybe just getting started from the current main branch will be easier, as it's been a while.

PeterDaveHello avatar May 15 '24 20:05 PeterDaveHello