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

The base image is too huge #97

Closed
alexjurkiewicz opened this issue Feb 24, 2021 · 3 comments
Closed

The base image is too huge #97

alexjurkiewicz opened this issue Feb 24, 2021 · 3 comments

Comments

@alexjurkiewicz
Copy link

This base image is almost 1gb. That's crazy! It takes 10-30secs to download and extract this image on CircleCI, which makes jobs much slower than they have to be.

Almost half the space is spent on Docker & associated tools. I don't think these are used by the majority of CircleCI jobs. They should be moved to a -docker variant tag of this image.

Another few hundred megs is spent on C/C++ compiler infrastructure. This must be even less useful, I think you could remove it entirely.

Then there are a lot of silly mistakes. Installing vim instead of vim-tiny costs nearly 100mb. Installing software-properties-common adds a similar amount of disk.

Are you interested in a pull request to drag this image back to a sensible size?

@alexjurkiewicz
Copy link
Author

The base image is 1.04gb.

  1. Removing docker & docker-compose saves 466mb
  2. Removing C/C++ toolchain (autoconf, build-essential, pkg-config, software-properties-common) saves 234mb
  3. Adding --no-install-recommends to main apt-get install saves 10mb
  4. Replacing vim with vim-tiny saves 53mb
  5. Removing dockerize saves 10mb
  6. Removing maria/pg libs saves 55mb

Final size is 212mb.

Packages you might want to re-add:

  • python3-minimal is 25mb (+10%)
  • maria/pg libs are +55mb (+25%)

@FelicianoTech
Copy link
Contributor

Hi Alex,

Thank for opening this issue and all of the thought you put into it. I agree with your sentiment however I do want to explain that our philosophy on CI focused Docker images differs a bit from a production Docker image. We run over 35 million builds a month with customers doing everything in the world you could image. There's a balance we need to strike with the size of the image vs pre-installing tools that will help a majority of users. With Docker layer caching, it's often that although the image is larger, it's ultimately faster for the majority of users using Convenience Images.

For example, "Removing C/C++ toolchain", a lot of other Convenience Images need these tools for compiling what's in their image. Docker, Docker Compose, and dockerize are all frequently used tools on CircleCI. Especially Docker itself. It's ingrained in our documentation, some sample projects, and many tools. Removing them is just not currently an option.

There are good points you've made. For example, using --no-install-recommends will save us space in the image and is something we're going to do. We have an existing Issue for that already (#86). It's not completed yet because of backwards compatibility issues. This change will remove a number of packages that we need to properly communicate to customers before we make the change. It is on the list though.

vim-tiny - This is also a good suggestion. I opened a PR for it today (#99). Good catch.


Thank you for the suggestions. I'm going to close this Issue but we'll be paying attention to the size of images.

@alexjurkiewicz
Copy link
Author

Thankyou for the response! Sorry for my slow reply.

You pointed out that it's impossible to make major changes (like removing Docker/build-essential) to such a widely used image. That is very true, and I should have realised it.

But I think you can remove these things from an image variant. For example, cimg/base:stable-slim is the same image without Docker or the build-essential. The existing image cimg/base:stable would be unchanged.

I think most cimg/base users would move to -slim variants happily for faster CI builds. You have the stats, maybe cimg/base is used by 95% C++ CI projects. I don't think so though :)

For example, "Removing C/C++ toolchain", a lot of other Convenience Images need these tools for compiling what's in their image.

If the toolchain is used to build other sub-images, it doesn't have to remain in the image for everyone to download. I am sure you are familiar with multi-stage build process:

FROM debian:stable as builder
RUN apt install build-essential
RUN wget redis.org/stable.tar.gz && ...

FROM cimg/base:stable as builder
COPY --from=builder /usr/local/redis /usr/local/redis

I actually couldn't see any cimg images that rely on C/C++ compilation, so I couldn't give you a real world example here. But I will happily write one if you point me at a use-case.

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

No branches or pull requests

2 participants