magento-docker
is Docker environment for easy to setup, configure, debug Magento2 instance with varnish, elasticsearch, redis, rabbit and mftf tests.
- Add
magento.test
to/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-docker
into you project directory:git clone git@github.com:duhon/magento-docker.git
) - Clone
magento
repository into your project directory undermagento2ce
directory name:git clone git@github.com:magento/magento2.git magento2ce
Now your project directory~/www
has 2 folders:magento-docker
&magento2ce
. cp magento-docker/bundles/typical.yml magento-docker/docker-compose.yml
Indocker-compose.yml
you can choose what containers and what extensions you really need.cp magento-docker/.env.dist magento-docker/.env
In.env
file environment variables are declared. Here you can change yourMAGENTO_PATH
into your project correct path or change your service containers ports together withCOMPOSE_PROJECT_NAME
.- Enter your
magento-docker
repository: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:80
in browser.80
is a default port but you can change it in.env
file. - 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.ini
line ofapp
container indocker-compose.yml
and 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
- If docker containers do not go up, check errors in console, run
docker-compose down
, fix issue and rundocker-compose up
again. - 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
- To create a cross platform installer that will check for dependencies, create a folder with the project and download the Magento (see install.sh)
- The default creation of the project for phpstorm (see etc/phpstorm)
- A single point of running tests with the preparation (magento prepare_tests) of Magento