MGT Development Environment - File Sync
File Synchronization on MacOS
To work with a PHP IDE like PhpStorm on your host system, you need to sync your code into the container.
The integrated file sharing solution from docker is very slow and not recommended for Magento 2.
To have a good performance, we need to sync the files from the host system into the container.
For the two-way file-synchronization, we use the great tool Unison.
Setup Unison on MacOS
To work with Unison, it's very important to have the right versions installed.
- Download Unison and extract the file tar.gz and copy the binary
bin/unison
to/usr/local/bin
:
- Open the terminal and install xcode, pip and macfsevents which are needed for unison-fsmonitor.
Python 3
For pip, python 3 is required. You can install it via Homebrew.
Install python 3 via brew.
Set python 3 as default:
- Install the unison-fsmonitor binary:
- Create a sync.sh file for each project you want to sync.
In our example, we want to sync the files from our host system into the container from:
/Users/admin/PhpstormProjects/magento2.mgt/
to
/home/cloudpanel/htdocs/magento2.mgt
We create the file:
/Users/admin/PhpstormProjects/magento2.mgt/bin/sync.sh
with the following content:
Permissions
Make sure the file sync.sh is executable.
To make it executable run: chmod 775 sync.sh
- Start file-synchronisation
Enter the password root to start the file-synchronization.
File Synchronization on Linux
With linux, you can mount a directory from your host to the container without setting up two-way sync.
Run the MGT Development Environment Docker Container with a volume.
File Synchronization on Windows
Setup Unison on Windows
To work with Unison, it's very important to have the right versions installed.
- Download and Install OpenSSH.
- Download Unison.
Download Unison and extract files to: C:\Program Files\unison
- Create a file sync.bat for each project you want to sync.
In our example, we want to sync the files from our host system into the container from
C:\Users\admin\PhpstormProjects\magento2.mgt\
to
/home/cloudpanel/htdocs/magento2.mgt/
For this we create the file:
C:\Users\admin\PhpstormProjects\magento2.mgt\bin\sync.bat
with the following content:
- Start the file synchronization.
To start the file synchronization open the PowerShell and run sync.bat file
Troubleshooting
If you see the error message "Fatal error: inconsistent state. The archive file is missing on some hosts", do the following:
- Delete unison archives on host system with the following command:
- Delete the unison archive in container:
- Start the sync process again.