Create a local folder. <app> will be the name of your application folder and Lando instance.
mkdir <app>
Position your working directory as your new folder
cd <app>
Initialize Lando and answer a few questions. This utility creates a .lando.yml file in your working directory. When you start Lando in the next step, this file is used to define the Lando configuration.
lando init
Choose: current working directory
Choose: Drupal9
Enter for webroot: web
Enter for app: <app>
Start Lando
lando start
Install Drupal code using composer. Note – Drupal is being install in a Docker container, not on your local computer.
lando composer create-project drupal/recommended-project blah -n
The above command uses composer to install Drupal and it’s dependencies into a folder called ‘blah’. Now, the files/folders in ‘blah’ will be move up one level into your directory and the ‘blah’ folder will be removed.
mv blah/* .
mv blah/.* .
rm -rf blah
Rebuild Lando containers.
lando rebuild -y
On a success rebuilt on Lando, it’s time to install Drupal 8. Goto the local URL for your Drupal 8 website.
https://<app>.lndo.site
Follow the steps in the Drupal installation Wizard. When the database page appears, use ‘drupal9‘ for the database name, username and password. Also, use ‘database‘ for the host name (under the Advanced settings.
Local Drupal development has moved to docker based environments with solutions like Lando and DDEv. With these tools, it’s fast and easy to spin up a local environment and manage many projects. The days of MAMP and WAMP are (long) gone.
Here’s the problem, Mac OS is the dominant development platform for Drupal developers, and Docker runs terribly on it. Docker interacts differently with macOS than it does with Linux. The source code on the host computer is shared with Docker containers. The multiple layers of communication between Docker and the macOS file system make file-sharing very slow. While Docker’s direct access to the Linux file system makes it very fast. This video, Improving Docker Desktop File Sharing Performance, from DockerCon 18 describes this issue in detail.
The file-sharing performance issue became apparent when working with a colleague to set up a new Drupal 8 website build. I was shocked to see the local build process taking over 8 minutes on my colleague’s computer and less than 30 seconds on my computer.
Benchmarks
In an unscientific way, with some help from my friends, I tested the build process on a few Macs and Linux computers with different hardware specs. Each computer had Docker and Lando installed. The website is a Drupal 8 Standard profile with Acquia’s BLT. The test is simple, run the BLT artifact build, blt artifact:build
Below are the results of this test.
Computer
Specs
OS
Artifact:build
ThinkPad T420 (2011)
i5 (2 cores), 8GB RAM, SSD
Linux (Endevour OS)
20 seconds
Custom Build (2020)
Ryzen i7 (8 cores), 32GB, SSD
Linux (Endevour OS)
7 seconds
Macbook Air (2018)
i5 (2 cores), 8GB RAM, SSD
macOS Catalina
8+ minutes
MacBook Pro (2015)
i7 (4 cores), 16GB RAM, SSD
macOS Mojave
6 minutes
Solutions
There are some potential solutions. Lando has an undocumented Mac-only feature called “Turbo Mode”. Reviewing the issue thread, there are mixed results with this implementation. Turbo Mode had little impact on my test case shaving off 30 to 60 seconds. A 5% to 10% improvement is good, but when comparing it to performance on Linux, there is no practical improvement. Others have seen better improvements with Turbo Mode. This approach is easy to implement and worth exploring, but Turbo Mode hasn’t made it’s way into Lando as a supported feature. Use with caution.
Some tweaks can be made to your Docker configuration. Increasing the default RAM usage from 2GB to 4GB is a starting point. You can also limit the number of shared folders Docker watches, by default, the entire /Users folder is included. I tested the memory upgrade and limited the shared folders to only the necessary application folders. Similar to the results with Turbo Mode, they were minimal for my test case. You may have more promising results. There are many online resources with recommendations to improve performance, search “Docker Mac performance”.
The beauty of using Lando is simplicity, which starts to diminish with lots of OS based tweaks. I suspect more research and testing could result in better performance on Mac. BUT, using Linux for Drupal development with Docker will get you the best performance by far, with ease. It’s that simple.
Create a local folder. <app> will be the name of your application folder and Lando instance.
mkdir <app>
Position your working directory as your new folder
cd <app>
Initialize Lando and answer a few questions. This utility creates a .lando.yml file in your working directory. When you start Lando in the next step, this file is used to define the Lando configuration.
lando init
Choose: current working directory
Choose: Drupal8
Enter for webroot: web
Enter for app: <app>
Start Lando
lando start
Install Drupal code using composer. Note – Drupal is being install in a Docker container, not on your local computer.
lando composer create-project drupal-composer/drupal-project:8.x-dev blah -n
The above command uses composer to install Drupal and it’s dependencies into a folder called ‘blah’. Now, the files/folders in ‘blah’ will be move up one level into your directory and the ‘blah’ folder will be removed.
mv blah/* .
mv blah/.* .
rm -rf blah
Rebuild Lando containers.
lando rebuild -y
On a success rebuilt on Lando, it’s time to install Drupal 8. Goto the local URL for your Drupal 8 website.
https://<app>.lndo.site
Follow the steps in the Drupal installation Wizard. When the database page appears, use ‘drupal8’ for the database name, username and password. Also, use ‘database’ for the host name (under the Advanced settings.
You should be up and running,
Updates
12/10/2019 – As of Drupal 8.8.0, Composer project templates are now available as part of Drupal core. The composer create-project command was updated to reflect this change.
I’ve recently started using Backstop JS for visual regression testing. You can add the following settings to your Lando configuration, .lando.yml, to include Backstop JS.