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

Publish variants of Docker image #5610

Closed
zanieb opened this issue Jul 30, 2024 · 8 comments · Fixed by #6053
Closed

Publish variants of Docker image #5610

zanieb opened this issue Jul 30, 2024 · 8 comments · Fixed by #6053
Labels
help wanted Contribution especially encouraged releases Related to building and distributing release artifacts of uv

Comments

@zanieb
Copy link
Member

zanieb commented Jul 30, 2024

Instead of only supplying a bare image, we should publish an alpine variant and a variant with Python so people can use our image without creating a custom derivative.

@zanieb
Copy link
Member Author

zanieb commented Jul 30, 2024

For example, this is important for GitLab CI which requires sh.

This applies to Ruff as well.

@zanieb zanieb added the releases Related to building and distributing release artifacts of uv label Jul 30, 2024
@zanieb
Copy link
Member Author

zanieb commented Jul 30, 2024

This should basically be trivial, we just need to setup a folder with a few variants, copy in the executable from the scratch image, and publish them each release.

@zanieb zanieb added the help wanted Contribution especially encouraged label Jul 30, 2024
@konstin
Copy link
Member

konstin commented Jul 31, 2024

When building an optimized production image, i'd need two base images: A builder with uv, my python version and ideally a bunch of dev libraries (curl, git, gcc, dev headers), and a runner image that has python in the same location as the builder, in which i only copy the venv and call python as entrypoint.

@zanieb
Copy link
Member Author

zanieb commented Jul 31, 2024

I think we can describe a few goals here:

  1. Allow uv to be used in GitLab CI, i.e. provide a image with a shell
  2. Allow uv to be used as a Python image, i.e. provide an image for each Python version with development tools
  3. Document best practices for deriving a minimal production image from (2)

@mayuresh-quartic
Copy link

mayuresh-quartic commented Jul 31, 2024

I can suggest few approach to this:

  • Pull latest python slim images
  • Install uv latest version in global system

I can create Dockerfiles quickly for this

This will be minimal with no extra apt or system packages

@zanieb

@mayuresh-quartic
Copy link

Later I can think of some CI to automate this:

On official release publish these Python version images with UV installed:
Python3.8
Python3.9
Python3.10
Python3.11
Python3.12

or as per UV support matrix

@zanieb
Copy link
Member Author

zanieb commented Jul 31, 2024

Sure, a couple notes:

  • I think I'd use a single Dockerfile parameterized on Python version.
  • We should copy the uv executable from our scratch Docker image instead of installing from, e.g., curl

@mayuresh-quartic
Copy link

For example here is the uv image i created based on Python3.9 version: mayuresh14/uv-python39-slim

Dockerfile looks like this

FROM --platform=linux/amd64 python:3.9-slim

RUN pip install uv

I will keep in mind your mentioned notes and create a PR soon

zanieb pushed a commit that referenced this issue Sep 3, 2024
## Summary

Closes #5610

This PR introduces additional images with the uv/uvx binaries from
scratch for both amd64/arm64 and make the mapping easy to configure by
generating the Dockerfile on the fly. This approach focuses on
minimizing CI time by taking advantage of dedicating a worker per
mapping (20-30s~ per job).

This PR also fixes `org.opencontainers.image.version` for all tags
(including the one from `scratch) to contain the right release version
instead of branch name `main` (default when no tag patterns are
specified).

For example, on release `x.y.z`, this will publish the following image
tags with format `ghcr.io/astral-sh/uv:{tag}` with manifests for both
amd64/arm64. This also include `x.y` tags for each respective additional
tag.

* From **scratch**: `latest`, `x.y.z`, `x.y` (currently being published)
* From **alpine:3.20**: `alpine`, `alpine3.20`, `x.y.z-alpine`,
`x.y.z-alpine3.20`
* From **debian:bookworm-slim**: `debian-slim`, `bookworm-slim`,
`x.y.z-debian-slim`, `x.y.z-bookworm-slim`
* From **buildpack-deps:bookworm**: `debian`, `bookworm`,
`x.y.z-debian`, `x.y.z-bookworm`
* From **python:3.12-alpine**: `python3.12-alpine`,
`x.y.z-python3.12-alpine`
* From **python:3.11-alpine**: `python3.11-alpine`,
`x.y.z-python3.11-alpine`
* From **python:3.10-alpine**: `python3.10-alpine`,
`x.y.z-python3.10-alpine`
* From **python:3.9-alpine**: `python3.9-alpine`,
`x.y.z-python3.9-alpine`
* From **python:3.8-alpine**: `python3.8-alpine`,
`x.y.z-python3.8-alpine`
* From **python:3.12-bookworm**: `python3.12-bookworm`,
`x.y.z-python3.12-bookworm`
* From **python:3.11-bookworm**: `python3.11-bookworm`,
`x.y.z-python3.11-bookworm`
* From **python:3.10-bookworm**: `python3.10-bookworm`,
`x.y.z-python3.10-bookworm`
* From **python:3.9-bookworm**: `python3.9-bookworm`,
`x.y.z-python3.9-bookworm`
* From **python:3.8-bookworm**: `python3.8-bookworm`,
`x.y.z-python3.8-bookworm`
* From **python:3.12-slim-bookworm**: `python3.12-slim-bookworm`,
`x.y.z-python3.12-slim-bookworm`
* From **python:3.11-slim-bookworm**: `python3.11-slim-bookworm`,
`x.y.z-python3.11-slim-bookworm`
* From **python:3.10-slim-bookworm**: `python3.10-slim-bookworm`,
`x.y.z-python3.10-slim-bookworm`
* From **python:3.9-slim-bookworm**: `python3.9-slim-bookworm`,
`x.y.z-python3.9-slim-bookworm`
* From **python:3.8-slim-bookworm**: `python3.8-slim-bookworm`,
`x.y.z-python3.8-slim-bookworm`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Contribution especially encouraged releases Related to building and distributing release artifacts of uv
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants