Bladeren bron

Added one line setup & updated volume mount setup. See CHANGELOG for full details.

Mark Shust 6 jaren geleden
bovenliggende
commit
f7cf5766c2

+ 21 - 0
CHANGELOG.md

@@ -8,6 +8,27 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
 
 - New PHP 7.2 image is now available on the dev tag. Please report any issues.
 
+## [18.0.0] - 2018-10-06
+
+### Changed
+- Changed the way bind mounts work with Docker compose and Magento 2.
+    - Note that `bin/start` now includes a call to `bin/copydirall` after the containers start. This helper script runs a `docker cp` command of all Magento directories from the container to the host. There is still a bind mount setup to `./src` root directory.
+    - There is a condition/bug within Docker that when named volumes overlap with bind mounts, the named volumes automatically sync back to the host once a `docker cp` command runs, while retaining their named volume status within the Docker container.
+    - We're tapping into this very odd bug and taking advantage of this as long as we can. Since data is still fetched from within the Docker container as a named volume, this should also allow not-so-performant computers to now run this Docker setup, as it provides near or truly native filesystem performance, since requests to these directories are still fetched through the named volume as far as Docker is concerned.
+- `bin/start` now runs in daemon mode, as we also need to run `bin/copydirall` immediately after starting containers so data syncs back to the host (and vice versa). This also eliminates the need to to have a terminal window open all the time for keeping containers running.
+
+### Added
+- Added back support for Magento 1 and PHP 5.6 containers. Magento 1 EOL will not be until 2020, so we should support these images and Docker Compose setup indefinitely for the time being.
+- Added new `bin/restart` helper script to stop and start all containers.
+- Added new `bin/remove` helper script to remove all containers.
+- Added new `bin/copydir` which copies whichever folder you wish from the container to the host.
+- Added new `bin/copydirall` which copies all Magento folders from the container to the host.
+- Added `lib/template` and `lib/onelinesetup` for much easier installation methods.
+- Added automatic Xdebug support for VS Code - no setup needed!
+
+### Removed
+- Removed `bin/initloopback` along with any references to `10.254.254.254` ip address. This may break existing Xdebug setups. Note that this ip address has been replaced with `host.docker.internal`, which should automatically resolve back to the host machine.
+
 ## [17.0.1] - 2018-10-06
 
 ### Removed

+ 81 - 92
README.md

