Sign inSign up

mickaelperrin/unison-server

By mickaelperrin

•Updated over 7 years ago

Dockerized unison server with script to sync a local folder with a container on a remote server

Image
0

186

mickaelperrin/unison-server repository overview

⁠dockerized unison server

Simple dockerized unison server with script to sync a local folder with a remote dockerized application.

⁠Description

Unison is a tool to perform bi-directional sync in real time.

This image provides:

  • real time bi-directionnal syncing between your host and a (remote) container
  • full performance for your docker mounts (OSXFS, NFS, Vboxfs... are really slow especially for large code base)
  • docker only as a requirement

⁠How to use

⁠Provided example

A full example is provided in the example folder⁠. To run it:

cd example
docker-compose -f docker-compose.yml up

Then, spawn in a new shell:

cd  example
../../startSync.sh --container=example_unison_src_1
⁠Generic example

Here is an example on how to use it with a docker-compose file. The scenario illustrates a way to sync source code in real-time from the host inside a container on a remote server and get the output generated by the execution of the code back to the host.

The app container inits the volume /src where the code will reside. The unison_app container mounts the volumes from the app container and runs the unison server.

version: '2'

app:
  image: alpine:edge
  command: /bin/true
  volumes:
    - ./app:/app
unison_app:
  image: mickaelperrin/unison:2.51.2
  build: ..
  ports:
    - 5000
  environment:
    - SYNC_DIR=/app
    - TZ=Europe/Paris
    - UNISON_ARGS=" -ignore='Name .git' -ignore='Name node_modules' -ignore='Name .idea' -ignore='Path log' -ignore='Path keyrings' -prefer newer -copyonconflict"
  volumes_from:
    - app    
    
⁠Start sync process with a remove server

To start the sync process you need to run the startSync.sh script with --server=YOURSERVER argument.

To make it work, be sure that you can ssh into your remote server by simply running: ssh YOURSERVER.

If your server doesn't resolve an IP, you can provide an IP with the --server-ip=SERVERIP argument.

startSync.sh --server="NAME_OF_YOUR_SERVER_YOU_SSH_INTO" --server-ip="IP_OF_YOUR_SERVER" --container="YOUR_UNISON_CONATINER"

Be sure that your remote server allows connections from your host to the unison port dynamically mapped on the server.

⁠Behind the scenes

This container uses:

  • unison for bi-directionnal syncing and file watching
  • docker-gen for volumes discovery

⁠WARNING

An issue with OSXFS prevents inotify events to get triggered in a mounted volume if the number of files created is high. This occurs when you perform a project initialisation like a composer install on a fresh project. Be sure, to stop the sync process before doing so, then re-eanble it to grab the generated files.

⁠Disclaimer

Besides the usual disclaimer in the license, we want to specifically emphasize that the authors, and any organizations the authors are associated with, can not be held responsible for data-loss caused by possible malfunctions of Docker Magic Sync.

⁠License

GPLv2⁠ or any later GPL version.

Tag summary

Content type

Image

Digest

Size

7 MB

Last updated

over 7 years ago

docker pull mickaelperrin/unison-server