Skip to content

LucianRadu/magento-docker

 
 

Repository files navigation

magento-docker

magento-docker is Docker environment for easy to set up, configure, debug Magento2 with Live Search instance.

Requirements

  • Git

  • Docker

  • Docker Compose

  • Setup SSH-keys on your github account. (see docs for help)

  • (optional - for Mutagen installation only) Install Mutagen docs

  • Ensure you do not have dnsmasq installed/enabled locally (will be auto-installed if you've use Valet+ to install Magento)

How to install

Steps

  1. 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
  1. Copy .env2.4.3 in .env and update MAGENTO_PATH with recently created repos path.

  2. Add $MAGENTO_DOMAIN from .env to hosts, e.g.:

    sudo -- sh -c "echo '127.0.0.1 magento.test >> /etc/hosts"
  1. Add Magento authentication keys to access the Magento Commerce repository
  • copy the contents of etc/php/auth.json.dist to new etc/php/auth.json file and replace placeholders with your credentials.

Project start

Note, for the first installation (when you don't have cloned repositories yes) please change settings "RECLONE" to "yes" in ".env" file

Configuration

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:

Project install

  • RUN mutagen project start to start project (repositories clone, linking, configuration)
  • 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 API Portal with Environment as QA and save them in Admin UI.
  • Refer to this document for additional information.

Troubleshooting

  • 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.

Scenarios

SaaS connector credentials setup

  • 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_connector and fill sub-nodes according to the values from Commerce Services Connector.
  • See comments regarding each config value.

Container operations

  • 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>

Run tests (in progress, can be not stable)

  1. docker-compose exec app magento prepare_tests

  2. docker-compose exec app bin/magento dev:tests:run (unit, integration) (:!:) (make sure db magento_integration_tests created before integration tests run)

  3. docker-compose exec app bash

  4. cd dev/tests/acceptance/ and vendor/bin/codecept run (mftf)

  5. cd dev/tests/functional/ and vendor/bin/phpunit run (mtf)

  6. vnc://localhost:5900 pass:secret (mftf or mtf)

Enable/disable Xdebug

  • Enable: mutagen project run xdebug-enable
  • Disable: mutagen project run xdebug-disable

⚠️ Enabled Xdebug may slow your environment.
❗ port 9003 is used for debug.

Magento (Re)-Installation

  • docker-compose exec app magento reinstall

Optimization host

  1. 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
    
  2. Optimization for MacOS

Project termination (:!: proceed with caution, removes all containers and volumes)

RUN mutagen project terminate

FAQ

  1. If docker containers do not go up, check errors in console, run docker-compose down, fix issue and run docker-compose up again.
  2. If Overwrite the existing configuration for db-ssl-verify?[Y/n] prompts in the console, type Y.
  3. If magento installation fails, run docker-compose exec app magento reinstall

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages

  • PHP 37.2%
  • Shell 29.8%
  • Roff 12.0%
  • VCL 11.4%
  • JavaScript 6.0%
  • Dockerfile 3.6%