First of all, my best wishes for 2025 and all the best for the future of Dagger.io.
I would like to be able to read a .env file from my Python Dagger function but I don't find how to achieve this.
To make things easy to illustrate, I would be able to do something like this:
@function
async def test(self) -> str:
load_dotenv(".env", override=True)
if os.environ.get('RUN_LINT', True):
return "Run it"
return "Don't run it"
By running it (dagger call test --verbose ), it didn't work because the .env file is not retrieved.
By replacing my function body with just return os.getcwd(); I get /scratch as the current folder.
My problem, I suppose; is because Dagger didn't retrieve my .env file while that file well exists in my current folder while running the dagger call instruction.
Did you've any tips / tutorials here?
Thanks!