This project aims to offer native performance on all OS systems for users that want to use docker on development. That means same speed as local setups even on Mac and Windows.
Open to read issue explanation
From docker for mac documentation: https://docs.docker.com/docker-for-mac/troubleshoot/#known-issues
There are a number of issues with the performance of directories bind-mounted with osxfs. In particular, writes of small blocks, and traversals of large directories are currently slow. Additionally, containers that perform large numbers of directory operations, such as repeated scans of large directory trees, may suffer from poor performance. Applications that behave in this way include:
- rake
- ember build
- Symfony
- Magento
- Zend Framework
- PHP applications that use Composer to install dependencies in a vendor folder
As a work-around for this behavior, you can put vendor or third-party library directories in Docker volumes, perform temporary file system operations outside of osxfs mounts, and use third-party tools like Unison or rsync to synchronize between container directories and bind-mounted directories. We are actively working on osxfs performance using a number of different techniques. To learn more, see the topic on Performance issues, solutions, and roadmap.
Solution:
- Set full magento app inside a named volume
magento
- Synchronise only git repository files between host and container.
- Everything else is not synchronised, so performance is same as in local setups.
How do you get the code that is not synchronised in your host?
Even if not synchronised, it is needed to have magento and vendor code in your host. Not only for developing but also for xdebug.
To sync that code seamlessly, magento2-dockergento-console uses docker cp
automatically when you execute relevant commands like dockergento composer
or dockergento start
, so you do not need to care about that.
On the other hand, for those that implement modules inside vendor, we also provide a unison
container that watches and syncs changes in background when you develop inside vendor.
See dockergento workflow for a better understanding about whole development process with dockergento.
-
Configure your docker
File Sharing
settings/Users/<user>/Sites
Mac
Optionally you can also apply these performance tweaks
-
Install magento2-dockergento-console
-
Setup docker in your project:
cd <path_to_your_project> dockergento setup
-
[Optional] If you have a multi-store magento, you need to add your website codes to the ngnix configuration as follows:
Open info about ngnix configuration
config/dockergento/nginx/conf/default.conf
# WEBSITES MAPPING map $http_host $MAGE_RUN_CODE { default base; ## For multi-store configuration add here your domain-website codes dominio-es.lo es; dominio-ch.lo ch; dominio-de.lo de; }
dockergento start
dockergento composer install
sudo vim /etc/hosts
// Add -> 127.0.0.1 <your-domain>
See detailed documentation about development workflow with dockergento
magento2-dockergento-console
> Development Workflow
This project has been possible thanks to the following resources:
- docker-magento by @markshust
- Getting Started with Docker for Magento by @mostlymagic
- Docker Background Sync by @cweagans
GNU General Public License, version 3 (GPLv3)
(c) ModestCoders