magento-docker
is Docker environment for easy to set up, configure, debug Magento 2.
-
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)
-
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)
- Add
magento.test
to hosts:
sudo -- sh -c "echo '127.0.0.1 magento.test' >> /etc/hosts"
-
Copy
.env.dist
in.env
and update the variables you need. -
Optionally, you can update file
etc/php/tools/pre-scripts
to add custom dependencies or run other commands before installation. -
Optionally, you can update file
etc/php/tools/post-scripts
to run custom commands after installation.
- RUN
mutagen project start
to start project (Magento 2 install, Magento 2 configuration apply)
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- You can log in to the JMeter GUI using the link -
vnc://magento.test:5902
and password -password
- Enable:
mutagen project run xdebug-enable
- Disable:
mutagen project run xdebug-disable
❗ port 9003
is used for debug.
- 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
Sent emails will be saved in folder ~/www/magento2ce/var/tmp/mails/
as .htm files
- RUN
mutagen project flush
- RUN
mutagen project reset
- RUN
mutagen project terminate