Skip to content

Conversation

@sairon
Copy link
Member

@sairon sairon commented Nov 12, 2025

Implement several low-risk optimization in the *-base-python images to optimize build and reduce layer count by 2. See the individual commits for details.

We don't need the patches in runtime but because they're copied, they are still
persisted in a layer of the image. Use bind-mount to have them available only
for the build.
There is no major benefit in splitting these two actions to two steps.
By defining it early we're busting the cache on pip version upgrade,
effectively making the split into two layers pointless.
Use ensurepip instead of fetching get-pip to install pip, to make the build
step simpler. Note that --without-ensurepip in the Python configure args is
still desired and correct, as it only prevents from running ensurepip after the
build. The ensurepip and upgrade to the pinned version should be run in the
same step to prevent layer bloat by modified files.
Copy link
Member

@agners agners left a comment

Choose a reason for hiding this comment

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

Very nice improvements! 🤩

Copy link
Member

@agners agners left a comment

Choose a reason for hiding this comment

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

LGTM, nice improvement!

@sairon sairon merged commit baa89d6 into master Nov 12, 2025
159 of 169 checks passed
@sairon sairon deleted the python-reduce-layers branch November 12, 2025 17:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants