#Equivalent of `docker compose watch`

1 messages · Page 1 of 1 (latest)

lilac glacier
#

Hey there, docker compose recently-ish added support for file watcher https://docs.docker.com/compose/file-watch/ which allows to rebuild containers, restart, or sync files as they change on the host. One of the key benefit, is that it is not using bind mounts and can ignore stuff like node_modules.

I was wondering if there was (long term?) plans to support something like that? Rebuild on file change, sync files on change, etc. It looks like Mutagen is under the hood.

On this note, is local "live" development where developer is running and building container locally and iterating on it with hot reload intended to be first-class use-case in Dagger? I see we can use WithMountedDirectory, but isn't that more akin to binding a mount? Also it would not enable rebuilding on file change beyond starting the dev server with hot reload enabled (e.g.: WithExec([]string{"yarn", "start"}) and having it doing the hot reloading).

Docker Documentation

Use File watch to automatically update running services as you work

spark shard
#

Yes we aim to support this workflow but its not possible right now. There have been some convos about this in various places, and we have considered mutagen.

I cant seem to find a GH issue for this though, but I swear we had one.

lilac glacier
#

I cant seem to find [the] issue for this though, but I swear we had one.

Story of my life. 😉

spark shard
#

Well, I filed this just now 🙂 https://github.com/dagger/dagger/issues/6990

Hope I captured your question, this is a use case that I would absolutely love to see supported becuse it unlocks some very powerful local development workflows

GitHub

What are you trying to do? I want to be able to make changes to code locally and see them reflected in my running Dagger services similar to how docker-compose and docker run --v works. Discussion ...

lilac glacier
#

Thanks! I would explictly mention docker compose watch in the issue since the way it works is especially nice.

This raise question, I was under the impression that WithMountedDirectory was the equivalent of docker run -v .... If not what does it do?

spark shard
#

The key idea to remember is that under the hood we are using buildkit and building a container.

The difference between withDirectory and withMountedDirectory is that withDirectory will include a directory in an container if you export it, and withMountedDirectory will not.

This is not the same as running docker -v because we are not creating a bind mount (but we're also not doing anything fancy like mutagen, which I wish we were) This is described a bit more here: https://docs.dagger.io/421437/work-with-host-filesystem/#important-notes