Skip to content

BLD: Decrease size of docker image #61430

New issue

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

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

Already on ? Sign in to your account

Merged
merged 2 commits into from
May 12, 2025
Merged

BLD: Decrease size of docker image #61430

merged 2 commits into from
May 12, 2025

Conversation

huisman
Copy link
Contributor

This PR reduces the size of the docker image by:

  • combining RUN commands to minimise the number of layers
  • removing the apt lists files to reduce total size
  • use --no-cache-dir when installing with pip

In my tests it reduced the size of the final image with approximately 0.47GB (most of it due to the --no-cache-dir).

  • closes #xxxx (Replace xxxx with the issue number)
  • Tests added and passed if fixing a bug or adding a new feature
  • All code checks passed.
  • Added type annotations to new arguments/methods/functions.
  • Added an entry in the latest doc/source/whatsnew/vX.X.X.rst file if fixing a bug or adding a new feature.

Combining RUN commands to minimise the number of layers and cleaning up the apt lists to reduce total size.
Dockerfile Outdated
Comment on lines 4 to 8
RUN apt-get update && \
apt-get -y upgrade && \
rm -rf /var/lib/apt/lists/*

# hdf5 needed for pytables installation
# libgles2-mesa needed for pytest-qt
RUN apt-get install -y libhdf5-dev libgles2-mesa-dev
RUN apt-get update && apt-get install -y \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Can you combine these two installs?
  2. Can you include --no-install-recommends?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, done. That saves another ~0.16 Gb.

Do note that the --no-install-recommends could impact 'downstream' images based on this image, if they depend on having a recommended library installed.

Combine upgrade and install steps
Add --no-install-recommends option
@mroeschkemroeschke added this to the 3.0 milestone May 12, 2025
@mroeschkemroeschke merged commit 839747c into pandas-dev:main May 12, 2025
43 of 44 checks passed
@mroeschke
Copy link
Member

Thanks @huisman

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

Successfully merging this pull request may close these issues.

2 participants