@@ -15,7 +15,8 @@ View Dockerfiles:
   - 7.2
       - [`dev`, `7.2-fpm`](https://github.com/markoshust/docker-magento/tree/master/images/php/7.2)
   - 7.1
-      - [`latest`, `7.1-fpm`, `7.1-fpm-8`](https://github.com/markoshust/docker-magento/tree/master/images/php/7.1)
+      - [`latest`, `7.1-fpm`, `7.1-fpm-9`](https://github.com/markoshust/docker-magento/tree/master/images/php/7.1)
+      - [`7.1-fpm-8`](https://github.com/markoshust/docker-magento/tree/17.0.1/images/php/7.1)
       - [`7.1-fpm-7`](https://github.com/markoshust/docker-magento/tree/16.2.0/images/php/7.1)
       - [`7.1-fpm-6`](https://github.com/markoshust/docker-magento/tree/16.0.0/images/php/7.1)
       - [`7.1-fpm-5`](https://github.com/markoshust/docker-magento/tree/15.0.1/images/php/7.1)
@@ -25,7 +26,8 @@ View Dockerfiles:
       - [`7.1-fpm-1`](https://github.com/markoshust/docker-magento/tree/11.1.5/images/php/7.1)
       - [`7.1-fpm-0`](https://github.com/markoshust/docker-magento/tree/11.0.0/images/php/7.1)
   - 7.0
-      - [`7.0-fpm`, `7.0-fpm-8`](https://github.com/markoshust/docker-magento/tree/master/images/php/7.0)
+      - [`7.0-fpm`, `7.0-fpm-9`](https://github.com/markoshust/docker-magento/tree/master/images/php/7.0)
+      - [`7.0-fpm-8`](https://github.com/markoshust/docker-magento/tree/17.0.1/images/php/7.0)
       - [`7.0-fpm-7`](https://github.com/markoshust/docker-magento/tree/16.2.0/images/php/7.0)
       - [`7.0-fpm-6`](https://github.com/markoshust/docker-magento/tree/16.0.0/images/php/7.0)
       - [`7.0-fpm-5`](https://github.com/markoshust/docker-magento/tree/15.0.1/images/php/7.0)
@@ -34,8 +36,8 @@ View Dockerfiles:
       - [`7.0-fpm-2`](https://github.com/markoshust/docker-magento/tree/13.0.0/images/php/7.0)
       - [`7.0-fpm-1`](https://github.com/markoshust/docker-magento/tree/11.1.5/images/php/7.0)
       - [`7.0-fpm-0`](https://github.com/markoshust/docker-magento/tree/11.0.0/images/php/7.0)
-  - 5.6 [NO LONGER MAINTAINED]
-      - [`5.6-fpm`, `5.6-fpm-6`](https://github.com/markoshust/docker-magento/tree/16.0.0/images/php/5.6)
+  - 5.6
+      - [`5.6-fpm`, `5.6-fpm-6`](https://github.com/markoshust/docker-magento/tree/master/images/php/5.6)
       - [`5.6-fpm-5`](https://github.com/markoshust/docker-magento/tree/15.0.1/images/php/5.6)
       - [`5.6-fpm-4`](https://github.com/markoshust/docker-magento/tree/15.0.0/images/php/5.6)
       - [`5.6-fpm-3`](https://github.com/markoshust/docker-magento/tree/14.0.1/images/php/5.6)
@@ -58,71 +60,82 @@ The PHP images are fairly agnostic to which version of Magento you are running.
 
 ## Prerequisites
 
-This setup assumes you are running Docker on a computer with at least 16GB RAM, a quad-core, and an SSD hard drive. [Download & Install Docker Community Edition](https://www.docker.com/community-edition#/download).
+This setup assumes you are running Docker on a computer with at least 8GB RAM, a dual-core, and an SSD hard drive. [Download & Install Docker Community Edition](https://www.docker.com/community-edition#/download).
 
-This configuration has been tested on Mac, but should also work on Mac, Windows and Linux.
+This configuration has been tested on Mac, Linux and Windows.
 
-If you are using a Mac, it is strongly recommended for you to apply [these performance tuning changes](http://markshust.com/2018/01/30/performance-tuning-docker-mac) to Docker for Mac before starting.
+## Automated One Line Setup & Quick Setup (NEW!)
 
-## Setup a New Magento 2 Project
+### One Line Setup
+
+> Magento 2, OS X & Linux Only
 
-1. Setup a new project using the Magento 2 compose skeleton:
+Run this automated one-liner from the directory you want to install your project to:
 
 ```
-mkdir magento2 && cd $_
-git init
-git remote add origin git@github.com:markoshust/docker-magento.git
-git fetch origin
-git checkout origin/master -- compose/magento-2
-mv compose/magento-2/* .
-rm -rf compose .git
-git init
+curl https://raw.githubusercontent.com/markoshust/docker-magento/master/lib/onelinesetup|bash -s - mymagento.test 2.2.6
 ```
 
-2. Download the Magento source code to the `src` folder with: `bin/download 2.2.4`
+The `mymagento.test` above defines the hostname to use, and the `2.2.6` defines the Magento version to install. Note that since we need a write to `/etc/hosts` for DNS resolution, you will be prompted for your system password during setup.
+
+After the one-liner above completes running, you should be able to access your site at `http://mymagento.test`.
+
+### Manual Quick Setup
+
+Same result as the one-liner above. Just replace `mymagento` references with the hostname that you wish to setup.
+
+```
+# Quick setup for a new instance of Magento 2, using magento226.test as a base:
+curl https://raw.githubusercontent.com/markoshust/docker-magento/master/lib/template|bash -s - magento-2
+bin/download 2.2.6
+echo "127.0.0.1 mymagento.test" | sudo tee -a /etc/hosts
+bin/start
+bin/setup mymagento.test
+open http://mymagento.test
+```
+
+## Setup a New Magento 2 Project
+
+1. Create the project template by going to the place you want the new project (ex. cd ~/Sites/magento2), then run
+	- `curl https://raw.githubusercontent.com/markoshust/docker-magento/master/lib/template|bash -s - magento-2`
 
-3. Setup your ip loopback for proper IP resolution with Docker: `bin/initloopback`
+2. Extract the contents of your current Magento site to the `src` folder, or download a fresh copy of the Magento source code for starting a new project with:
+    - `bin/download 2.2.6`
 
-4. Add an entry to `/etc/hosts` with your custom domain: `10.254.254.254 magento2.test` (assuming the domain  you want to setup is `magento2.test`). Be sure to use a `.test` tld, as `.localhost` and `.dev` will present issues with domain resolution.
+3. Add an entry to your local hosts file with your custom domain. Assuming the domain you want to setup is `magento2.test`, enter the below. Be sure to use a `.test` tld, as `.localhost` and `.dev` will present issues with domain resolution.
+    - `echo "127.0.0.1 magento226.test" | sudo tee -a /etc/hosts`
 
-5. Start your Docker containers with: `bin/start`.
+4. Start your Docker containers with the provided helper script:
+    - `bin/start`
 
-6. Run Magento's setup install process with the command: `bin/setup`. Feel free to edit this file to your liking; at the very least you will probably need to update the `base-url` value to the domain you setup in step 6. Also, be sure to setup [Composer Authentication](https://github.com/markoshust/docker-magento#composer-authentication) before initiating the setup script.
+5. For new projects: run Magento's setup install process with the below helper script. Feel free to edit this file to your liking; at the very least you will probably need to update the `base-url` value to the domain you setup in step 3. Also, be sure to setup [Composer Authentication](https://github.com/markoshust/docker-magento#composer-authentication) before initiating the setup script.
+    - `bin/setup`
 
-7. You may now access your site at `http://magento2.test` (or whatever domain you setup).
+6. You may now access your site! Check out whatever domain you setup from within a web browser.
+    - `open http://magento2.test`
 
-## Setup a New Magento 2 Project in Windows
+## Setup a New Magento 2 Project (Windows)
 
 The following scripts are meant to run with Powershell. Note that the execution policy for scripts needs to be set accordingly [Execution policy](https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.security/get-executionpolicy?view=powershell-6).
 
-1. Setup a new project using the Magento 2 compose skeleton:
-(Run this with a bash-like terminal)
-```
-mkdir magento2 && cd $_
-git init
-git remote add origin git@github.com:markoshust/docker-magento.git
-git fetch origin
-git checkout origin/master -- compose/magento-2-windows
-mv compose/magento-2-windows/* .
-rm -rf compose .git
-git init
-```
+1. Create the project template by going to the place you want the new project (ex. cd ~/Sites/magento2), then run
+	- `curl https://raw.githubusercontent.com/markoshust/docker-magento/master/lib/template|bash -s - magento-2-windows`
 
-2. Download the Magento source code to the `src` folder with: `bin/download 2.2.2`. Note that the default untar command is quite slow. If you want to speed that up install [7-Zip](http://www.7-zip.org/) and add it to your PATH. The script will automatically use 7-Zip if it is available.
+2. Extract the contents of your current Magento site to the `src` folder, or download a fresh copy of the Magento source code for starting a new project with the following line. Note that the default untar command is quite slow. If you want to speed that up install [7-Zip](http://www.7-zip.org/) and add it to your PATH. The script will automatically use 7-Zip if it is available:
+    - `bin/download 2.2.6`
 
 3. Copy magento into the docker container with `bin/copymagento`. This is needed because of permission restrictions of shared data in Windows (see [Troubleshooting Docker](https://docs.docker.com/docker-for-windows/troubleshoot/#permissions-errors-on-data-directories-for-shared-volumes)). The `app` folder will however be shared with Windows for ease of development. For this folder the default permission 755 works just fine.
 
 4. Add an entry to `C:\Windows\System32\drivers\etc\hosts` with your custom domain: `127.0.0.1 magento2.test` (assuming the domain  you want to setup is `magento2.test`). Be sure to use a `.test` tld, as `.localhost` and `.dev` will present issues with domain resolution.
 
-5. Start your Docker containers with: `bin/start`.
-
-6. Run Magento's setup install process with the command: `bin/setup`. Feel free to edit this file to your liking; at the very least you will probably need to update the `base-url` value to the domain you setup in step 6. Also, be sure to setup [Composer Authentication](https://github.com/markoshust/docker-magento#composer-authentication) before initiating the setup script.
+5. Start your Docker containers with the provided helper script:
+    - `bin/start`
 
-7. You may now access your site at `http://magento2.test` (or whatever domain you setup).
+6. For new projects: run Magento's setup install process with the below helper script. Feel free to edit this file to your liking; at the very least you will probably need to update the `base-url` value to the domain you setup in step 4. Also, be sure to setup [Composer Authentication](https://github.com/markoshust/docker-magento#composer-authentication) before initiating the setup script.
+    - `bin/setup`
 
-## Existing Magento Project Setup
-
-See the `compose` folder for sample setups for both Magento 1 and Magento 2. Basically your source code should go in the `src` folder, and you can then kick your project off with `bin/start`. You may have to complete a few of the steps above to get things functioning properly.
+7. You may now access your site! Check out whatever domain you setup from within a web browser.
+    - `open http://magento2.test`
 
 ## Custom CLI Commands
 
@@ -130,24 +143,43 @@ See the `compose` folder for sample setups for both Magento 1 and Magento 2. Bas
 - `bin/dev-urn-catalog-generate`: Generate URN's for PHPStorm and remap paths to local host. Restart PHPStorm after running this command.
 - `bin/cli`: Run any CLI command without going into the bash prompt. Ex. `bin/cli ls`
 - `bin/composer`: Run the composer binary. Ex. `bin/composer install`
+- `bin/copydir`: Copy a directory from the container to the host. Ex. `bin/copydir vendor`
+- `bin/copydirall`: Copy all Magento directories from the container to the host. Ex. `bin/copydirall`
 - `bin/download`: Download a version of Magento to the `src` directory. Ex. `bin/download 2.2.2`
 - `bin/fixperms`: This will fix filesystem ownerships and permissions within Docker.
 - `bin/grunt`: Run the grunt binary. Note that this runs the version from the node_modules directory for project version parity. Ex. `bin/grunt exec`
-- `bin/initloopback`: Setup your ip loopback for proper Docker ip resolution.
 - `bin/magento`: Run the Magento CLI. Ex: `bin/magento cache:flush`
 - `bin/node`: Run the node binary. Ex. `bin/node --version`
 - `bin/npm`: Run the npm binary. Ex. `bin/npm install`
+- `bin/remove`: Remove all containers. Ex. `bin/remove`
+- `bin/restart`: Stop and then start all containers. Ex. `bin/restart`
 - `bin/root`: Run any CLI command as root without going into the bash prompt. Ex `bin/root apt-get install nano`
-- `bin/setup`: Run the Magento setup process to install Magento from the source code.
-- `bin/start`: Start the Docker Compose process and your app. Ctrl+C to stop the process.
-- `bin/stop`: Stop the Docker Compose process and your app. Use if Ctrl+C isn't working or to stop the containers from another shell.
+- `bin/setup`: Run the Magento setup process to install Magento from the source code. Ex. `bin/setup`
+- `bin/start`: Start all containers. This includes helper for bi-directional file sync, so be sure to use this instead of `docker-compose up -d`. Ex. `bin/start`
+- `bin/stop`: Stop all containers. Ex. `bin/stop`
 - `bin/xdebug`: Disable or enable Xdebug. Ex. `bin/xdebug enable`
 
 ## Misc Info
 
 ### Database
 
-- The hostname of each service is the name of the service within the `docker-compose.yml` file. So for example, MySQL's hostname is `db` (not `localhost`) when accessing it from a Docker container.
+- The hostname of each service is the name of the service within the `docker-compose.yml` file. So for example, MySQL's hostname is `db` (not `localhost`) when accessing it from within a Docker container.
+
+### Composer Authentication
+
+First setup Magento Marketplace authentication (details in the [DevDocs](http://devdocs.magento.com/guides/v2.0/install-gde/prereq/connect-auth.html)).
+
+After doing so, copy the auth sample file to:
+
+- `cp ./src/auth.json.sample ./src/auth.json`
+
+Then update the username and password values with your Magento public and private keys, respectively.
+
+### Xdebug & VS Code
+
+Install and enable the PHP Debug extension from the [Visual Studio Marketplace](https://marketplace.visualstudio.com/items?itemName=felixfbecker.php-debug).
+
+Otherwise, this project now automatically sets up Xdebug support with VS Code. If you wish to set this up manually, please see the [`.vscode/launch.json`](https://github.com/markoshust/docker-magento/blame/master/compose/magento-2/.vscode/launch.json) file.
 
 ### Xdebug & PHPStorm
 
@@ -179,46 +211,3 @@ Open `PHPStorm > Preferences > Languages & Frameworks > PHP > Servers` and creat
 Create a new `PHP Remote Debug` configuration at `Run > Edit Configurations`. Set the Name to your domain (ex. `magento2.test`), then click OK.
 
 Open up `src/pub/index.php`, and set a breakpoint near the end of the file. Go to `Run > Debug 'magento2.test'`, and open up a web browser. Xdebug within PHPStorm should now enable the debugger and stop at the toggled breakpoint.
-
-### Xdebug & VS Code
-
-Install and enable the PHP Debug extension from the [Visual Studio Marketplace](https://marketplace.visualstudio.com/items?itemName=felixfbecker.php-debug).
-
-Create or edit the file at `.vscode/launch.json`:
-
-```
-{
-  "version": "0.2.0",
-  "configurations": [
-    {
-      "name": "Listen for XDebug",
-      "type": "php",
-      "request": "launch",
-      "pathMappings": {
-        "/var/www/html": "${workspaceFolder}/src"
-      },
-      "port": 9001
-    }
-  ]
-}
-```
-
-Open up `src/pub/index.php`, and set a breakpoint near the end of the file. Go to `Debug > Start Debugging`, and open up a web browser. Xdebug within VS Code should now enable the debugger and stop at the toggled breakpoint.
-
-
-### Composer Authentication
-
-Please first setup Magento Marketplace authentication (details in the [DevDocs](http://devdocs.magento.com/guides/v2.0/install-gde/prereq/connect-auth.html)).
-
-Update the auth credentials within `./src/auth.json`, replacing your public and private key respectively:
-
-```
-{
-    "http-basic": {
-        "repo.magento.com": {
-            "username": "MAGENTO_PUBLIC_KEY",
-            "password": "MAGENTO_PRIVATE_KEY"
-        }
-    }
-}
-```

+ 2 - 0
compose/magento-1/bin/remove

@@ -0,0 +1,2 @@
+#!/bin/bash
+docker-compose rm

+ 3 - 0
compose/magento-1/bin/restart

@@ -0,0 +1,3 @@
+#!/bin/bash
+docker-compose stop
+docker-compose up -d

+ 1 - 1
compose/magento-1/bin/start

@@ -1,2 +1,2 @@
 #!/bin/bash
-docker-compose up
+docker-compose up -d

+ 1 - 1
compose/magento-1/docker-compose.yml

@@ -1,5 +1,5 @@
 # Mark Shust's Docker Configuration for Magento (https://github.com/markoshust/docker-magento)
-# Version 17.0.1
+# Version 18.0.0
 
 version: "3"
 

+ 14 - 0
compose/magento-2-windows/.vscode/launch.json

@@ -0,0 +1,14 @@
+{
+  "version": "0.2.0",
+  "configurations": [
+    {
+      "name": "Listen for XDebug",
+      "type": "php",
+      "request": "launch",
+      "pathMappings": {
+        "/var/www/html": "${workspaceFolder}/src"
+      },
+      "port": 9001
+    }
+  ]
+}

+ 1 - 1
compose/magento-2-windows/bin/cli.ps1

@@ -2,5 +2,5 @@ if ($args.length -eq 0) {
     Write-Host "Please specify a CLI command (ex. ls)"
     exit
 } else {
-    docker-compose exec phpfpm $args
+    docker-compose exec -T phpfpm $args
 }

+ 6 - 0
compose/magento-2-windows/bin/copydir.ps1

@@ -0,0 +1,6 @@
+[CmdletBinding()]
+Param(
+  [Parameter(Mandatory=$True,Position=1)]
+  [string]$dir
+)
+docker cp $(docker-compose ps|grep phpfpm|awk '{print $dir}'):/var/www/html/$dir src/

+ 11 - 0
compose/magento-2-windows/bin/copydirall.ps1

@@ -0,0 +1,11 @@
+bin/copydir app
+bin/copydir bin
+bin/copydir dev
+bin/copydir generated
+bin/copydir lib
+bin/copydir phpserver
+bin/copydir pub
+bin/copydir setup
+bin/copydir update
+bin/copydir var
+bin/copydir vendor

+ 1 - 0
compose/magento-2-windows/bin/restart.ps1

@@ -0,0 +1 @@
+docker-compose rm

+ 4 - 2
compose/magento-2-windows/bin/setup.ps1

@@ -1,11 +1,13 @@
 bin/cli chmod u+x bin/magento
 
-docker-compose exec phpfpm /usr/local/bin/php bin/magento setup:install `
+BASE_URL=${1:-magento2.test}
+
+bin/cli bin/magento setup:install `
   --db-host=db `
   --db-name=magento `
   --db-user=magento `
   --db-password=magento `
-  --base-url=http://magento2.test/ `
+  --base-url=http://$BASE_URL/ `
   --admin-firstname=John `
   --admin-lastname=Smith `
   --admin-email=john.smith@gmail.com `

+ 5 - 1
compose/magento-2-windows/bin/start.ps1

@@ -1 +1,5 @@
-docker-compose up
+docker-compose up -d
+
+echo "Initiating bi-directional sync between host & containers..."
+bin/copydirall
+echo "All containers have started successfully."

+ 2 - 0
compose/magento-2-windows/bin/xdebug.ps1

@@ -5,9 +5,11 @@ Param(
 )
 if ( "$enable_disable_xdebug" -eq "disable" ) {
   bin/cli sed -i -e 's/^zend_extension/\;zend_extension/g' /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
+  bin/restart
   Write-Host "Xdebug has been disabled."
 } elseif ( "$enable_disable_xdebug" -eq "enable" ) {
   bin/cli sed -i -e 's/^\;zend_extension/zend_extension/g' /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
+  bin/restart
   Write-Host "Xdebug has been enabled."
 } else {
   Write-Host "Please specify either 'enable' or 'disable' as an argument"

+ 14 - 4
compose/magento-2-windows/docker-compose.yml

@@ -1,5 +1,5 @@
 # Mark Shust's Docker Configuration for Magento (https://github.com/markoshust/docker-magento)
-# Version 17.0.1
+# Version 18.0.0
 
 version: "3"
 
@@ -13,19 +13,29 @@ services:
       - phpfpm
     volumes: &appvolumes
       - ./src:/var/www/html:delegated
-      - ~/.composer:/var/www/html/var/composer_home:delegated
       - ~/.composer:/var/www/.composer:delegated
       - appdata:/sock
+      - appdata:/var/www/html/app
+      - appdata:/var/www/html/bin
+      - appdata:/var/www/html/dev
+      - appdata:/var/www/html/generated
+      - appdata:/var/www/html/lib
+      - appdata:/var/www/html/phpserver
+      - appdata:/var/www/html/pub
+      - appdata:/var/www/html/setup
+      - appdata:/var/www/html/update
+      - appdata:/var/www/html/var
+      - appdata:/var/www/html/vendor
 
   phpfpm:
-    image: markoshust/magento-php:7.1-fpm-8
+    image: markoshust/magento-php:7.1-fpm-9
     links:
       - db
     volumes: *appvolumes
 
   # Disabling cron by default as it uses higher CPU, enable if needed
   #cron:
-  #  image: markoshust/magento-php:7.1-fpm-8
+  #  image: markoshust/magento-php:7.1-fpm-9
   #  user: root
   #  command: /usr/local/bin/cronstart
   #  tty: true

+ 14 - 0
compose/magento-2/.vscode/launch.json

@@ -0,0 +1,14 @@
+{
+  "version": "0.2.0",
+  "configurations": [
+    {
+      "name": "Listen for XDebug",
+      "type": "php",
+      "request": "launch",
+      "pathMappings": {
+        "/var/www/html": "${workspaceFolder}/src"
+      },
+      "port": 9001
+    }
+  ]
+}

+ 1 - 1
compose/magento-2/bin/cli

@@ -1,3 +1,3 @@
 #!/bin/bash
 [ -z "$1" ] && echo "Please specify a CLI command (ex. ls)" && exit
-docker-compose exec phpfpm "$@"
+docker-compose exec -T phpfpm "$@"

+ 3 - 0
compose/magento-2/bin/copydir

@@ -0,0 +1,3 @@
+#!/bin/bash
+[ -z "$1" ] && echo "Please specify a directory to copy (ex. vendor)" && exit
+docker cp $(docker-compose ps|grep phpfpm|awk '{print $1}'):/var/www/html/$1 src/

+ 12 - 0
compose/magento-2/bin/copydirall

@@ -0,0 +1,12 @@
+#!/bin/bash
+bin/copydir app
+bin/copydir bin
+bin/copydir dev
+bin/copydir generated
+bin/copydir lib
+bin/copydir phpserver
+bin/copydir pub
+bin/copydir setup
+bin/copydir update
+bin/copydir var
+bin/copydir vendor

+ 0 - 31
compose/magento-2/bin/initloopback

@@ -1,31 +0,0 @@
-#!/bin/bash
-
-################################################################################
-# macOS
-################################################################################
-sudo ifconfig lo0 alias 10.254.254.254 255.255.255.0
-sudo bash -c "curl https://raw.githubusercontent.com/markoshust/magento-docker/master/lib/com.network.alias.plist > /Library/LaunchDaemons/com.network.alias.plist"
-sudo chmod 0644 /Library/LaunchDaemons/com.network.alias.plist
-sudo chown root:wheel /Library/LaunchDaemons/com.network.alias.plist
-sudo launchctl load /Library/LaunchDaemons/com.network.alias.plist
-
-################################################################################
-# Fedora
-################################################################################
-# To enable immediately:
-#sudo ip addr add 10.254.254.254 dev lo label lo:0
-#
-# To persist after reboots:
-# edit file at /etc/sysconfig/network-scripts/ifcfg-lo:0 with the following configuration values:
-#
-#ISALIAS=yes
-#DEVICE=lo:0
-#ONBOOT=yes
-#BOOTPROTO=none
-#IPADDR=10.254.254.254
-#NETMASK=255.255.255.0
-#TYPE=Ethernet
-#
-# Aftewards, create the following symlinks:
-#ln /etc/sysconfig/network-scripts/ifcfg-lo:0 /etc/sysconfig/networking/devices/ifcfg-lo:0
-#ln /etc/sysconfig/network-scripts/ifcfg-lo:0 /etc/sysconfig/networking/profiles/default/ifcfg-lo:0

+ 2 - 0
compose/magento-2/bin/remove

@@ -0,0 +1,2 @@
+#!/bin/bash
+docker-compose rm

+ 3 - 0
compose/magento-2/bin/restart

@@ -0,0 +1,3 @@
+#!/bin/bash
+bin/stop
+bin/start

+ 1 - 1
compose/magento-2/bin/root

@@ -1,3 +1,3 @@
 #!/bin/bash
 [ -z "$1" ] && echo "Please specify a CLI command (ex. ls)" && exit
-docker-compose exec -u root phpfpm "$@"
+docker-compose exec -T -u root phpfpm "$@"

+ 4 - 2
compose/magento-2/bin/setup

@@ -1,12 +1,14 @@
 #!/bin/bash
 bin/cli chmod u+x bin/magento
 
-docker-compose exec phpfpm /usr/local/bin/php ./bin/magento setup:install \
+BASE_URL=${1:-magento2.test}
+
+bin/cli bin/magento setup:install \
   --db-host=db \
   --db-name=magento \
   --db-user=magento \
   --db-password=magento \
-  --base-url=http://magento2.test/ \
+  --base-url=http://$BASE_URL/ \
   --admin-firstname=John \
   --admin-lastname=Smith \
   --admin-email=john.smith@gmail.com \

+ 5 - 1
compose/magento-2/bin/start

@@ -1,2 +1,6 @@
 #!/bin/bash
-docker-compose up
+docker-compose up -d
+
+echo "Initiating bi-directional sync between host & containers..."
+bin/copydirall
+echo "All containers have started successfully."

+ 2 - 0
compose/magento-2/bin/xdebug

@@ -1,9 +1,11 @@
 #!/bin/bash
 if [ "$1" == "disable" ]; then
   bin/cli sed -i -e 's/^zend_extension/\;zend_extension/g' /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
+  bin/restart
   echo "Xdebug has been disabled."
 elif [ "$1" == "enable" ]; then
   bin/cli sed -i -e 's/^\;zend_extension/zend_extension/g' /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
+  bin/restart
   echo "Xdebug has been enabled."
 else
   echo "Please specify either 'enable' or 'disable' as an argument"

+ 14 - 4
compose/magento-2/docker-compose.yml

@@ -1,5 +1,5 @@
 # Mark Shust's Docker Configuration for Magento (https://github.com/markoshust/docker-magento)
-# Version 17.0.1
+# Version 18.0.0
 
 version: "3"
 
@@ -13,19 +13,29 @@ services:
       - phpfpm
     volumes: &appvolumes
       - ./src:/var/www/html:delegated
-      - ~/.composer:/var/www/html/var/composer_home:delegated
       - ~/.composer:/var/www/.composer:delegated
       - appdata:/sock
+      - appdata:/var/www/html/app
+      - appdata:/var/www/html/bin
+      - appdata:/var/www/html/dev
+      - appdata:/var/www/html/generated
+      - appdata:/var/www/html/lib
+      - appdata:/var/www/html/phpserver
+      - appdata:/var/www/html/pub
+      - appdata:/var/www/html/setup
+      - appdata:/var/www/html/update
+      - appdata:/var/www/html/var
+      - appdata:/var/www/html/vendor
 
   phpfpm:
-    image: markoshust/magento-php:7.1-fpm-8
+    image: markoshust/magento-php:7.1-fpm-9
     links:
       - db
     volumes: *appvolumes
 
   # Disabling cron by default as it uses higher CPU, enable if needed
   #cron:
-  #  image: markoshust/magento-php:7.1-fpm-8
+  #  image: markoshust/magento-php:7.1-fpm-9
   #  user: root
   #  command: /usr/local/bin/cronstart
   #  tty: true

+ 1 - 3
images/php/5.6/conf/php.ini

@@ -4,11 +4,9 @@ zlib.output_compression = On
 cgi.fix_pathinfo = 0
 date.timezone = UTC
 
-xdebug.idekey = PHPSTORM
 xdebug.remote_autostart = 1
-xdebug.remote_connect_back = 0
 xdebug.remote_enable = 1
-xdebug.remote_host = 10.254.254.254
+xdebug.remote_host = host.docker.internal
 xdebug.remote_port = 9001
 
 upload_max_filesize = 20M

+ 1 - 1
images/php/7.0/conf/php.ini

@@ -6,7 +6,7 @@ date.timezone = UTC
 
 xdebug.remote_autostart = 1
 xdebug.remote_enable = 1
-xdebug.remote_host = 10.254.254.254
+xdebug.remote_host = host.docker.internal
 xdebug.remote_port = 9001
 
 upload_max_filesize = 20M

+ 1 - 1
images/php/7.1/conf/php.ini

@@ -6,7 +6,7 @@ date.timezone = UTC
 
 xdebug.remote_autostart = 1
 xdebug.remote_enable = 1
-xdebug.remote_host = 10.254.254.254
+xdebug.remote_host = host.docker.internal
 xdebug.remote_port = 9001
 
 upload_max_filesize = 20M

+ 1 - 1
images/php/7.2/conf/php.ini

@@ -6,7 +6,7 @@ date.timezone = UTC
 
 xdebug.remote_autostart = 1
 xdebug.remote_enable = 1
-xdebug.remote_host = 10.254.254.254
+xdebug.remote_host = host.docker.internal
 xdebug.remote_port = 9001
 
 upload_max_filesize = 20M

+ 0 - 24
lib/com.network.alias.plist

@@ -1,24 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
-<plist version="1.0">
- <dict>
-   <key>Label</key>
-   <string>com.network.alias</string>
-   <key>ProgramArguments</key>
-   <array>
-        <string>ifconfig</string>
-        <string>lo0</string>
-        <string>alias</string>
-        <string>10.254.254.254</string>
-        <string>255.255.255.0</string>
-	</array>
-   <key>RunAtLoad</key>
-   <true/>   
-   <key>StandardOutPath</key>
-   <string>/var/log/com.network.alias.log</string>
-   <key>StandardErrorPath</key>
-   <string>/var/log/com.network.alias.log</string>
-   <key>Debug</key>
-   <true/>
- </dict>
-</plist>

+ 9 - 0
lib/onelinesetup

@@ -0,0 +1,9 @@
+#!/bin/bash
+DOMAIN=${1:-magento2.test}
+VERSION=${2:-2.2.6}
+
+curl https://raw.githubusercontent.com/markoshust/docker-magento/master/lib/template|bash -s - magento-2
+bin/download $VERSION
+echo "127.0.0.1 $DOMAIN" | sudo tee -a /etc/hosts
+bin/start
+bin/setup $DOMAIN

+ 9 - 0
lib/template

@@ -0,0 +1,9 @@
+#!/bin/bash
+git init -qqq
+git remote add origin git@github.com:markoshust/docker-magento.git
+git fetch origin -qqq
+git checkout origin/master -- compose/$1
+mv compose/$1/* ./
+mv compose/$1/.vscode ./
+rm -rf compose .git
+git init