├── .gitignore ├── .gitmodules ├── README.md ├── bin ├── run_intergration_tests.sh ├── run_unit_tests.sh └── setup.sh ├── composer.env.sample ├── current.env.sample └── docker-compose.yml /.gitignore: -------------------------------------------------------------------------------- 1 | /magento 2 | /test-results 3 | /src 4 | *.env 5 | 6 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "extensions/meanbee-example-magento2-module2"] 2 | path = extensions/meanbee-example-magento2-module2 3 | url = git@github.com:meanbee/example-magento2-module.git 4 | branch = develop 5 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Meanbee Environment Example 2 | 3 | This repository is the development environment that Meanbee are using for their Magento 2 builds. 4 | 5 | This repository will build a Magento 2 instance and inject the configured extensions into it. 6 | 7 | We are currently running: 8 | 9 | * PHP 7 10 | * NGINX 11 | * MySql 12 | 13 | ## Development Environment Setup 14 | 15 | cp composer.env.sample composer.env 16 | cp current.env.sample current.env 17 | 18 | git submodule init 19 | git submodule update --remote 20 | 21 | docker-compose run cli /usr/local/bin/magento-installer 22 | docker-compose run cli /tools/setup.sh 23 | docker-compose up -d 24 | 25 | You can now visit [http://meanbee-environment.docker/](http://meanbee-environment.docker/) 26 | 27 | ### Configuring xDebug 28 | 29 | You'll need to setup path mapping in *Languages & Frameworks -> PHP -> Servers*. Assuming your checkout on your local 30 | machine is `$basedir`, configure the following: 31 | 32 | * `$basedir` -> `/src` 33 | * `$basedir/src` -> `/src/src` 34 | * `$basedir/magento` -> `/magento` 35 | * `$basedir/magento/src` -> `/src` 36 | 37 | ##Running Tests 38 | 39 | To run unit tests: 40 | 41 | docker-compose run --rm cli /tools/run_unit_tests.sh 42 | 43 | To run integration tests: 44 | 45 | docker-compose run --rm cli /tools/run_integration_tests.sh 46 | 47 | ## Adding new extensions 48 | 49 | When adding new submodules we should make sure that we are tracking against a remote branch instead of a specific commit. To do that we need to run the following: 50 | 51 | git submodule add -b develop git@github.com:meanbee/example-magento2-module.git extensions/meanbee-example-magento2-module2 52 | 53 | With the submodule added we now need to ensure that the extension is installed and configured when `bin/setup.sh` is executed. To do this, edit `bin/setup.sh` with: 54 | 55 | * Add local path reference to repository, e.g. `$COMPOSER config repositories.meanbee_example-magento2-module2 path /src/extensions/meanbee-example-magento2-module2` 56 | * Require your package in Magento's `composer.json`, e.g. `$COMPOSER require "meanbee/example-magento2-module2" "*"` 57 | * Enable your extension within Magento (if applicable), e.g. `$MAGENTO_TOOL module:enable Meanbee_ExampleMagento2Module2` 58 | -------------------------------------------------------------------------------- /bin/run_intergration_tests.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -x 2 | 3 | PHP="/usr/local/bin/php -d memory_limit=2G" 4 | PHPUNIT_CONFIGURATION="$MAGENTO_ROOT/dev/tests/integration/phpunit.xml.dist" 5 | MYSQL_CONFIGURATION="$MAGENTO_ROOT/dev/tests/integration/etc/install-config-mysql.php" 6 | PHPUNIT="$PHP $MAGENTO_ROOT/vendor/bin/phpunit -c $PHPUNIT_CONFIGURATION --log-junit /mnt/test-results/junit-integration.xml $*" 7 | 8 | echo " 'db', 16 | 'db-user' => 'root', 17 | 'db-password' => 'magento2', 18 | 'db-name' => 'magento_integration_tests', 19 | 'db-prefix' => '', 20 | 'backend-frontname' => 'backend', 21 | 'admin-user' => \Magento\TestFramework\Bootstrap::ADMIN_NAME, 22 | 'admin-password' => \Magento\TestFramework\Bootstrap::ADMIN_PASSWORD, 23 | 'admin-email' => \Magento\TestFramework\Bootstrap::ADMIN_EMAIL, 24 | 'admin-firstname' => \Magento\TestFramework\Bootstrap::ADMIN_FIRSTNAME, 25 | 'admin-lastname' => \Magento\TestFramework\Bootstrap::ADMIN_LASTNAME, 26 | ]; 27 | " > ${MYSQL_CONFIGURATION} 28 | 29 | ${PHPUNIT} "/src/extensions/meanbee-example-magento2-module/src/Test/Integration" 30 | 31 | exit 0 32 | -------------------------------------------------------------------------------- /bin/run_unit_tests.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -x 2 | 3 | PHP="/usr/local/bin/php -d memory_limit=2G" 4 | PHPUNIT_CONFIGURATION="$MAGENTO_ROOT/dev/tests/unit/phpunit.xml.dist" 5 | PHPUNIT="$PHP $MAGENTO_ROOT/vendor/bin/phpunit -c $PHPUNIT_CONFIGURATION --log-junit /mnt/test-results/junit.xml $*" 6 | 7 | $PHPUNIT "/src/src/extensions/meanbee-example-magento2-module/src/Test/Unit/" 8 | 9 | exit 0 10 | -------------------------------------------------------------------------------- /bin/setup.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | PHP="/usr/local/bin/php" 4 | COMPOSER="$PHP /usr/local/bin/composer" 5 | 6 | MAGENTO_TOOL="magento-command" 7 | 8 | cd $MAGENTO_ROOT 9 | 10 | # This is required because Magento doesn't support the path type in composer 11 | # this is a hack. 12 | ln -s /src/ src 13 | 14 | $COMPOSER config repositories.meanbee_example-magento2-module path /src/extensions/meanbee-example-magento2-module2 15 | 16 | $COMPOSER require "meanbee/example-magento2-module" "*" 17 | 18 | # Required due to us using the "path" type for the repository 19 | $COMPOSER require "composer/composer" "1.0.0-alpha11 as 1.0.0-alpha10" 20 | 21 | $MAGENTO_TOOL module:enable Meanbee_ExampleMagento2Module 22 | $MAGENTO_TOOL setup:upgrade 23 | $MAGENTO_TOOL setup:static-content:deploy 24 | $MAGENTO_TOOL cache:flush 25 | $MAGENTO_TOOL deploy:mode:set developer 26 | -------------------------------------------------------------------------------- /composer.env.sample: -------------------------------------------------------------------------------- 1 | COMPOSER_GITHUB_TOKEN=0000000000000000000000000000000000000000 2 | COMPOSER_MAGENTO_USERNAME=00000000000000000000000000000000 3 | COMPOSER_MAGENTO_PASSWORD=00000000000000000000000000000000 4 | -------------------------------------------------------------------------------- /current.env.sample: -------------------------------------------------------------------------------- 1 | UPDATE_UID_GID=true 2 | PHP_ENABLE_XDEBUG=true -------------------------------------------------------------------------------- /docker-compose.yml: -------------------------------------------------------------------------------- 1 | web: 2 | image: meanbee/magento2-nginx:1.9 3 | ports: 4 | - 80 5 | links: 6 | - fpm 7 | - db 8 | volumes_from: 9 | - appdata 10 | env_file: 11 | - current.env 12 | environment: 13 | - VIRTUAL_HOST=meanbee-environment.docker 14 | - MAGENTO_RUN_MODE=developer 15 | 16 | appdata: 17 | image: tianon/true 18 | volumes: 19 | - ./magento:/var/www/magento 20 | - ./:/src 21 | - ~/.composer/cache:/root/.composer/cache 22 | 23 | fpm: 24 | image: meanbee/magento2-php:7.0-fpm 25 | links: 26 | - db 27 | volumes_from: 28 | - appdata 29 | env_file: 30 | - current.env 31 | environment: 32 | - PHP_MEMORY_LIMIT=2G 33 | 34 | db: 35 | image: mariadb:10.0 36 | ports: 37 | - 3306 38 | volumes_from: 39 | - dbdata 40 | env_file: 41 | - current.env 42 | environment: 43 | - MYSQL_ROOT_PASSWORD=magento2 44 | - MYSQL_DATABASE=magento2 45 | - MYSQL_USER=magento2 46 | - MYSQL_PASSWORD=magento2 47 | 48 | dbdata: 49 | image: tianon/true 50 | volumes: 51 | - /var/lib/mysql 52 | 53 | cli: 54 | image: meanbee/magento2-php:7.0-cli 55 | links: 56 | - db 57 | volumes: 58 | - ./bin:/tools 59 | - ./test-results:/mnt/test-results 60 | volumes_from: 61 | - appdata 62 | env_file: 63 | - composer.env 64 | - current.env 65 | environment: 66 | - PHP_MEMORY_LIMIT=2G 67 | - M2SETUP_DB_HOST=db 68 | - M2SETUP_DB_NAME=magento2 69 | - M2SETUP_DB_USER=magento2 70 | - M2SETUP_DB_PASSWORD=magento2 71 | - M2SETUP_BASE_URL=http://meanbee-environment.docker/ 72 | - M2SETUP_ADMIN_FIRSTNAME=Admin 73 | - M2SETUP_ADMIN_LASTNAME=User 74 | - M2SETUP_ADMIN_EMAIL=dummy@gmail.com 75 | - M2SETUP_ADMIN_USER=magento2 76 | - M2SETUP_ADMIN_PASSWORD=magento2 77 | - M2SETUP_BACKEND_FRONTNAME=admin 78 | - M2SETUP_VERSION=2.0.4 79 | - M2SETUP_USE_SAMPLE_DATA=true 80 | - MAGENTO_ROOT=/var/www/magento 81 | --------------------------------------------------------------------------------