BaDos / magento-docker

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

magento-docker

magento-docker is Docker environment for easy to set up, configure, debug Magento 2.

Requirements

  • Git

  • Docker

  • Docker Compose

  • Setup SSH-keys on your github account. (see docs for help)

  • Install Mutagen docs

  • Ensure you do not have dnsmasq installed/enabled locally (will be auto-installed if you've use Valet+ to install Magento 2)

How to install

Steps

  1. Create a directory where all repositories will be cloned (used in your IDE)

    Proposed structure:

    ~/www/magento-docker                    # This repo
    ~/www/repos/magento2ce                  # Magento 2 repo (If you want to install a version other than CE, then simply deploy files of the required version and or extensions to this directory over the files from CE)
  1. Add magento.test to hosts:
    sudo -- sh -c "echo '127.0.0.1 magento.test' >> /etc/hosts"
  1. Copy .env.dist in .env and update the variables you need.

  2. Optionally, you can update file etc/php/tools/pre-scripts to add custom dependencies or run other commands before installation.

  3. Optionally, you can update file etc/php/tools/post-scripts to run custom commands after installation.

Project start

  • RUN mutagen project start to start project (Magento 2 install, Magento 2 configuration apply)

Generate performance profile

  • RUN docker-compose exec app bash to connect to docker container
  • RUN cd magento2ce to go to the root directory of the project
  • RUN bin/magento setup:performance:generate-fixtures -s setup/performance-toolkit/profiles/PROFILE_EDITION/PROFILE_SIZE.xml to generate performance profile. . Instead of PROFILE_EDITION and PROFILE_SIZE - specify your Magento edition and required profile size
  • RUN bin/magento indexer:reindex to execute reindex command
  • RUN bin/magento cache:flush to execute cache flush command

Cron run

  • RUN docker-compose exec app bash to connect to docker container
  • RUN cd magento2ce to go to the root directory of the project
  • RUN bin/magento cron:run to execute cron command

Reindex run

  • RUN docker-compose exec app bash to connect to docker container
  • RUN cd magento2ce to go to the root directory of the project
  • RUN bin/magento indexer:reindex to execute reindex command

Change indexers mode

  • RUN docker-compose exec app bash to connect to docker container
  • RUN cd magento2ce to go to the root directory of the project
  • RUN bin/magento indexer:set-mode realtime to set realtime indexers mode
  • RUN bin/magento indexer:set-mode schedule to set schedule indexers mode

Cache flush

  • RUN docker-compose exec app bash to connect to docker container
  • RUN cd magento2ce to go to the root directory of the project
  • RUN bin/magento cache:flush to execute cache flush command

Upgrade run

  • RUN docker-compose exec app bash to connect to docker container
  • RUN cd magento2ce to go to the root directory of the project
  • RUN bin/magento setup:upgrade to execute upgrade command
  • RUN bin/magento cache:flush to execute cache flush command

DI compile

  • RUN docker-compose exec app bash to connect to docker container
  • RUN cd magento2ce to go to the root directory of the project
  • RUN bin/magento setup:di:compile to execute di compile command
  • RUN bin/magento cache:flush to execute cache flush command

Static content deploy

  • RUN docker-compose exec app bash to connect to docker container
  • RUN cd magento2ce to go to the root directory of the project
  • RUN bin/magento setup:static-content:deploy to execute static-content deploy command

Enable production mode

  • RUN docker-compose exec app bash to connect to docker container
  • RUN cd magento2ce to go to the root directory of the project
  • RUN bin/magento deploy:mode:set production to execute enable production mode command

DB query-log

  • RUN docker-compose exec app bash to connect to docker container
  • RUN cd magento2ce to go to the root directory of the project
  • RUN bin/magento dev:query-log:enable to enable DB query-log

Tests execution

  • RUN docker-compose exec app bash to connect to docker container
  • RUN cd magento2ce to go to the root directory of the project

MFTF

  • RUN vendor/bin/mftf run:test MftfTestName to run MFTF test. Instead of MftfTestName - specify the real name of the test

PHP Unit

  • RUN vendor/phpunit/phpunit/phpunit --configuration /var/www/magento2ce/dev/tests/unit/phpunit.xml.dist app/code/PhpUnitTestPath to run PHP Unit test. Instead of PhpUnitTestPath - specify the real PHP Unit test path of the test

Integration

  • RUN rm -rf generated/code && rm -rf generated/metadata in case of errors in Magento installation before running the Integration test
  • RUN vendor/phpunit/phpunit/phpunit --configuration /var/www/magento2ce/dev/tests/integration/phpunit.xml.dist dev/tests/integration/testsuite/IntegrationTestPath to run Integration test. Instead of IntegrationTestPath - specify the real integration test path of the test

Api Functional

  • RUN vendor/phpunit/phpunit/phpunit --configuration /var/www/magento2ce/dev/tests/api-functional/phpunit_rest.xml.dist dev/tests/api-functional/testsuite/ApiFunctionalTestPath to run Api Functional test. Instead of ApiFunctionalTestPath - specify the real Api Functional test path of the test

JMeter execution

  • You can log in to the JMeter GUI using the link - vnc://magento.test:5902 and password - password

Enable/disable Xdebug

  • Enable: mutagen project run xdebug-enable
  • Disable: mutagen project run xdebug-disable

⚠️ Enabled Xdebug may slow your environment.

❗ port 9003 is used for debug.

Enable/disable uopz (Depends on the availability of the necessary extension in the PHP image used)

  • Enable: mutagen project run uopz-enable
  • Disable: mutagen project run uopz-disable

❗ for example, this extension is present in PHP image: slopukhov/php:8.1.19-fpm

Enable/disable xhprof (Depends on the availability of the necessary extension in the PHP image used)

  • Enable: mutagen project run xhprof-enable
  • Disable: mutagen project run xhprof-disable

❗ for example, this extension is present in PHP image: slopukhov/php:8.2.12-fpm

Enable/disable php-spx (Depends on the availability of the necessary extension in the PHP image used)

  • Enable: mutagen project run spx-enable
  • Disable: mutagen project run spx-disable

Add parameters ?SPX_KEY=dev&SPX_ENABLED=1 to your URL to measure this URL. Example: https://magento.test/?SPX_KEY=dev&SPX_ENABLED=1

Open with your browser the following URL: https://magento.test/?SPX_KEY=dev&SPX_UI_URI=/ to access to the spx web UI control panel with measurement results.

❗ for example, this extension is present in PHP image: slopukhov/php:8.2.8-fpm

Enable/disable tideways (Depends on the availability of the necessary extension in the PHP image used)

  • Enable: mutagen project run tideways-enable
  • Disable: mutagen project run tideways-disable

❗ for example, this extension is present in PHP image: slopukhov/php:7.3.33-fpm

Emails sending

Sent emails will be saved in folder ~/www/magento2ce/var/tmp/mails/ as .htm files

Project flushing sessions (to flush the synchronization sessions associated with a project)

  • RUN mutagen project flush

Project resetting sessions (to reset the synchronization sessions associated with a project)

  • RUN mutagen project reset

Project termination (removes all containers and volumes)

  • RUN mutagen project terminate

About

License:MIT License


Languages

Language:Shell 45.1%Language:Roff 33.7%Language:PHP 21.2%