#Dockerfile ENV availability

1 messages ยท Page 1 of 1 (latest)

fluid vortex
#

I'm new to Dagger, so sorry in advance. Is there some way in the API to do with_env? As in, I am using with_exec to do the steps I would normally use Dockerfile RUN for, and now I wish to do the Dockerfile ENV equivalent, but there is no with_env API. Specific use case is that I am setting up Python virtual environment as a cache volume, and then I want to set my PATH=/path/to/venv:$PATH but I don't see a way. I have the venv caching working and for subsequent calls to python I am using /src/venv/bin/[python,pip] and it's working great. I just feel like I am missing something and I can't find any examples. Thanks

blazing tundra
chrome python
fluid vortex
#

@blazing tundra thanks that is what I needed

#

@chrome python and thank you, I tried with_env_variable("PATH", "/somepath:$PATH") which I knew wouldn't work when I typed it but tried anyway ๐Ÿ™‚

#

you already answered the follow-up thanks

chrome python
#

How are you activating the venv if I may ask? ๐Ÿ™‚

fluid vortex
#

i didn't, if you use the path to the python which is in a venv then magic happens (at least it has always worked for every case I've had)

chrome python
#

Yep, that's right. I like to also set VIRTUAL_ENV. Poetry for example detects that automatically.

fluid vortex
#

i'm sure this is wrong, but works. if you have a hint I would gladly activate it properly

chrome python
fluid vortex
#

excellent, thanks for the assistance

#

@chrome python yes perfect, now I have unmangled my path. i was trying with path=container.env_variable(PATH) and then with_env_variable(f"{venv}/bin:{path}") but that was not working as expected

#

you just set a fixed path in your ci, which is fine for me

#

seems like what I was trying should work but maybe I just messed it up

chrome python
fluid vortex
#

I will try it again and get it in a sharable state if it's still not working

chrome python
#

Cool ๐Ÿ‘

fluid vortex
#

@chrome python ok, i was messing it up. path = AWAIT container.env_variable...

#

path was a coroutine, not a string

chrome python
#

Yep, that's right ๐Ÿ™‚

fluid vortex
#

thanks muchly ๐Ÿ™‚