Skip to content

Usage of tool uv in Dockerfile fails to activate environment #13273

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

Open
brunolnetto opened this issue May 2, 2025 · 4 comments
Open

Usage of tool uv in Dockerfile fails to activate environment #13273

brunolnetto opened this issue May 2, 2025 · 4 comments

Comments

@brunolnetto
Copy link

brunolnetto commented May 2, 2025

Hi all. I want to use uv on my Dockerfile. After more than 3 hours reading and implementing the documentation, without success to "activate the environment", I came here for help. THe repository is here. The command to run the application is docker compose up -d --build.

After "succesfully building the application", following error pops up:

   Building landgraph-pydantic-mvp @ file:///app
      Built landgraph-pydantic-mvp @ file:///app
Uninstalled 1 package in 2ms
Installed 1 package in 0.64ms
Bytecode compiled 6046 files in 1.03s
error: Failed to spawn: uvicorn
  Caused by: No such file or directory (os error 2)

I am sure, I am using it wrongly, but at this point, I am tired of trying new things out. Therefore, any help is appreciated.

@charliermarsh
Copy link
Member

I cloned the repo and it mostly "just worked" for me? I had to run uv add langchain-openai. Then I ran docker compose up -d --build and looked at the logs:

INFO:     Will watch for changes in these directories: ['/app']
INFO:     Uvicorn running on http://0.0.0.0:8000 (Press CTRL+C to quit)
INFO:     Started reloader process [131] using WatchFiles

(It's immediately failing because I don't have OPENAI_API_KEY set, but uvicorn starts without issue.)

@brunolnetto
Copy link
Author

brunolnetto commented May 2, 2025

You don't count. Tool uv is your favourite child, it will always obey you. 😅 . But it still is not working properly for me, with the same issue. :/

@zanieb
Copy link
Member

zanieb commented May 2, 2025

You mount your working directory as a volume

    volumes:
      - .:/app

This can clobber the existing environment as mentioned at https://docs.astral.sh/uv/guides/integration/docker/#developing-in-a-container

See https://github.com/astral-sh/uv-docker-example/blob/ac09d87bf12d7b2d573a0e37c1d64f791ae31f10/compose.yml#L14-L21 instead

@brunolnetto
Copy link
Author

Thanks, @zanieb. You guys are so amazing, I feel blessed everytime I come here asking for help.

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

3 participants