astral-sh/rye

Add --system to uv pip install in guide/docker under "Container from a Python Package"

eschmidt42 opened this issue · 0 comments

Steps to reproduce

Running on Ubuntu I followed the steps under Container from a Python Package

rye build --wheel --clean
docker build . --tag your-image-name

with the run command as described on the page as

RUN --mount=source=dist,target=/dist uv pip install --no-cache /dist/*.whl

Which I think may be missing the --system flag in uv pip install?

If I use --system it works and if if I don't it doesn't, see below 🙂 .

Expected result

docker build -f ./my_app/Dockerfile --tag my-app .
[+] Building 14.9s (13/13) FINISHED                                                                                           docker:desktop-linux
 => [internal] load build definition from Dockerfile                                                                                          0.0s
 => => transferring dockerfile: 2.98kB                                                                                                        0.0s
 => [internal] load metadata for docker.io/library/python:3.12-slim                                                                           1.3s
 => [internal] load .dockerignore                                                                                                             0.0s
 => => transferring context: 2B                                                                                                               0.0s
 => [stage-0 1/8] FROM docker.io/library/python:3.12-slim@sha256:59c7332a4a24373861c4a5f0eec2c92b87e3efeb8ddef011744ef9a751b1d11c             0.0s
 => [internal] load build context                                                                                                             0.0s
 => => transferring context: 9.73kB                                                                                                           0.0s
 => CACHED [stage-0 2/8] WORKDIR /work                                                                                                        0.0s
 => CACHED [stage-0 3/8] COPY .streamlit /work/.streamlit                                                                                     0.0s
 => [stage-0 4/8] COPY my_app /work/my_app                                                                                0.1s
 => [stage-0 5/8] RUN pip install uv                                                                                                          3.7s
 => [stage-0 6/8] RUN --mount=source=dist,target=/dist uv pip install --system --no-cache /dist/*.whl                                         6.5s 
 => [stage-0 7/8] COPY configs /work/configs                                                                                                  0.1s 
 => [stage-0 8/8] COPY logs /work/logs                                                                                                        0.1s 
 => exporting to image                                                                                                                        3.0s 
 => => exporting layers                                                                                                                       3.0s 
 => => writing image sha256:080dc1eb61fb4c0d5ed275c4eb547b4d92df5d4e083e2bbdfcb89846479da43c                                                  0.0s 
 => => naming to docker.io/library/my-app                                                                                       0.0s

Actual Result

docker build -f ./my_app/Dockerfile --tag my-app .
[+] Building 5.7s (10/12)                                                                                                     docker:desktop-linux
 => [internal] load build definition from Dockerfile                                                                                          0.0s
 => => transferring dockerfile: 2.97kB                                                                                                        0.0s
 => [internal] load metadata for docker.io/library/python:3.12-slim                                                                           1.3s
 => [internal] load .dockerignore                                                                                                             0.0s
 => => transferring context: 2B                                                                                                               0.0s
 => [stage-0 1/8] FROM docker.io/library/python:3.12-slim@sha256:59c7332a4a24373861c4a5f0eec2c92b87e3efeb8ddef011744ef9a751b1d11c             0.0s
 => [internal] load build context                                                                                                             0.0s
 => => transferring context: 9.72kB                                                                                                           0.0s
 => CACHED [stage-0 2/8] WORKDIR /work                                                                                                        0.0s
 => [stage-0 3/8] COPY .streamlit /work/.streamlit                                                                                            0.1s
 => [stage-0 4/8] COPY my_app /work/my_app                                                                                0.1s
 => [stage-0 5/8] RUN pip install uv                                                                                                          3.5s
 => ERROR [stage-0 6/8] RUN --mount=source=dist,target=/dist uv pip install --no-cache /dist/*.whl                                            0.5s 
------                                                                                                                                             
 > [stage-0 6/8] RUN --mount=source=dist,target=/dist uv pip install --no-cache /dist/*.whl:                                                       
0.480 error: No virtual environment found                                                                                                          
------                                                                                                                                             
Dockerfile:46                                                                                                                                      
--------------------
  44 |     
  45 |     RUN pip install uv
  46 | >>> RUN --mount=source=dist,target=/dist uv pip install --no-cache /dist/*.whl
  47 |     
  48 |     # RUN \
--------------------
ERROR: failed to solve: process "/bin/sh -c uv pip install --no-cache /dist/*.whl" did not complete successfully: exit code: 2

Version Info

rye 0.38.0
commit: 0.38.0 (3e3c8540f 2024-08-02)
platform: linux (x86_64)
self-python: cpython@3.12.3
symlink support: true
uv enabled: true