#So how do .env files work?

1 messages · Page 1 of 1 (latest)

cloud linden
#

Some other threads have alluded to .env files being used by dagger at startup to populate variables of functions, but the docs are silent on the subject. Can someone give me a quick rundown here?

tiny flicker
cloud linden
#

I've tried it out and I'm not able to see files changing in my running services. I'm using this pattern:

FilteredDefaultDirectory = Annotated[
    dagger.Directory,
    dagger.DefaultPath("."),
    dagger.Ignore(["!frontend", "!backend"]),
]

@object_type
class AwesomeThing:
    @function
    def something(self, source: FilteredDefaultDirectory):
        pass

Do DefaultPath and Ignore play nice together?

#

Just tried it without the Ignore and still got no love

cloud linden
#

the logs do say noCache=true tho...

cloud linden
#

I just did this minimal sample ```FilteredDefaultDirectory = Annotated[
dagger.Directory,
dagger.DefaultPath(
".",
),
dagger.Ignore(["!frontend", "!backend"]),
]

@object_type
class ReloadDefaultPath:
@function
def try_reload(self, source: FilteredDefaultDirectory) -> dagger.Service:
# Use GitLab mirror in CI, public registry locally
base_image = "public.ecr.aws/docker/library/python:3.12-slim"
container = dag.container().from_(base_image).with_directory("/app", source)
return container.as_service(args=["sh", "-c", "while true; do sleep 2; done"])

and ran it with `dagger call try-reload up --ports 1234:1234` and used the CLI to navigate to the service and get a terminal with `t`. I `tail`d a file, changed it in on the host, then `tail`d it again:

dagger / $ tail app/backend/src/app.py
exit(1)

uvicorn.run(
    "app:app",
    host="0.0.0.0",
    port=8000,
    reload=True,
)

hello

dagger / $ tail app/backend/src/app.py
exit(1)

uvicorn.run(
    "app:app",
    host="0.0.0.0",
    port=8000,
    reload=True,
)

hello

dagger / $

No change.
#

Oh man I just totally lost the plot on this thread.

#

my b

tiny flicker
#

@cloud linden sorry for the late reply. Dagger doesn't have a concept of bind mounts yet. This means that files are transferred to your pipeline only once and they get snapshotted for reproducibility purposes. I understand your use case and we so plan to support it soon but there's currently no way to have live-syncing while your pipeline is running

cloud linden
#

Is there a convenient way to do Dev work using dagger, or are we stuck with docker compose?