cweagans/docker-bg-sync

Using docker compose 3

delmicio opened this issue ยท 12 comments

Hi,

I'm getting Destination directory does not exist!
How should I use it?

version: '3'
volumes:
  code:
services:
  bg-sync:
    image: cweagans/bg-sync
    volumes:
      - code:/source
    environment:
      SYNC_VERBOSE: 1
      SYNC_DESTINATION: /source/www
      SYNC_EXTRA_UNISON_PROFILE_OPTS: |
        ignore = Path /source/www/appname/vendor
    privileged: true

The actual path in the code service is /app/www but it doesn't work either .

Please post your complete docker-compose.yml and I'll fix it for you.

version: '3'

volumes:
  code:

services:
  php:    
    build:
      context: .
    ports:
      - 80:80
    volumes:
      - code:/app/www

bg-sync:
    image: cweagans/bg-sync
    volumes:
      - code:/source
    environment:
      SYNC_VERBOSE: 1
      SYNC_DESTINATION: /source/www
      SYNC_EXTRA_UNISON_PROFILE_OPTS: |
        ignore = Path /source/www/appname/vendor
    privileged: true

Ah, I see. Okay, so the problem is that you need two separate volumes. Mount your code from your local disk into the bg-sync container using one volume. Mount a separate volume in both your PHP and bg-sync containers at /app/www (in both containers) and use that as your SYNC_DESTINATION. Does that make sense?

(Sorry, on mobile right now, so YAML is difficult)

@cweagans I'll try that and write you back...

I can't get it to work, but I think we're close...

I've removed the global volume 'code' and added my local folder mounted to /souce

version: '3'

services:

  php:
    ...
    volumes:
      - /app/www

  # this service sync a local dir in your computer with a dir on the app server side
  bg-sync:
    image: cweagans/bg-sync
    volumes:
      - ./app:/source
      - /app/www
    environment:
      SYNC_VERBOSE: 1
      SYNC_DESTINATION: /app/www
      SYNC_EXTRA_UNISON_PROFILE_OPTS: |
        ignore = Path lmss/vendor
    privileged: true

This is the log:

bg-sync_1  |
bg-sync_1  | ==> Generating Unison profile
bg-sync_1  |
bg-sync_1  | ==> Starting continuous sync.
bg-sync_1  | Warning: No archive files were found for these roots, whose canonical names are:
bg-sync_1  |    /source
bg-sync_1  |    /app/www
bg-sync_1  | This can happen either
bg-sync_1  | because this is the first time you have synchronized these roots,
bg-sync_1  | or because you have upgraded Unison to a new version with a different
bg-sync_1  | archive format.
bg-sync_1  |
bg-sync_1  | Update detection may take a while on this run if the replicas are
bg-sync_1  | large.
bg-sync_1  |
bg-sync_1  | Unison will assume that the 'last synchronized state' of both replicas
bg-sync_1  | was completely empty.  This means that any files that are different
bg-sync_1  | will be reported as conflicts, and any files that exist only on one
bg-sync_1  | replica will be judged as new and propagated to the other replica.
bg-sync_1  | If the two replicas are identical, then no changes will be reported.
bg-sync_1  |
bg-sync_1  | If you see this message repeatedly, it may be because one of your machines
bg-sync_1  | is getting its address from DHCP, which is causing its host name to change
bg-sync_1  | between synchronizations.  See the documentation for the UNISONLOCALHOSTNAME
bg-sync_1  | environment variable for advice on how to correct this.
bg-sync_1  |
bg-sync_1  | Donations to the Unison project are gratefully accepted:
bg-sync_1  | http://www.cis.upenn.edu/~bcpierce/unison
bg-sync_1  |

Let that run for a bit. It will take some time depending on how large your application is.

Also, you want to make sure the same volume is mounted at /app/www in both containers - if I'm reading your docker-compose.yml correctly, it's going to be two separate volumes.

Okay, now I've bring the volumes back from global

version: '3'

volumes:
  php_code:

services:

  php:
    volumes:
      - php_code:/app/www

  # this service sync a local dir in your computer with a dir on the app server side
  bg-sync:
    image: cweagans/bg-sync
    volumes:
      - ./app:/source
      - php_code:/app/www
    environment:
      SYNC_VERBOSE: 1
      SYNC_DESTINATION: /app/www
      SYNC_EXTRA_UNISON_PROFILE_OPTS: |
        ignore = Path lmss/vendor
    privileged: true

==> Configuration:
-----> SYNC_SOURCE:                  /source
-----> SYNC_DESTINATION:             /app/www
-----> SYNC_VERBOSE:                 1
----->
-----> IMPORTANT:
----->
-----> You have added additional options to the Unison profile. The capability of doing
-----> so is supported, but the results of what Unison might do are *not*.
----->
-----> Proceed at your own risk.
----->

==> Generating Unison profile

==> Starting continuous sync.

Now seems that starts the syncing but how long should it take?
8000 files (167 MB)

That depends almost entirely on your hard drive speed (and your CPU if you're on a mac). The first time it runs will be the longest. Give it like 30 minutes and see if it has done anything.

Sounds like everything is good here?

If not, let me know and we can reopen.

sorry, I used docker 3.1

this is my file

###############################################################################
#                          Generated on phpdocker.io                          #
###############################################################################
version: "3.1"
volumes:
  php_code:
services:
    redis:
      image: redis:alpine
      container_name: fusion-redis

    php-fpm:
      build: phpdocker/php-fpm
      container_name: fusion-php-fpm
      working_dir: /application
      links:
          - redis:redis
      volumes:
          - php_code:/application
          - ./phpdocker/php-fpm/php-ini-overrides.ini:/etc/php/7.1/fpm/conf.d/99-overrides.ini
          - ./phpdocker/php-fpm/GeoLiteCity.dat:/usr/share/GeoIP/GeoIPRegion.dat

    webserver:
      image: nginx:latest
      container_name: fusion-webserver
      working_dir: /application
      command: [nginx-debug, '-g', 'daemon off;']
      volumes:
          - php_code:/application
          - ./phpdocker/nginx/nginx.conf:/etc/nginx/conf.d/default.conf
      ports:
          - "8080:80"        
      links:
          - php-fpm:php-fpm
          - mysql:mysql

    mysql:
      image: mysql:5.7
      container_name: fusion-mysql
      working_dir: /application
      volumes:
        - ./mysql:/var/lib/mysql
      environment:
        - MYSQL_ROOT_PASSWORD=root
        - MYSQL_DATABASE=platform-scaffold
        - MYSQL_USER=root
        - MYSQL_PASSWORD=root
      ports:
        - "8081:3306"

    bg-sync:
      image: cweagans/bg-sync
      container_name: fusion-bg-sync
      volumes:
        - .:/source
        - php_code:/application
      environment:
        - SYNC_DESTINATION=/application
        - SYNC_MAX_INOTIFY_WATCHES=40000
        - SYNC_VERBOSE=1
      privileged: true

sync is success

but here is problem

first I can find at no matter at php-fpm or webserver or just bg-sync
But
without use bg-sync
I can Work my php page

And when use bg-sync
I can't work php page even phpinfo
my php page total can't read and find