Skip to content
This repository was archived by the owner on Mar 15, 2022. It is now read-only.

improve size by not having tgz in the image #10

Merged
merged 1 commit into from
Sep 26, 2020
Merged

improve size by not having tgz in the image #10

merged 1 commit into from
Sep 26, 2020

Conversation

asottile
Copy link
Member

I noticed that the image size was a bit large so I looked into why that is

There's 1.04 GB from the base image so not much that can be improved there -- however I noticed that the .tgz sources are in the image so they're essentially bloat.

Docker is a layered filesystem so if you add contents in a layer it will live with the image forever (even if you delete it in a future layer, actually deleting it in a future layer makes the image slightly larger since deletion is implemented via whiteout files)

So I moved the source acquisition inside the layer where the pythons are installed and this reduced the overhead disk usage pretty dramatically.

Here's the docker history from the current image which is on dockerhub:

$ docker history docker.io/pypywheels/manylinux2010-pypy_x86_64
ID            CREATED        CREATED BY                                     SIZE     COMMENT
8373e8655e34  2 months ago   /bin/sh -c #(nop)  CMD ["/bin/bash"]           0 B      
<missing>     2 months ago   /bin/sh -c bash build_scripts_pypy/install...  450 MB   
<missing>     2 months ago   /bin/sh -c #(nop) COPY dir:83d196df7353244...  6.14 kB  
<missing>     2 months ago   /bin/sh -c #(nop) COPY dir:b6cf88d344488c5...  534 kB   
<missing>     2 months ago   /bin/sh -c #(nop) COPY dir:4ec5065aa04411f...  133 MB   
<missing>     2 months ago   /bin/sh -c #(nop)  LABEL maintainer=Antoni...  0 B      
...

Note that the COPY at the bottom is the COPY sources / that I removed -- and this 133MB lives with the image permanently

In my adjusted version, this is what those layers look like now:

$ docker history test
ID            CREATED        CREATED BY                                     SIZE     COMMENT
0dd9e8404836  4 minutes ago  /bin/sh -c #(nop) CMD ["/bin/bash"]            0 B      
<missing>     4 minutes ago  /bin/sh -c :     && build_scripts_pypy/pre...  450 MB   
f7782c9f490e  6 minutes ago  /bin/sh -c #(nop) COPY dir:3b7c4e3c9c0b411...  6.14 kB  
7f269f24df66  7 minutes ago  /bin/sh -c #(nop) COPY dir:eeea7d90789cc10...  534 kB   
1d63db00a9ae  7 minutes ago  /bin/sh -c #(nop) LABEL maintainer="Antoni...  0 B 
...

so I essentially reduced the image size by 133MB!

@antocuni
Copy link
Member

LGTM! I invited you to be part of the PyPy team so you can merge it directly, if you want!

@asottile
Copy link
Member Author

neat, thanks!

@asottile asottile merged commit 8f210b5 into pypy:master Sep 26, 2020
@asottile asottile deleted the improve_size branch September 26, 2020 14:42
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants