magento-docker is Docker environment for easy to setup, configure, debug Magento2 instance with varnish, elasticsearch, redis, rabbit and mftf tests.
- Git
- Docker
- Docker Compose
- Ensure you do not have dnsmasqinstalled/enabled locally (will be auto-installed if you've use Valet+ to install Magento)
- Add magento.testto/etc/hosts:127.0.0.1 magento.test.
- Create your project directory:
- cd ~/
- mkdir www
- cd www
- chown -R $USER:root .
- chmod g+s .
- Clone magento-dockerinto you project directory:git clone [email protected]:duhon/magento-docker.git)
- Clone magentorepository into your project directory undermagento2cedirectory name:git clone [email protected]:magento/magento2.git magento2ceNow your project directory~/wwwhas 2 folders:magento-docker&magento2ce.
- cp magento-docker/bundles/typical.yml magento-docker/docker-compose.ymlIn- docker-compose.ymlyou can choose what containers and what extensions you really need.
- cp magento-docker/.env.dist magento-docker/.envIn- .envfile environment variables are declared. Here you can change your- MAGENTO_PATHinto your project correct path or change your service containers ports together with- COMPOSE_PROJECT_NAME.
- Enter your magento-dockerrepository:cd ~/www/magento-docker.
- Run docker-compose up. As a result all containers should be up. You can check if containers are up by running:docker-compose ps.
- Check in browser if your magento host is up and running. Enter http://magento.test:80in browser.80is a default port but you can change it in.envfile.
- Install magento: docker-compose exec app magento reinstall. If you want to install ee/b2b versions rundocker-compose exec app magento reinstall <ee|b2b>.
- Magento installed.
- Run docker-compose exec app bash.
- Run docker-compose scale <container_name>=0 && docker-compose scale <container_name>=1. For example:docker-compose scale app=0 && docker-compose scale app=1.
- docker-compose exec app magento prepare_tests
- docker-compose exec app bin/magento dev:tests:run (unit, integration)
- docker-compose exec app bash
- cd dev/tests/acceptance/ and vendor/bin/codecept run (mftf)
- cd dev/tests/functional/ and vendor/bin/phpunit run (mtf)
- vnc://localhost:5900 pass:secret (mftf or mtf)
- To enable xdebug, uncomment xdebug.iniline ofappcontainer indocker-compose.ymland rundocker-compose scale app=0 && docker-compose scale app=1. :warning: Enabled Xdebug may slow your environment.
- docker-compose exec app magento reinstall (ee|b2b)
- Redis optimization
docker run -it --rm --privileged ubuntu /bin/bash echo never | tee /sys/kernel/mm/transparent_hugepage/enabled echo never | tee /sys/kernel/mm/transparent_hugepage/defrag
- Optimization for MacOS
- https://gist.github.com/tombigel/d503800a282fcadbee14b537735d202c
- https://markshust.com/2018/01/30/performance-tuning-docker-mac/
- If docker containers do not go up, check errors in console, run docker-compose down, fix issue and rundocker-compose upagain.
- If Overwrite the existing configuration for db-ssl-verify?[Y/n]prompts in console, typeY.
- If magento installation fails, run docker-compose exec app magento reinstall
- If there is 404 error on /admin page, clean cache by running bin/magento cache:cleancommand insideappcontainer.