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

Issue with uv@0.2.7 in Dockerfile + venv #4072

Closed
omarish opened this issue Jun 5, 2024 · 8 comments · Fixed by #4073
Closed

Issue with uv@0.2.7 in Dockerfile + venv #4072

omarish opened this issue Jun 5, 2024 · 8 comments · Fixed by #4073
Labels
bug Something isn't working

Comments

@omarish
Copy link

omarish commented Jun 5, 2024

I think I've encountered an issue related to (I believe) virtualenv detection when using uv in a dockerfile. Specifically, I noticed that my company's CI started failing on all images that rely on uv.

For reference, here is the dockerfile:

# syntax = docker/dockerfile:1.0-experimental

# Base image
FROM python:3.12.2 as build
RUN apt-get update && apt-get install -y build-essential curl libpq-dev
ENV VIRTUAL_ENV=/opt/venv \
  PATH="/opt/venv/bin:$PATH"

ADD https://astral.sh/uv/install.sh /install.sh
RUN chmod -R 655 /install.sh && /install.sh && rm /install.sh
COPY ./packages/waldo-db-proxy/requirements.txt .
RUN /root/.cargo/bin/uv venv /opt/venv && \
  /root/.cargo/bin/uv pip install --no-cache -r requirements.txt

# App image
FROM python:3.12.2-slim-bookworm
RUN apt-get update && apt-get install -y build-essential curl libpq-dev
COPY --from=build /opt/venv /opt/venv
ENV PATH="/opt/venv/bin:$PATH"
WORKDIR /app
COPY  ./packages/waldo-db-proxy ./
EXPOSE  5432
CMD [ "python", "-m", "app", "start" ]

This started failing universally this morning.

I hopped in to a partial image (before this line that activates the venv RUN /root/.cargo/bin/uv venv /opt/venv), and found that it was running uv@0.2.7.

This image works without issue when I replace https://astral.sh/uv/install.sh with https://github.com/astral-sh/uv/releases/download/0.2.6/uv-installer.sh.

I haven't had time to further debug, but just wanted to raise this issue in case others are trying to debug.

Edit: it seems to fail at this step on 0.2.7:

 > [build 6/6] RUN /root/.cargo/bin/uv venv /opt/venv &&   /root/.cargo/bin/uv pip install --no-cache -r requirements.txt:
#19 0.100   × failed to canonicalize path `/opt/venv/bin/python3`
#19 0.100   ╰─▶ No such file or directory (os error 2)
@omarish omarish changed the title Issue with uv 0.2.7 when running in Dockerfile with virtualenv Issue with uv@0.2.7 in Dockerfile + venv Jun 5, 2024
@charliermarsh
Copy link
Member

FWIW, you can also use https://astral.sh/uv/0.2.6/install.sh as the installer link.

@charliermarsh
Copy link
Member

Can you share any more on what is failing?

@charliermarsh
Copy link
Member

Modifying the Dockerfile a bit, I eventually get:

 > [build 6/6] RUN /root/.cargo/bin/uv venv /opt/venv &&   /root/.cargo/bin/uv pip install --no-cache -r requirements.txt:
#19 0.100   × failed to canonicalize path `/opt/venv/bin/python3`
#19 0.100   ╰─▶ No such file or directory (os error 2)

Does that look familiar?

@omarish
Copy link
Author

omarish commented Jun 5, 2024

Sorry for not posting that in the original issue. Yes, that's the issue I ran into using 0.2.7.

@charliermarsh
Copy link
Member

Okay, thanks.

@zanieb
Copy link
Member

zanieb commented Jun 5, 2024

Thanks! We'll have a fix out shortly.

zanieb added a commit that referenced this issue Jun 5, 2024
…nvironment (#4073)

Closes #4072

This was an accidental change in
#4029 in which I had updated the
pull request to support virtual environments as requested in review and
forgot to revert it.

Separately, we shouldn't fail if `VIRTUAL_ENV` points to an empty
directory and `SystemPython::Allowed` is used, will address that
separately.
@omarish
Copy link
Author

omarish commented Jun 5, 2024

That was fast! Thank you.

@zanieb
Copy link
Member

zanieb commented Jun 5, 2024

The release should be out now. Let us know if you run into any more problems :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants