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

Both Dockerfile examples should probably include UV_SYSTEM_PYTHON=true #26

Open
joejoinerr opened this issue Nov 8, 2024 · 4 comments

Comments

@joejoinerr
Copy link

I got caught out using these examples, since both the standard and multistage built fine. However, the multistage image wouldn't run, instead exiting with a ModuleNotFoundError.

It took a while to figure out, but I found that because my .python-version file, which contained a different version to that specified on the container image, had been copied during the build, uv was using that to install and run, which later broke the app.

This can be overcome by specifiying UV_SYSTEM_PYTHON=true as an env to make sure that the container-specified Python version is used.

The docs also specify it for this purpose:

UV_SYSTEM_PYTHON=true is intended for use in continuous integration (CI) or containerized environments

https://docs.astral.sh/uv/configuration/environment/#UV_SYSTEM_PYTHON

@zanieb
Copy link
Member

zanieb commented Nov 8, 2024

Mmm interesting. Maybe we should add the .python-version file to the .dockerignore?

@joejoinerr
Copy link
Author

Yeah that also works. I have both in my project now, but I like the environment variable since it sits alongside the other build-specific settings. e.g.

ENV UV_COMPILE_BYTECODE=1 UV_LINK_MODE=copy UV_SYSTEM_PYTHON=true

@zanieb
Copy link
Member

zanieb commented Nov 8, 2024

I worry that UV_SYSTEM_PYTHON will imply to people that we'll install into the system Python environment — which we do not.

@joejoinerr
Copy link
Author

Ah, makes sense. Well from my brief tests, both solutions seem to have the same effect. So it's up to you :)

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

No branches or pull requests

2 participants