From ec17c5e1e19b29ee730b1ef01fb620e6e689b5ed Mon Sep 17 00:00:00 2001 From: alojua Date: Fri, 21 Sep 2018 13:24:54 +0200 Subject: [PATCH 1/4] Update project settings to be able to install it using new `dockergento setup` command --- CHANGELOG.md | 7 ++ README.md | 70 +++---------------- config/docker/image/app-volumes/Dockerfile | 7 -- .../grumphp/hooks}/commit-msg | 0 .../grumphp/hooks}/pre-commit | 0 .../image/nginx/Dockerfile | 0 .../image/nginx/conf/default.conf | 0 ...r-compose.yml => docker-compose-sample.yml | 32 ++++----- docs/grumphp_setup.md | 4 +- 9 files changed, 33 insertions(+), 87 deletions(-) delete mode 100644 config/docker/image/app-volumes/Dockerfile rename config/{grumphp/hooks/docker => dockergento/grumphp/hooks}/commit-msg (100%) rename config/{grumphp/hooks/docker => dockergento/grumphp/hooks}/pre-commit (100%) rename config/{docker => dockergento}/image/nginx/Dockerfile (100%) rename config/{docker => dockergento}/image/nginx/conf/default.conf (100%) rename docker-compose.yml => docker-compose-sample.yml (76%) diff --git a/CHANGELOG.md b/CHANGELOG.md index 18c8ee4..f9da97b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,13 @@ and this project adheres to [Semantic Version](http://semver.org/spec/v2.0.0.htm ### Removed +## [next release 2.1.0] - 21-09-2018 +### Changed + +* Easier install documentation using `dockergento setup` command +* Set all configuration settings inside `config/dockergento` folder +* Change `docker-compose.yml` filename to `docker-compose-sample.yml` as this file needs to be copied and edited per project. + ## [next release 2.0.0] - 13-09-2018 ### Added diff --git a/README.md b/README.md index 74bcb36..d7baac9 100644 --- a/README.md +++ b/README.md @@ -71,68 +71,20 @@ See [dockergento workflow](#workflow) for a better understanding about whole dev ## Installation -1. Copy this docker configuration repository in your project +1. Install [magento2-dockergento-console](https://github.com/ModestCoders/magento2-dockergento-console) - ``` - cd - curl -L https://api.github.com/repos/ModestCoders/magento2-dockergento/tarball | tar xz --strip=1 - ``` +2. Setup docker in your project: + + ``` + cd + dockergento setup + ``` -2. Edit binded paths or nginx configuration if needed +3. [Optional] If you have a multi-store magento, you need to add your website codes to the ngnix configuration as follows:
- More info about custom configurations - - **Binded Paths:** - - If you install magento code in a different folder than your project root, you might need to replace `` on the following files: - - * `docker-compose.yml` - - ``` - app-volumes: - build: ./config/docker/image/app-volumes - volumes: &appvolumes - - ~/.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: - - magento:/var/www/html/ - - .//vendor:/sync//vendor - environment: - - SYNC_SOURCE_BASE_PATH=/sync/ - - SYNC_DESTINATION_BASE_PATH=/var/www/html/ - - SYNC_MAX_INOTIFY_WATCHES=60000 - ``` - - * `config/docker/image/app-volumes/Dockerfile` - - ``` - RUN mkdir -p /var/www/html/ && chown -R 1000:1000 /var/www/html - ``` - - * `config/docker/image/nginx/conf/default.conf` - - ``` - server { - # ... - set $MAGE_ROOT /var/www/html/; - # ... - ``` - - **Nginx Multi-store:** - - If you have a multi-store magento, you need to add your website codes to the ngnix configuration as follows: - + Open info about ngnix configuration + * `config/docker/image/nginx/conf/default.conf` ``` @@ -148,8 +100,6 @@ See [dockergento workflow](#workflow) for a better understanding about whole dev ```
-3. Install [magento2-dockergento-console](https://github.com/ModestCoders/magento2-dockergento-console) - ## Usage ### Start Application diff --git a/config/docker/image/app-volumes/Dockerfile b/config/docker/image/app-volumes/Dockerfile deleted file mode 100644 index 94ded42..0000000 --- a/config/docker/image/app-volumes/Dockerfile +++ /dev/null @@ -1,7 +0,0 @@ -FROM alpine:latest - -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. -CMD sleep 30 \ No newline at end of file diff --git a/config/grumphp/hooks/docker/commit-msg b/config/dockergento/grumphp/hooks/commit-msg similarity index 100% rename from config/grumphp/hooks/docker/commit-msg rename to config/dockergento/grumphp/hooks/commit-msg diff --git a/config/grumphp/hooks/docker/pre-commit b/config/dockergento/grumphp/hooks/pre-commit similarity index 100% rename from config/grumphp/hooks/docker/pre-commit rename to config/dockergento/grumphp/hooks/pre-commit diff --git a/config/docker/image/nginx/Dockerfile b/config/dockergento/image/nginx/Dockerfile similarity index 100% rename from config/docker/image/nginx/Dockerfile rename to config/dockergento/image/nginx/Dockerfile diff --git a/config/docker/image/nginx/conf/default.conf b/config/dockergento/image/nginx/conf/default.conf similarity index 100% rename from config/docker/image/nginx/conf/default.conf rename to config/dockergento/image/nginx/conf/default.conf diff --git a/docker-compose.yml b/docker-compose-sample.yml similarity index 76% rename from docker-compose.yml rename to docker-compose-sample.yml index 9ebeaeb..6e65fcc 100644 --- a/docker-compose.yml +++ b/docker-compose-sample.yml @@ -1,36 +1,32 @@ version: "3" services: - app-volumes: - build: ./config/docker/image/app-volumes + + phpfpm: + image: modestcoders/php:7.1-fpm volumes: &appvolumes - ~/.composer:/var/www/.composer:delegated - sockdata:/sock - - magento:/var/www/html + - workspace:/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 + # {files_in_git} + environment: + PHP_IDE_CONFIG: serverName=localhost + depends_on: + - db app: - build: ./config/docker/image/nginx + build: ./config/dockergento/image/nginx ports: - 80:8000 volumes: *appvolumes depends_on: - phpfpm - phpfpm: - image: modestcoders/php:7.1-fpm - volumes: *appvolumes - environment: - PHP_IDE_CONFIG: serverName=localhost - depends_on: - - app-volumes - - db - db: image: mysql:5.7 ports: @@ -47,22 +43,22 @@ services: image: modestcoders/node-php:node8-php7.1 volumes: *appvolumes depends_on: - - app-volumes + - phpfpm unison: image: modestcoders/unison:2.51.2 volumes: - - magento:/var/www/html + - workspace:/var/www/html - ./vendor:/sync/vendor environment: - SYNC_SOURCE_BASE_PATH=/sync - SYNC_DESTINATION_BASE_PATH=/var/www/html - SYNC_MAX_INOTIFY_WATCHES=60000 depends_on: - - app-volumes + - phpfpm privileged: true volumes: dbdata: sockdata: - magento: + workspace: diff --git a/docs/grumphp_setup.md b/docs/grumphp_setup.md index 1f0e37a..4caa334 100644 --- a/docs/grumphp_setup.md +++ b/docs/grumphp_setup.md @@ -4,13 +4,13 @@ If you want to use `grumphp` in your `git hooks`, the `grumphp` commands need to This project provides 2 custom `git hook` templates for that: -* [See config/grumphp/hooks/docker](../config/grumphp/hooks/docker) +* [See config/dockergento/grumphp/hooks](../config/dockergento/grumphp/hooks) Use these custom template by adding this in your `composer.json`: ``` "scripts": { - "grumphpTemplates": "cp -Rf config/grumphp/hooks/docker/* vendor/phpro/grumphp/resources/hooks/local/", + "grumphpTemplates": "cp -Rf config/dockergento/grumphp/hooks/* vendor/phpro/grumphp/resources/hooks/local/", "pre-autoload-dump": [ "cp vendor/magento/magento2-base/app/etc/NonComposerComponentRegistration.php app/etc/NonComposerComponentRegistration.php" ], From efd909bcf12247c1c78c873d6d264858bf60ea1b Mon Sep 17 00:00:00 2001 From: alojua Date: Sat, 22 Sep 2018 00:41:15 +0200 Subject: [PATCH 2/4] [Fix] Setting back app-volumes because otherwise there are permissions problems when magento folder is not in workdir root --- .../dockergento/image/app-volumes/Dockerfile | 7 ++++++ docker-compose-sample.yml | 22 +++++++++++-------- 2 files changed, 20 insertions(+), 9 deletions(-) create mode 100644 config/dockergento/image/app-volumes/Dockerfile diff --git a/config/dockergento/image/app-volumes/Dockerfile b/config/dockergento/image/app-volumes/Dockerfile new file mode 100644 index 0000000..94ded42 --- /dev/null +++ b/config/dockergento/image/app-volumes/Dockerfile @@ -0,0 +1,7 @@ +FROM alpine:latest + +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. +CMD sleep 30 \ No newline at end of file diff --git a/docker-compose-sample.yml b/docker-compose-sample.yml index 6e65fcc..e624da1 100644 --- a/docker-compose-sample.yml +++ b/docker-compose-sample.yml @@ -1,9 +1,8 @@ version: "3" services: - - phpfpm: - image: modestcoders/php:7.1-fpm + app-volumes: + build: ./config/dockergento/image/app-volumes volumes: &appvolumes - ~/.composer:/var/www/.composer:delegated - sockdata:/sock @@ -14,10 +13,6 @@ services: - ./composer.json:/var/www/html/composer.json:delegated - ./composer.lock:/var/www/html/composer.lock:delegated # {files_in_git} - environment: - PHP_IDE_CONFIG: serverName=localhost - depends_on: - - db app: build: ./config/dockergento/image/nginx @@ -27,6 +22,15 @@ services: depends_on: - phpfpm + phpfpm: + image: modestcoders/php:7.1-fpm + volumes: *appvolumes + environment: + PHP_IDE_CONFIG: serverName=localhost + depends_on: + - app-volumes + - db + db: image: mysql:5.7 ports: @@ -43,7 +47,7 @@ services: image: modestcoders/node-php:node8-php7.1 volumes: *appvolumes depends_on: - - phpfpm + - app-volumes unison: image: modestcoders/unison:2.51.2 @@ -55,7 +59,7 @@ services: - SYNC_DESTINATION_BASE_PATH=/var/www/html - SYNC_MAX_INOTIFY_WATCHES=60000 depends_on: - - phpfpm + - app-volumes privileged: true volumes: From 5a567e4b68483ab0ea7e6246c7c8caa00e038b13 Mon Sep 17 00:00:00 2001 From: alojua Date: Sat, 22 Sep 2018 01:14:41 +0200 Subject: [PATCH 3/4] Set commend placeholder to replace binded git files in uppercase --- docker-compose-sample.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker-compose-sample.yml b/docker-compose-sample.yml index e624da1..0012f05 100644 --- a/docker-compose-sample.yml +++ b/docker-compose-sample.yml @@ -12,7 +12,7 @@ services: - ./config:/var/www/html/config:delegated - ./composer.json:/var/www/html/composer.json:delegated - ./composer.lock:/var/www/html/composer.lock:delegated - # {files_in_git} + # {FILES_IN_GIT} app: build: ./config/dockergento/image/nginx From 69b5d4bf69093780808a8de67a15b189168ae6f9 Mon Sep 17 00:00:00 2001 From: alojua Date: Sun, 23 Sep 2018 00:56:18 +0200 Subject: [PATCH 4/4] Rename docker-compose sample file --- docker-compose-sample.yml => docker-compose.sample.yml | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename docker-compose-sample.yml => docker-compose.sample.yml (100%) diff --git a/docker-compose-sample.yml b/docker-compose.sample.yml similarity index 100% rename from docker-compose-sample.yml rename to docker-compose.sample.yml