magento-docker is Docker environment for easy to set up, configure, debug Magento2 with Live Search instance.
-
(optional - for Mutagen installation only) Install Mutagen docs
-
Ensure you do not have
dnsmasqinstalled/enabled locally (will be auto-installed if you've use Valet+ to install Magento)
-
Create a directory where all repositories will be cloned (used in your IDE)
Proposed structure:
~/projects/livesearch/magento-docker # this repo
~/projects/livesearch/repos # directory with repositories - MAGENTO_PATH in scripts
-
Copy
.env2.4.3in.envand updateMAGENTO_PATHwith recently created repos path. -
Add
$MAGENTO_DOMAINfrom .env to hosts, e.g.:
sudo -- sh -c "echo '127.0.0.1 magento.test >> /etc/hosts"
- Add Magento authentication keys to access the Magento Commerce repository
- copy the contents of
etc/php/auth.json.distto newetc/php/auth.jsonfile and replace placeholders with your credentials.
Note, for the first installation (when you don't have cloned repositories yes) please change settings "RECLONE" to "yes" in ".env" file
MAGENTO_PATH=~/projects/livesearch/reposl # local directory to clone repos into
RECLONE=yes # flag indicate whether do re-clon of all repos or no, set yes to clone at first time
MAGENTO_EDITION=CE # CE|EE|B2B
Notices:
- RUN
mutagen project startto start project (repositories clone, linking, configuration) - Log in to the Admin UI (use
ADMIN_USER/ADMIN_PASSWORDfrom.env), - Navigate to Stores > Configuration > Services > Commerce Services Connector
- Get your QA API credentials from API Portal with Environment as QA and save them in Admin UI.
- Refer to this document for additional information.
- Add MAGENTO_PATH path to Docker sharing folders (Docker preferences) in case docker-error
- If you see certificate errors. Make
https://magento.testcertificate trusted with these steps.
- After first project install you can automate pre-filling of SaaS credentials (pretty useful if you reinstall Magento often)
- Navigate to
etc/php/magento-config.php - find node
services_connectorand fill sub-nodes according to the values fromCommerce Services Connector. - See comments regarding each config value.
-
enter the container (see
docker-composer.ymlfor app name -web,db,app, etc.)
docker-compose exec <app_name> bash->docker-compose exec app bash -
stop all containers
docker-compose stop -
start all containers in background:
docker-compose up -d -
restart all containers:
docker-compose restart -
stop container:
docker-compose stop <app_name> -
start container in background:
docker-compose up -d <app_name> -
restart container:
docker-compose restart <app_name>
-
docker-compose exec app magento prepare_tests -
docker-compose exec app bin/magento dev:tests:run (unit, integration)(:!:) (make sure dbmagento_integration_testscreated before integration tests run) -
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)
- Enable:
mutagen project run xdebug-enable - Disable:
mutagen project run xdebug-disable
❗ port 9003 is used for debug.
docker-compose exec app magento reinstall
- 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
RUN mutagen project terminate
- 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 the console, typeY. - If magento installation fails, run
docker-compose exec app magento reinstall