Skip to content

Conversation

huisman
Copy link
Contributor

@huisman huisman commented May 11, 2025

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 GitHub 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
@mroeschke mroeschke added this to the 3.0 milestone May 12, 2025
@mroeschke mroeschke merged commit 839747c into pandas-dev:main May 12, 2025
43 of 44 checks passed
@mroeschke
Copy link
Member

Thanks @huisman

xaris96 pushed a commit to xaris96/pandas that referenced this pull request May 30, 2025
* Decrease size of docker image

Combining RUN commands to minimise the number of layers and cleaning up the apt lists to reduce total size.

* Combine upgrade and install steps

Combine upgrade and install steps
Add --no-install-recommends option
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

Successfully merging this pull request may close these issues.

2 participants