Docker running Drupal very quickly on the local development environment

Source: Internet
Author: User
Tags drupal git clone docker for mac docker compose

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:

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.