X Tutup
The Wayback Machine - https://web.archive.org/web/20200917205315/https://github.com/nodejs/docker-node/pull/1283
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reduce image size #1283

Open
wants to merge 2 commits into
base: master
from
Open

Reduce image size #1283

wants to merge 2 commits into from

Conversation

@Aschen
Copy link

Aschen commented Jun 26, 2020

What this PR do?

This PR reduce the alpine image size by 20% from 117MB to 93.5MB.

This PR reduce the alpine image size by 7,5% from 117MB to 108MB.

  • strip node binary (10MB)
  • remove c headers (3.9MB)
  • remove documentation (~6MB)
  • remove unnecessary files such as LICENSE
  • yarn compile cache (2.3MB)

If those changes are ok for you, I will do the same for other images.

@Aschen Aschen force-pushed the kuzzleio:reduce-alpine-image-size branch from 747e42c to b0b43b6 Jun 26, 2020
@Aschen Aschen force-pushed the kuzzleio:reduce-alpine-image-size branch from b0b43b6 to 116fcfa Jun 26, 2020
@nschonni
Copy link
Member

nschonni commented Jun 27, 2020

I don't think removing LICENSE files arbitrarily is safe, as some license require the text to be distributed with the code.

@Aschen
Copy link
Author

Aschen commented Jun 27, 2020

You're right, I will keep the license files.
About stripping Node binary I don't think it's a good idea after all because some observability tools may rely on debug symbols (see this comment nodejs/build#2367 (comment))
What do you think?

@mmarchini
Copy link
Member

mmarchini commented Jun 27, 2020

It's probably best to not strip the binary. Maybe on the slim image, but even then I'm not sure. Users who need an image smaller than alpine or slim can either delete the unnecessary files from this image on a new layer, or they can build one from scratch using our Dockerfiles as base. I'd be curious which use cases require such savings on a dependency image (which is only downloaded once per version), since those are usually more worth on final images (which are usually significantly bigger and built many times).

remove c headers

This means users who install native modules will need to download the headers every time they build their images, so the tradeoff is 3.9MB on the base image vs. increased build time for all users who need headers.

@mmarchini
Copy link
Member

mmarchini commented Jun 27, 2020

Documentation seems fine to remove IMO? All others can cause some impact to our users.

If we're moving forward with this we'll probably also need to remove it from the other alpine images and the slim images (the gains on the normal image would be very small). Also, would it need to be semver-major and thus wait for v15? If not we can do this for v10 and v12 as well.

@Aschen
Copy link
Author

Aschen commented Jun 29, 2020

@mmarchini What about the yarn compile cache?

@mmarchini
Copy link
Member

mmarchini commented Jun 29, 2020

I'm not familiar with yarn enough to know how impactful removing it would be to our users, so I'll defer to others to answer that

@Aschen
Copy link
Author

Aschen commented Jul 21, 2020

As far as I can see the /tmp/v8-compile-cache is used to speed up a little yarn loading time: https://www.npmjs.com/package/v8-compile-cache (from 153ms to 113ms)

&& yarn --version \
# remove unnecessary files
&& rm -rf \
/tmp/v8-compile-cache-*

This comment has been minimized.

@navarroaxel

navarroaxel Sep 16, 2020

Why not?

Suggested change
/tmp/v8-compile-cache-*
/tmp/*

This comment has been minimized.

@Aschen

Aschen Sep 17, 2020 Author

Usually I'm not comfortable to use a wildcard but since it's the tmp folder it should be ok.

@Aschen
Copy link
Author

Aschen commented Sep 17, 2020

@mmarchini About the cache the choice is between some performance gain for some packages or a 2.3 MB gain in image size.
image

My thought are it's better to reduce the image size for everyone than improving the perf for certain packages

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

4 participants
You can’t perform that action at this time.
X Tutup