Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The image produced by #382 is large:
We can cut the size in half by using a stripped-down Debian image,
python:3.10-slim
. Unlikealpine
, theslim
variant still uses glibc, and Python'smanylinux
wheels run on it. More info the excellent Normcore talk, "How small can I get this Docker container?".In #382 there was a nonsensical multi-stage build being used, equivalent to:
The second stage has no effect because it builds directly on top of the previous stage, discarding nothing. (This was introduced by me, due to a fuzzy mental model of layering.) Consolidating those to stages into one produces an image of exactly the same size, as expected:
If we use multi-stage builds properly, we can keep the source tree out of the final image and shave off another 37 MB:
Using Dive I inspected where that size is coming from. The vast majority (664 MB) lives in
/opt/venv/lib/python3.10/site-packages/
. The dependencies include some heavyweights like scipy (84 MB) and pandas (56 MB). That seems right.As the talk linked at the top shows, it's possible to make more progress if we're willing to accept much more complexity and longer build times. But as the talk recommends, something close to this approach is the pragmatic sweet spot.