docker-osx-dev icon indicating copy to clipboard operation
docker-osx-dev copied to clipboard

finer-grained rsync control

Open leemhenson opened this issue 9 years ago • 2 comments

I am working with a project at the moment that writes a couple of files from templates when it boots up. Because these files are written inside the directory structure that is being rsynced over, when I make any change to a file in that directory in my host I find these generated files are deleted by rsync. This is due to the --delete flag being set here:

https://github.com/brikis98/docker-osx-dev/blob/master/src/docker-osx-dev#L51

I have tested running docker-osx-dev with that flag removed, and my generated files are then persisted during the rsync cycle.

I am trying to envision some sort of per-path rsync configuration that would allow me and other users to special-case the rsync flags to deal with this sort of idiosyncrasy. Has there been any discussion around this sort of thing in the past?

Perhaps some sort of .docker-osx-dev or .rsync file that if found in a synced directory was used instead of the default options?

--archive --log-format 'Syncing %n: %i' --omit-dir-times --inplace --whole-file

Is there a more elegant way of doing this?

leemhenson avatar Jul 06 '15 17:07 leemhenson

Good question. I'm not sure of the best way to handle this case. You typically want the --delete flag to ensure the remote directory is truly in sync, especially after file deletes, but that does conflict with code generation. Usually, generated files are stored in a non-source directory, so you can just add them to the ignore flags in docker-osx-dev (run docker-osx-dev -h to see all supported flags). Are your files being generated into the exact same folder as normal source files? Is there any sort of file name pattern you could rely on for ignoring them?

brikis98 avatar Jul 06 '15 17:07 brikis98

It looks like explicitly --includeing all my non-generated source files and then --excludeing * in that directory gives me the behaviour I want from rsync. I've patched the .dockerignore parsing so it understands the ! prefix syntax.

leemhenson avatar Jul 07 '15 10:07 leemhenson