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
dnsmasq
installed/enabled locally (will be auto-installed if you've use Valet+ to install Magento)
- 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 [email protected]:duhon/magento-docker.git
) - Clone
magento
repository into your project directory undermagento2ce
directory name:git clone [email protected]: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
- 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 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
- If there is 404 error on /admin page, clean cache by running
bin/magento cache:clean
command insideapp
container.