From 30a4ef29483b2e26c5a0744a7d332f798e7a2edd Mon Sep 17 00:00:00 2001 From: alojua Date: Thu, 13 Sep 2018 14:02:47 +0200 Subject: [PATCH] Change volumes configuration to use only one one volume for the whole magento app instead of 6 specific ones. - Reason is a Docker bug with named volumes inside bind mounts: https://github.com/moby/moby/issues/26157#issuecomment-419722589 --- CHANGELOG.md | 20 +++++++++ README.md | 52 ++++++++++------------ config/docker/image/app-volumes/Dockerfile | 8 +--- docker-compose.yml | 35 +++++++-------- 4 files changed, 60 insertions(+), 55 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 341c48c..18c8ee4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,26 @@ and this project adheres to [Semantic Version](http://semver.org/spec/v2.0.0.htm ### Removed +## [next release 2.0.0] - 13-09-2018 +### Added + +### Changed + +* Set whole magento application in a named volume `magento` instead of using 6 volumes: + + ``` + app-vendor + app-generated + app-var + pub-static + pub-media + integration-test-sandbox + ``` + + * Reason: Bug when having volumes inside a file bind mount: [#26157](https://github.com/moby/moby/issues/26157#issuecomment-419722589) + +### Removed + ## [1.3.0] - 05-09-2018 ### Changed diff --git a/README.md b/README.md index 46c49de..d2f11a6 100644 --- a/README.md +++ b/README.md @@ -39,17 +39,19 @@ As a work-around for this behavior, you can put vendor or third-party library di **Solution:** -* Use docker volumes for following directories: +* Set full magento app inside a named volume `magento` +* Synchronise only git repository files between host and container. +* Everything else is not synchronised, so performance is same as in local setups. - * vendor - * generated - * var - * pub/static - * pub/media +**How do you get the code that is not synchronised in your host?** -* Custom synchronisation of `vendor` and `generated`: - * These volumes are synchronised seamless thanks to [magento2-dockergento-console](https://github.com/ModestCoders/magento2-dockergento-console) - * See [dockergento workflow](#workflow) for a better understanding about whole development process with dockergento. +Even if not synchronised, it is needed to have magento and vendor code in your host. Not only for developing but also for xdebug. + +To sync that code seamlessly, [magento2-dockergento-console](https://github.com/ModestCoders/magento2-dockergento-console) uses `docker cp` automatically when you execute relevant commands like `dockergento composer` or `dockergento start`, so you do not need to care about that. + +On the other hand, for those that implement modules inside vendor, we also provide a `unison` container that watches and syncs changes in background when you develop inside vendor. + +See [dockergento workflow](#workflow) for a better understanding about whole development process with dockergento. ## Preconditions @@ -87,23 +89,23 @@ As a work-around for this behavior, you can put vendor or third-party library di app-volumes: build: ./config/docker/image/app-volumes volumes: &appvolumes - - .:/var/www/html:delegated - - ~/.composer:/var/www/.composer:delegated - - sockdata:/sock - - app-vendor:/var/www/html//vendor - - app-generated:/var/www/html//generated - - app-var:/var/www/html//var - - pub-static:/var/www/html//pub/static - - pub-media:/var/www/html//pub/media - - integration-test-sandbox:/var/www/html//dev/tests/integration/tmp + - ~/.composer:/var/www/.composer:delegated + - sockdata:/sock + - magento:/var/www/html/ + - ./app:/var/www/html//app:delegated + - ./.git:/var/www/html/.git:delegated + - ./config:/var/www/html/config:delegated + - ./composer.json:/var/www/html/composer.json:delegated + - ./composer.lock:/var/www/html/composer.lock:delegated + # Add here the rest of files and folders in your git repository that you want to bind between host and container unison: image: modestcoders/unison:2.51.2 volumes: - - app-vendor:/var/www/html//vendor - - ./vendor:/sync/vendor + - magento:/var/www/html/ + - .//vendor:/sync//vendor environment: - - SYNC_SOURCE_BASE_PATH=/sync + - SYNC_SOURCE_BASE_PATH=/sync/ - SYNC_DESTINATION_BASE_PATH=/var/www/html/ - SYNC_MAX_INOTIFY_WATCHES=60000 ``` @@ -111,13 +113,7 @@ As a work-around for this behavior, you can put vendor or third-party library di * `config/docker/image/app-volumes/Dockerfile` ``` - RUN mkdir -p /var/www/html//vendor \ - /var/www/html//generated \ - /var/www/html//var \ - /var/www/html//pub/static \ - /var/www/html//pub/media \ - /var/www/html//dev/tests/integration/tmp \ - && chown -R 1000:1000 /var/www/html/ + RUN mkdir -p /var/www/html/ && chown -R 1000:1000 /var/www/html ``` * `config/docker/image/nginx/conf/default.conf` diff --git a/config/docker/image/app-volumes/Dockerfile b/config/docker/image/app-volumes/Dockerfile index 6fc193c..94ded42 100644 --- a/config/docker/image/app-volumes/Dockerfile +++ b/config/docker/image/app-volumes/Dockerfile @@ -1,12 +1,6 @@ FROM alpine:latest -RUN mkdir -p /var/www/html/vendor \ - /var/www/html/generated \ - /var/www/html/var \ - /var/www/html/pub/static \ - /var/www/html/pub/media \ - /var/www/html/dev/tests/integration/tmp \ - && chown -R 1000:1000 /var/www/html +RUN mkdir -p /var/www/html && chown -R 1000:1000 /var/www/html # Keep container running until all other containers are created. # This avoid issues when this container is started multiple times. diff --git a/docker-compose.yml b/docker-compose.yml index bf0a283..9ebeaeb 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -4,15 +4,15 @@ services: app-volumes: build: ./config/docker/image/app-volumes volumes: &appvolumes - - .:/var/www/html:delegated - ~/.composer:/var/www/.composer:delegated - sockdata:/sock - - app-vendor:/var/www/html/vendor - - app-generated:/var/www/html/generated - - app-var:/var/www/html/var - - pub-static:/var/www/html/pub/static - - pub-media:/var/www/html/pub/media - - integration-test-sandbox:/var/www/html/dev/tests/integration/tmp + - magento:/var/www/html + - ./app:/var/www/html/app:delegated + - ./.git:/var/www/html/.git:delegated + - ./config:/var/www/html/config:delegated + - ./composer.json:/var/www/html/composer.json:delegated + - ./composer.lock:/var/www/html/composer.lock:delegated + # Add here the rest of files and folders in your git repository that you want to bind between host and container app: build: ./config/docker/image/nginx @@ -43,10 +43,16 @@ services: volumes: - dbdata:/var/lib/mysql + node: + image: modestcoders/node-php:node8-php7.1 + volumes: *appvolumes + depends_on: + - app-volumes + unison: image: modestcoders/unison:2.51.2 volumes: - - app-vendor:/var/www/html/vendor + - magento:/var/www/html - ./vendor:/sync/vendor environment: - SYNC_SOURCE_BASE_PATH=/sync @@ -56,18 +62,7 @@ services: - app-volumes privileged: true - node: - image: modestcoders/node-php:node8-php7.1 - volumes: *appvolumes - depends_on: - - app-volumes - volumes: dbdata: sockdata: - app-vendor: - app-generated: - app-var: - pub-static: - pub-media: - integration-test-sandbox: + magento: