cweagans / docker-bg-sync

A container that syncs files between two configurable directories.
224 stars 39 forks source link

How to add custom ignore paths? #17

Closed cglai closed 6 years ago

cglai commented 6 years ago

In the sync.sh, I saw # Files to ignore, and yes, files in path like .git/ were not synced into app container.

However, I couldn't find where to add custom ignore paths (in my example, .phpintel) in README.

So, can u add one more start option to support this without fork this repo and rebuild a container by modify sysc.sh?

cweagans commented 6 years ago

Yep, you can use SYNC_EXTRA_UNISON_PROFILE_OPTS to specify extra lines to add to your Unison profile. Just mimic the other lines that are there and they will be skipped.

cglai commented 6 years ago

Sorry it was I that unfamiliar with Unison configuration before, and I didn't recognize this option.

I used SYNC_EXTRA_UNISON_PROFILE_OPTS option when start this container like this:

-e SYNC_EXTRA_UNISON_PROFILE_OPTS="ignore = Path .path1/*"

And in /home/{USER}/.unison/default.prf, the identical string value of that option was appended in, and it works.

However, when I add one more path to be ignored, like

-e SYNC_EXTRA_UNISON_PROFILE_OPTS="ignore = Path .path1/* \n ignore = Path .path2/*"

# Or
-e SYNC_EXTRA_UNISON_PROFILE_OPTS="ignore = Path .path1/*" \
-e SYNC_EXTRA_UNISON_PROFILE_OPTS="ignore = Path .path2/*"    # !!! overwrote

It didn't work this time, whether \n exist or not.

If you have more than one option that you want to add, simply make this a multiline string.

So, what a multiline string actually look like?

Thx! :)

cweagans commented 6 years ago

@leymannx has a good example here: https://github.com/leymannx/dockerix/blob/master/docker-compose.yml#L39-L50

If there's something that could go into the documentation to make this clearer, PRs are always appreciated :) Otherwise, I'll get around to it someday.

cglai commented 6 years ago

All right ... It turns out I thought this too complicated because there's the simplest way to set multiline values for environment option when executing docker run:

docker run \

...

-e SYNC_EXTRA_UNISON_PROFILE_OPTS="ignore = Path path1/*
ignore = Path path2/*
ignore = Path path3/*" \

...

Besides, https://github.com/leymannx/dockerix/blob/master/docker-compose.yml#L39-L50 also remind me to achieve multiline string setting when using docker-compose.

Thx again, problem solved. :)