GithubHelp home page GithubHelp logo

dinamic / docker-bg-sync Goto Github PK

View Code? Open in Web Editor NEW

This project forked from cweagans/docker-bg-sync

0.0 1.0 0.0 12 KB

A container that syncs files between two configurable directories.

Shell 100.00%

docker-bg-sync's Introduction

bg-sync

This container continuously syncs files between two directories. This is useful for avoiding the filesystem slowness on Docker for Mac, for instance. It's also generally useful for any other time where you have a slow filesystem as a source of files that need to be read inside of a container.

Usage

This is a basic docker-compose.yml that demonstrates usage of this container.


version: '2'

services:
  web:
    image: php:7.0-apache
    volumes:
      - /var/www/myapp

  bg-sync:
    image: cweagans/bg-sync
    volumes:
      - .:/source
    volumes_from:
      - web
    environment:
      - SYNC_DESTINATION=/var/www/myapp
      - SYNC_MAX_INOTIFY_WATCHES=40000
      - SYNC_VERBOSE=1
    privileged: true

Environment variables

This container uses values from a handful of environment variables. These are documented below.

  • SYNC_SOURCE (default: /source): The path inside the container which will be used as the source of the file sync. Most of the time, you probably shouldn't change the value of this variable. Instead, just bind-mount your files into the container at /source and call it a day.
  • SYNC_DESTINATION (default: /destination): When files are changed in SYNC_SOURCE, they will be copied over to the equivalent paths in SYNC_DESTINATION. If you are using bg-sync to avoid filesystem slowness, you should set this path to whatever path the volume is at in your application container. In the example above, for instance, this would be /var/www/myapp.
  • SYNC_PREFER (default: /source): Control the conflict strategy to apply when there are conflits. By default the contents from the source folder are left unchanged but there is also the "newer" option to pick up the most recent files.
  • SYNC_VERBOSE (default: "0"): Set this variable to "1" to get more log output from Unison.
  • SYNC_MAX_INOTIFY_WATCHES (default: ''): If set, the sync script will attempt to increase the value of fs.inotify.max_user_watches. IMPORTANT: This requires that you run this container as a priviliged container. Otherwise, the inotify limit increase will not work. As always, when running a third party container as a priviliged container, look through the source thoroughly first to make sure it won't do anything nefarious. sync.sh should be pretty understandable. Go on - read it. I'll wait.
  • SYNC_EXTRA_UNISON_PROFILE_OPTS (default: ''): The value of this variable will be appended to the end of the Unison profile that's automatically generated when this container is started. Ensure that the syntax is valid. If you have more than one option that you want to add, simply make this a multiline string. IMPORTANT: The ability to add extra lines to your Unison profile is supported by the bg-sync project. The results of what might happen because of this configuration is not. Use this option at your own risk.
  • SYNC_NODELETE_SOURCE (default: '1'): Set this variable to "0" to allow Unison to sync deletions to the source directory. This could cause unpredictable behaviour with your source files.
  • UNISON_USER (default: 'root'): The user running Unison. When this value is customized it's also possible to specify UNISON_UID, UNISON_GROUP and UNISON_GID to ensure that unison has the correct permissions to manage files under SYNC_SOURCE and SYNC_DESTINATION.
  • UNISON_UID (default: '0'): See UNISON_USER.
  • UNISON_GROUP (default: 'root'): See UNISON_USER.
  • UNISON_GID (default: '0'): See UNISON_USER.

Why not use x?

I've probably tried it and didn't like it for one reason or another. If you think that's not the case, open an issue. I'd love to be told about another project that makes it possible to deprecate this one.

Specific reasons:

  • Docker Sync: Although the choice of sync backends is cool, I think it's better to offer just one and make sure that it works as close to perfect as is possible. The big deal breaker with Docker Sync, though, is that it requires installing extra stuff on the host. The entire point of containerization is that you shouldn't have to worry about that kind of stuff.
  • Docker Magic Sync: I like the idea - using Docker Gen to generate a set of Unison profiles + a supervisord config is pretty clever. However, I rarely need to sync more than one pair of directories, and when I do, each set of directories usually needs different configurations. With bg-sync, you can spin up multiple instances of the container, each with different Unison configurations if you want to.

Credits

Donations

Bitcoin donation address: 149NMUk73ETqEP3ML9sghpWQqEqAREX9z2

docker-bg-sync's People

Contributors

cweagans avatar davide avatar dinamic avatar leymannx avatar smfsh avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.