Ver código fonte

Add Windows compatibility

Soeren Zorn 7 anos atrás
pai
commit
3aff06aac6

+ 28 - 0
README.md

@@ -71,6 +71,34 @@ git init
 
 7. You may now access your site at `http://magento2.test` (or whatever domain you setup).
 
+## Setup a New Magento 2 Project in Windows
+
+1. Setup a new project using the Magento 2 compose skeleton:
+
+```
+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
+```
+
+2. Download the Magento source code to the `src` folder with: `./bin/download 2.2.2`. Note that the default untar app is quite slow. If you want to speed that up install [7-Zip](http://www.7-zip.de/) and add it to your PATH. It will automatically use 7-Zip if it is available.
+
+3. Copy magento into the docker container with `./bin/copymagento`. This is needed because of mounting restrictions from Windows to Docker. The folders `app/code`, `app/design` and `app/i18n` will however be mounted into the container for ease of development.
+
+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.
+
+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.
+
+7. You may now access your site at `http://magento2.test` (or whatever domain you 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.

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

@@ -0,0 +1 @@
+./bin/cli bash

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

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

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

@@ -0,0 +1 @@
+docker-compose exec phpfpm composer $args

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

@@ -0,0 +1 @@
+docker-compose run --user=root --no-deps --rm -v $PWD/src/.:/source phpfpm cp -r /source/. /var/www/html

+ 27 - 0
compose/magento-2-windows/bin/download.ps1

@@ -0,0 +1,27 @@
+[CmdletBinding()]
+Param(
+  [Parameter(Mandatory=$True,Position=1)]
+  [string]$version
+)
+function Expand-Targz($tarFile, $dest) {
+  if (Get-Command "7z.exe" -ErrorAction SilentlyContinue) {
+    & cmd.exe "/C 7z x $tarFile.tar.gz -so | 7z x -aoa -si -ttar -o$dest"
+    Remove-Item "$tarFile.tar.gz"
+  }
+  else {
+    if (-not (Get-Command Expand-7Zip -ErrorAction Ignore)) {
+      Install-Package -Scope CurrentUser -Force 7Zip4PowerShell > $null
+    }
+    Expand-7Zip "$tarFile.tar.gz" $dest
+    Expand-7Zip "$tarFile.tar" $dest
+    Remove-Item "$tarFile.tar.gz"
+    Remove-Item "$tarFile.tar"
+  }
+}
+
+If( -not (Test-Path -Path .\src) )
+{
+    mkdir .\src | Out-Null
+}
+Start-BitsTransfer "http://pubfiles.nexcess.net/magento/ce-packages/magento2-$version.tar.gz" ".\src\magento2-$version.tar.gz"
+Expand-Targz ".\src\magento2-$version" ".\src"

+ 8 - 0
compose/magento-2-windows/bin/fixperms.ps1

@@ -0,0 +1,8 @@
+Write-Host "Correcting filesystem permissions..."
+
+./bin/rootcli chown -R app:app /var/www
+./bin/rootcli find var vendor pub/static pub/media app/etc -type f -exec chmod u+w `{`} `;
+./bin/rootcli find var vendor pub/static pub/media app/etc -type d -exec chmod u+w `{`} `;
+./bin/rootcli chmod u+x bin/magento
+
+Write-Host "Filesystem permissions corrected."

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

@@ -0,0 +1 @@
+docker-compose exec phpfpm ./bin/magento $args

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

@@ -0,0 +1,6 @@
+if ($args.length -eq 0) {
+    Write-Host "Please specify a CLI command (ex. ls)"
+    exit
+} else {
+    docker-compose exec --user=root phpfpm $args
+}

+ 25 - 0
compose/magento-2-windows/bin/setup.ps1

@@ -0,0 +1,25 @@
+./bin/cli chmod u+x bin/magento
+
+docker-compose exec phpfpm /usr/local/bin/php ./bin/magento setup:install `
+  --db-host=db `
+  --db-name=magento `
+  --db-user=magento `
+  --db-password=magento `
+  --base-url=http://magento2.test/ `
+  --admin-firstname=Admin `
+  --admin-lastname=User `
+  --admin-email=dummy@gmail.com `
+  --admin-user=magento2user `
+  --admin-password=magento2 `
+  --language=en_US `
+  --currency=USD `
+  --timezone=America/New_York
+
+./bin/fixperms
+
+echo "Turning on developer mode.."
+./bin/magento deploy:mode:set developer
+
+./bin/magento indexer:reindex
+
+./bin/magento cache:enable

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

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

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

@@ -0,0 +1,14 @@
+[CmdletBinding()]
+Param(
+  [Parameter(Mandatory=$True,Position=1)]
+  [string]$enable_disable_xdebug
+)
+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
+  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
+  Write-Host "Xdebug has been enabled."
+} else {
+  Write-Host "Please specify either 'enable' or 'disable' as an argument"
+}

+ 48 - 0
compose/magento-2-windows/docker-compose.yml

@@ -0,0 +1,48 @@
+# Mark Shust's Docker Configuration for Magento (https://github.com/markoshust/docker-magento)
+# Version 12.0.0
+
+version: "3"
+
+services:
+  app:
+    image: markoshust/magento-nginx:1.13
+    ports:
+      - 80:8000
+    links:
+      - db
+      - phpfpm
+    volumes: &appvolumes
+      - appdata:/var/www/html
+      - ./src/app/code:/var/www/html/app/code:delegated
+      - ./src/app/design:/var/www/html/app/design:delegated
+      - ./src/app/i18n:/var/www/html/app/i18n:delegated
+      - ~/.composer:/var/www/html/var/composer_home:delegated
+      - sockdata:/sock
+
+  phpfpm:
+    image: markoshust/magento-php:7.1-fpm
+    links:
+      - db
+    volumes: *appvolumes
+
+  cron:
+    image: markoshust/magento-php:7.1-fpm
+    user: root
+    command: /usr/local/bin/cronstart
+    tty: true
+    links:
+      - db
+    volumes: *appvolumes
+
+  db:
+    image: percona:5.7
+    ports:
+      - 3306:3306
+    env_file: env/db.env
+    volumes:
+      - dbdata:/var/lib/mysql
+
+volumes:
+  dbdata:
+  sockdata:
+  appdata:

+ 4 - 0
compose/magento-2-windows/env/db.env

@@ -0,0 +1,4 @@
+MYSQL_ROOT_PASSWORD=magento
+MYSQL_DATABASE=magento
+MYSQL_USER=magento
+MYSQL_PASSWORD=magento

+ 1 - 0
compose/magento-2-windows/src/.gitignore

@@ -0,0 +1 @@
+!.gitignore