Locally, we can use the Docker for Windows or Docker for MAC as the development environment for the application. However, if you plan to use Docker data volumes to store the application code, especially the application of the file more, such as Drupal, you will feel particularly slow when running it. This is because Docker for Windows and Docker for MAC use localized virtual technology to provide us with a more downstream experience, but the performance of data volumes is a temporary problem that cannot be solved. I found a workaround, using Unison to sync the files, only to test them on the MacOS for the time being.
Installation Unison and essential
After installing the Homebrew on the MacOS, it is easy to install Unison with it. In addition you need to let Unison can monitor the file changes, when there is a change to perform synchronized action, and then install the unison-fsmonitor.
# Install Unison
Brew Install Unison
# Installation of Unox dependencies
Pip Install Macfsevents
# Unox is a unison-fsmonitor script used on MacOS.
Curl-o/usr/local/bin/unison-fsmonitor-l https://raw.githubusercontent.com/hnsl/unox/master/unox.py
chmod +x/usr/local/bin/unison-fsmonitor
Running Drupal
I have a warehouse called Nest on the GitHub, which is an environment where Docker Compose can run a generic PHP application, and its Use-unison-sync-app-files branch tests the method of using Unison to synchronize files.
1-Clone Warehouse
git clone-b use-unison-sync-app-files git@github.com:ninghao/nest.git
2-Build and start services
CD Nest
# Build the mirrors used in Compose
Docker-compose Build
# Start the service described in Compose
Docker-compose up-d
3-Download Drupal
# into a container with drush tools
Docker-compose EXEC Console Bash
# download Drupal
Drush DL Drupal
MV drupal* Drupal
# Modify permissions, otherwise Drupal can't write files
Chown-r Www-data Drupal/sites
4-Configure the Nginx
# File: services/nginx/config/default.conf
# Change the value of the root command in the configuration file to look like this:
Root/mnt/app/drupal;
5-Restart the Web service
# executes directly on the local
Docker-compose Restart Web
6-Sync files using unison
# executes directly on the local
# Sync up your Drupal files first
Unison./app/drupal Socket://127.0.0.1:5000/drupal-auto-batch
# Monitor changes to files
Unison./app/drupal Socket://127.0.0.1:5000/drupal-repeat Watch-auto-batch
7-Install Drupal
# Open in Browser
http://localhost:8080
8-feel very fast running speed: