Skip to content

Use debian:*-slim image as base for node:*-slim #618

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

Closed
edmorley opened this issue Jan 29, 2018 · 12 comments
Closed

Use debian:*-slim image as base for node:*-slim #618

edmorley opened this issue Jan 29, 2018 · 12 comments

Comments

@edmorley
Copy link

edmorley commented Jan 29, 2018

Hi!

The slim image variants (for example: node:9.4.0-slim) currently use buildpack-deps:jessie-curl as the image base (which is 72MB).

I was wondering if there was a reason why debian:jessie-slim or debian:stretch-slim (which are 30MB and 22MB respectively) aren't used instead? As a datapoint the official Python images recently made a similar switch (docker-library/python#233).

If this is something people would be open to, I'm happy to create a PR :-)

@chorrell
Copy link
Contributor

It's mostly because we use curl to download the Node.js and yarn binaries.

@edmorley
Copy link
Author

edmorley commented Jan 30, 2018

Thank you for the reply :-)

The slim debian image variants differ in more than just curl - they also exclude a number of superfluous files:
https://github.com/debuerreotype/debuerreotype/blob/master/scripts/.slimify-excludes

As such manually installing curl into the debian:*-slim images would still have a net size win - plus curl could always be treated as a build-time only dependency and uninstalled afterwards (like other official images do).

@chorrell
Copy link
Contributor

That seems pretty compelling, especially the file-size reduction. If we do switch to debian:jessie-slim we might want to keep curl installed just to avoid any breakage for users who expect it to be in the slim image. I don't really see that as a dealbreaker though.

@chorrell
Copy link
Contributor

I looked into this a little bit more. The jessie-curl also includes wget, so dropping that would break the ghost image: https://github.com/docker-library/ghost/blob/master/1/debian/Dockerfile#L8

@tianon
Copy link
Contributor

tianon commented May 17, 2018 via email

@LaurentGoderre
Copy link
Member

Would having jessie-slim plus curl and wget be enough of a size saving to justify the change?

@chorrell
Copy link
Contributor

It didn’t really seem like it when I tried it, but I don’t recall what the size difference was.

@chorrell
Copy link
Contributor

I think maybe we just err on the side of making the image smaller (with curl and the ca certs installed as buildDeps) and try to notify anyone downstream if we can. The ghost image is the only one I'm aware of, so we're covered there I guess :)

@tianon
Copy link
Contributor

tianon commented May 17, 2018

Just did a test of node:10-slim, and the results are pretty compelling IMO:

diff --git a/10/slim/Dockerfile b/10/slim/Dockerfile
index ccd8ece..db9ca55 100644
--- a/10/slim/Dockerfile
+++ b/10/slim/Dockerfile
@@ -1,4 +1,6 @@
-FROM buildpack-deps:jessie-curl
+FROM debian:jessie-slim
+
+RUN apt-get update && apt-get install -y --no-install-recommends ca-certificates curl wget && rm -rf /var/lib/apt/lists/*
 
 RUN groupadd --gid 1000 node \
   && useradd --uid 1000 --gid node --shell /bin/bash --create-home node

Before: ~233MB
After: ~185MB

@LaurentGoderre
Copy link
Member

Nice!

@chorrell
Copy link
Contributor

chorrell commented May 17, 2018

150MB if we put ca-certificates and curl in buildDeps.

@chorrell
Copy link
Contributor

I'm going to do a PR for switching to jessie-slim with curl and wget installed. The savings are pretty decent.

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

No branches or pull requests

4 participants