magento-docker
is Docker environment for easy to set up, configure, debug Magento2 with Live Search instance.
-
Install Mutagen docs
-
Ensure you do not have
dnsmasq
installed/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
.env.dist
in.env
and updateMAGENTO_PATH
with recently created repos path.DOCKER_PATH
is the path to which magento-docker was cloned (~/projects/livesearch/magento-docker
in example). -
Add
$MAGENTO_DOMAIN
from .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.dist
to newetc/php/auth.json
file 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 start
to start project (repositories clone, linking, configuration) - If you're getting the error
init_project: line 16: export:
#NEW_REPOS': not a valid identifierand don't use
NEW_REPOS, delete that line safely in
.env` file. - Log in to the Admin UI (use
ADMIN_USER
/ADMIN_PASSWORD
from.env
), - Navigate to Stores > Configuration > Services > Commerce Services Connector
- Get your QA API credentials from DEV API Portal with Environment as QA and save them in Admin UI.
- Get your PROD API credentials from API Portal with Environment as Production and save them in Admin UI.
- Refer to this document for additional information.
- to sync products with SaaS run the following commands:
bin/magento saas:resync --feed productattributes
bin/magento saas:resync --feed products
bin/magento saas:resync --feed categories
bin/magento saas:resync --feed categoryPermissions
bin/magento saas:resync --feed prices
bin/magento saas:resync --feed productOverrides
bin/magento saas:resync --feed variants
bin/magento saas:resync --feed scopesWebsite
bin/magento saas:resync --feed scopesCustomerGroup
- to sync product updates simply run
bin/magento cron:run
bin/magento cron:run
If you have issues with mutagen files sync (no changes from host reflected in files in containers, sync errors if running mutagen sync list
), do the following:
- run
mutagen sync list
to get list of syncs, output may look like this:
Name: code
Identifier: sync_rFbovEduhlHv6ZOFWlNt4WFaWPRmHEU44fiNbhZXMwv
Labels:
io.mutagen.project: proj_h8cbq5g9tO2MZw278MeyeyizVJtHRujJyWbLYd5wnhm
Alpha:
URL: /Users/ruslankostiv/projects/livesearch/repos
Connection state: Connected
Beta:
URL: docker://web-mutagen/var/www
Connection state: Connected
Status: Watching for changes
- use sync identifier (
sync_rFbovEduhlHv6ZOFWlNt4WFaWPRmHEU44fiNbhZXMwv
in example above) to flush the sync,mutagen sync flush sync_rFbovEduhlHv6ZOFWlNt4WFaWPRmHEU44fiNbhZXMwv
- navigate to folder where Magento repositories were cloned (
MAGENTO_PATH
from.env
, for example~/projects/livesearch/repos
) - clone GitHub needed repositories into
MAGENTO_PATH
folder (git clone https://github.com/magento-commerce/saas-prices-provider
. for example) - navigate to app container (
docker-compose exec app bash
) - to create symlinks to Magento project, command from reinstall script will be used
- run
php -f /var/www/magento2ee/dev/tools/build-ee.php -- --command link --exclude true --ce-source /var/www/magento2ce/app/code/Magento --ee-source /var/www/${edition}
, replace${edition}
with name of folder was created after cloning GitHub repository (for examplesaas-prices-provider
) - to make sure that extension available, run
bin/magento module:status
and check that extension is in the list of disabled modules. - run
bin/magento module:enable <module_list_of_modules>
to enable them - run
bin/magento setup:upgrade
to apply extension changes - if there's an error
Module does not exist
it means cloned repositories were not synced between host and container after they cloned. To fix it, follow "Container files sync issues" steps.
- Add MAGENTO_PATH path to Docker sharing folders (Docker preferences) in case docker-error
- If you see certificate errors. Make
https://magento.test
certificate 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.dist
- copy it to
etc/php/magento-config.php
(available locally, ignored for commits) - find node
services_connector
and fill sub-nodes according to the values fromCommerce Services Connector
. - See comments regarding each config value.
-
enter the container (see
docker-composer.yml
for 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>
-
remove container:
docker-compose rm <app_name>
(will remove container, but not volumes)
MailHog is used to receive emails sent by Magento, navigate to http://localhost:8025/ to see them.
-
docker-compose exec app magento prepare_tests
-
docker-compose exec app bin/magento dev:tests:run (unit, integration)
(:!:) (make sure dbmagento_integration_tests
created 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.
-
Once xdebug in enabled, create a new PHP CLI Interpretor with SSH Configuration:
-
Then, create a new Run/Debug Configuration with path mapping:
docker-compose exec app magento relink
docker-compose exec app magento reinstall
RUN mutagen project terminate
- 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 the console, typeY
. - If magento installation fails, run
docker-compose exec app magento reinstall