Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Produce a distroless-based Docker image #18033

Closed
wants to merge 9 commits into from
Closed

Conversation

sandhose
Copy link
Member

@sandhose sandhose commented Dec 16, 2024

This minimises the docker image by using a distroless-based runtime image.

This means:

  • Runtime native dependencies must be installed in another stage
  • The Python interpreter we'd like must also be manually installed, as the distroless python image is frozen on py3.11 and doesn't seem to move regularly

To do both, we add a new stage that runs on the build platform arch (rather than the target platform) which sets up those environments for both x86-64 and aarch64.

For the former, we download the debs using apt-get download, and manually unarchive them.

For the latter, we use uv python to download Python distributions from the indygreg/python-build-standalone project.


I then looked how I could further improve build speeds, especially when cross-compiling:

  • Because this was using uv anyway, I figured I could swap pip install calls with uv pip install, which saves a few minutes by itself
  • I then looked at what packages were not using binary wheels: I upgraded MarkupSafe to have binaries for py3.12, and got back to Python 3.12 because hiredis didn't have builds for py3.13 with the version we were using
  • The generation of the requirements.txt is arch-agnostic, so I've switched this one to run on the build architecture, so that both arch can share it
  • We were using -slim images, but still installed a bunch of -dev dependencies. Turns
    out, all the dev dependencies were already installed in the non-slim image, which saves a bunch of time as well

@sandhose sandhose force-pushed the quenting/distroless branch from e043329 to dd14231 Compare December 16, 2024 14:56
@sandhose
Copy link
Member Author

Superseded by #18038 and #18039

@sandhose sandhose closed this Dec 18, 2024
@sandhose sandhose deleted the quenting/distroless branch December 18, 2024 09:37
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.

1 participant