leighmcculloch / docker-unison

A docker data container using Unison for fast folder sync. An alternative to slow boot2docker volumes on OS X.
GNU General Public License v3.0
167 stars 26 forks source link

sync a special directory inside of webserver container #12

Closed Jehu closed 7 years ago

Jehu commented 8 years ago

i try to figure out how to sync /var/www/html from this image.

I use docker-compose with a docker-compose.yml like this:

version: '2'
services:
  web:
    image: drupaldocker/php:apache
    volumes_from:
        - unison
    ports:
      - "8080:80"
    links:
      - db
    depends_on:
      - unison
      - db
      - solr
  db:
    image: bitnami/mariadb
    environment:
      MARIADB_DATABASE: drupal
      MARIADB_PASSWORD: rootroot
    ports:
      - "3306:3306"
  unison:
    image: leighmcculloch/unison
    environment:
      - UNISON_VERSION=2.48.3
      - UNISON_WORKING_DIR=/var/www/html
      - WORKDIR=/var/www/html
    ports:
      - "5000:5000"
  solr:
      image: mxr576/apachesolr-5.x-drupal-docker
      ports:
        - 8983:8983
      environment:
        PARTIAL_SEARCH_ENABLED: 'true'

But after the command unison /Users/marco/path/to/my/project/www/ socket://localhost:5000/ -ignore 'Path .git' -auto -batch the /var/www/html inside the web container is empty

leighmcculloch commented 7 years ago

@Jehu Is unison on your host machine outputting an error? Can you tail the docker logs and share what the image is showing?

jujes commented 7 years ago

Hi, I have the same issue, my special directory is: /var/www/htdocs

logs

*** Running /etc/my_init.d/00_regen_ssh_host_keys.sh...
*** Running /etc/rc.local...
*** Booting runit daemon...
*** Runit started as PID 8
./run: 3: cd: can't cd to /var/www/htdocs
Jul 30 17:21:33 55cb620b097c syslog-ng[15]: syslog-ng starting up; version='3.5.3'

docker-compose.yml

web:
  build: .
  ports:
    - "80:80"
  links:
    - mysql
  env_file:
    - env
  volumes_from:
    - unison
mysql:
  image: mysql:5.6.23
  env_file:
    - env
unison:
  image: leighmcculloch/unison:latest
  environment:
    - UNISON_WORKING_DIR=/var/www/htdocs
    - WORKDIR=/var/www/htdocs
  ports:
    - "5000:5000"

Someone know how keep sync my Magento folder whit Unison?

thanks in advance,

leighmcculloch commented 7 years ago

This line surprises me:

./run: 3: cd: can't cd to /var/www/htdocs

That directory should exist because it will be stated as a VOLUME in the Dockerfile, but possibly I'm misinterpreting how this works because VOLUME has been set already when the docker image was built.

leighmcculloch commented 7 years ago

I don't think setting the WORKDIR environment variable is necessary or will change anything. The UNISON_WORKING_DIR is the directory that unison is executed in, and it syncs to that directory. It's possible that because that doesn't change in the dockerfile since it's already built, that the VOLUME directive isn't creating the directory, and that's the only step that's missing.

leighmcculloch commented 7 years ago

I'll release a version that makes the directory specifically and I think that's going to resolve this.

leighmcculloch commented 7 years ago

@Jehu @jujes Turns out the README is misleading and you just need to add an extra argument/config to make it work. I've updated the readme in 286ff02ff02b9502aa07c3d0a1f6f17dbd2af61a to clear this up. Can you try that and confirm that it resolves the issue for you?