Search…
Lando Environments
Use Lando to make your development environment portable

Why use Lando?

  1. 1.
    Standardizing local environments is simple and effective.
  2. 2.
    Your development environment is portable, so you only need Docker and Lando to develop.
  3. 3.
    Complicated infrastructure can be stood up quickly.
  4. 4.
    Versions of services can be changed with simple line updates.
  5. 5.
    Local environments can be extended with automation easily.
  6. 6.
    You can ensure specific versions of your tools are set, so they do not vary from machine-to-machine.

Dependencies

Basic Lando stack

  1. 1.
    The drupal9 recipe can handle most the work for us
    1
    recipe: drupal9
    Copied!
  2. 2.
    Both NodeJS and NPM needs to be available at a project level. Using npm the emulsify cli command can also be installed. This and npm can both be made available via Lando tooling.
    1
    services:
    2
    appserver:
    3
    build_as_root:
    4
    - apt update -y && apt install -y apt-transport-https build-essential unzip
    5
    - curl -sL https://deb.nodesource.com/setup_16.x | bash -
    6
    - apt-get install -y nodejs
    7
    - chown -R www-data /usr/lib/node_modules
    8
    - chown -R www-data /usr/bin
    9
    - npm install -g npm
    10
    - npm install -g @emulsify/cli
    11
    ...
    12
    tooling:
    13
    node:
    14
    service: appserver
    15
    npm:
    16
    service: appserver
    17
    emulsify:
    18
    service: appserver
    Copied!
  3. 3.
    Emulsify needs port 6006 to be available for StorybookJS and port 32778 to be available for Hot Reload.
    By adding proxy address for browsersync.example.lndo.site and storybook.example.lndo.site that point to the ports needed, those applications can be accessible by navigating to the addresses (without the ports, like this: http://storybook.example.lndo.site) from outside the container services.
    Since we are using proxies instead of forwarding ports directly, multiple projects can make use of these ports simultaneously.
    1
    proxy:
    2
    appserver:
    3
    - example.lndo.site
    4
    - browsersync.example.lndo.site:32778
    5
    - storybook.example.lndo.site:6006
    Copied!

Full example

.lando.yml

This example includes a full setup for Emulsify Drupal with Drupal 9 in a Lando environment.
1
name: example
2
recipe: drupal9
3
config:
4
php: '7.4'
5
via: apache
6
webroot: ./web
7
database: mysql
8
services:
9
appserver:
10
overrides:
11
environment:
12
DRUSH_OPTIONS_URI: "https://example.lndo.site"
13
build:
14
- composer install
15
build_as_root:
16
- apt update -y && apt install -y apt-transport-https build-essential unzip
17
- curl -sL https://deb.nodesource.com/setup_16.x | bash -
18
- apt-get install -y nodejs
19
- chown -R www-data /usr/lib/node_modules
20
- chown -R www-data /usr/bin
21
- npm install -g npm
22
- npm install -g @emulsify/cli
23
proxy:
24
appserver:
25
- example.lndo.site
26
- browsersync.example.lndo.site:32778
27
- storybook.example.lndo.site:6006
28
tooling:
29
drush:
30
service: appserver
31
cmd: /app/vendor/bin/drush --root=/app/web
32
node:
33
service: appserver
34
npm:
35
service: appserver
36
emulsify:
37
service: appserver
Copied!

Setup

  1. 1.
    Run composer create-project drupal/recommended-project my-project See Starting a Site Using Drupal Composer Project Templates for more information on setting up a Drupal project with Composer.
  2. 2.
    Add the above lando.yml file to the project
  3. 3.
    Run lando start
  4. 4.
    After it builds you can then run these commands:
  • lando node
  • lando npm
  • lando emulsify
  • lando drush
  1. 1.
    Follow the Inside a Composer-Based Drupal Instance steps to complete setting up Emulsify Drupal.