LANDO

Administer Your Own

Cloud City

Derek Laventure

derek@consensus.enterprises

(DrupalNorth 2018)

Overview

  1. Assumptions
  2. Basics
  3. Customizing
  4. Workflow
  5. PLEASE ASK QUESTIONS!

Assumptions

You have some familiarity with:

  • Docker & docker-compose
  • Git
  • Drupal dev workflow (composer etc)
  • Recommended: install Lando from source
https://docs.devwithlando.io/installation/installing.html#from-source

Why not…

  • DrupalVM?
  • DDev?
  • Docksal?
  • [your favourite here]

Donald Glover shooting

“vanilla” Docker Compose

Moshe: http://medium.com/ma-digital-services/dev-env-5d35b97f3473

Good Luck!

Shout Out

lagoon.readthedocs.io

https://lagoon.readthedocs.io

Who me?

Lando Basics

D8 From Scratch

# Basic Drupal setup
mkdir chewie
composer create-project drupal-composer/drupal-project:8.x-dev \
   chewie --stability dev --no-interaction

# Git setup
cd chewie 
git init && git add .
git commit -m "Initial commit: chewie.lndo.site"

# Lando!
lando init --name=chewie --recipe=drupal8 --webroot=web
git add .lando.yml && git commit -m "lando init"
lando start

http://chewie.lndo.site

.lando.yml

name: chewie
recipe: drupal8
config:
  webroot: web

~/.lando/compose/

chewie/chewie-1.yml

$ wc -l ~/.lando/compose/chewie/chewie-1.yml 
127 /home/spiderman/.lando/compose/chewie/chewie-1.yml

Donald Glover Oooooh

Lando-fy

lando init --recipe=drupal7 --name=smithwriter --webroot=.
lando start
lando db-import database.sql

.lando.yml

name: smithwriter
recipe: drupal7
config:
  webroot: web

Buckle Up

Other

unzip grav-skeleton-onepage-site-v2.0.0.zip
mv grav-skeleton-onepage-site grav

cd grav
lando init --recipe=custom --name=grav --webroot=.

GravCMS .lando.yml

name: grav
recipe: custom
config:
  webroot: .

proxy:
  appserver:
    - grav.lndo.site

services:
  appserver:
    type: php:7.2
    via: apache
    ssl: true
lando start

Yeeehaaa!

Recipes

plugins/lando-recipes/recipes/drupal7/drupal7.js
  /*
   * Build out Drupal7
   */
  var build = function(name, config) {

    // Get the via so we can grab our builder
    var base = (_.get(config, 'via', 'apache') === 'apache') ? 'lamp' : 'lemp';

    // Update with new config defaults if needed
    config = helpers.resetConfig(config._recipe, config);

    // Set the default php version for D7
    config.php = _.get(config, 'php', '7.0');

    // Start by cheating
    var build = lando.recipes.build(name, base, config);

    // Determine the default drush setup for D7
    var defaultDrush = (config.php === '5.3' ? DRUSH7 : DRUSH8);

    // Get the drush config
    var drushConfig = _.get(config, 'drush', 'global:' + defaultDrush);

    // Handle drush
    var buildersKey = 'services.appserver.run_internal';
    build.services.appserver.run_internal = _.get(build, buildersKey, []);
    build = drush(build, drushConfig);

    // Return the things
    return build;

  };

  // Return the things
  return {
    build: build,
    configDir: __dirname
  };

Customizing

s/apache/nginx/

--- a/.lando.yml
+++ b/.lando.yml
@@ -10,5 +10,5 @@ proxy:
 services:
   appserver:
     type: php:7.2
-    via: apache
+    via: nginx
     ssl: true

What have we here?

Adding Services

eg. MailHog…

services:
  mailhog:
    type: mailhog
    hogfrom:
      - appserver

proxy:
  mailhog:
    - mh.chewie.lndo.site

…or whatever

  • Elasticsearch
  • MongoDB
  • NodeJS
  • etc..

Custom config

  • custom php.ini & database credentials

    services:
    appserver:
    config:
      conf: php.ini
    database:
    creds:
      user: l337
      password: droidlife
      database: falcon
    

Lando looks at Boba Fett

The Kessel Run

  • install 2 drupal sites!
  • example: SSO setup

.lando.yml

name: ra
compose:
  - chromedriver-compose.yml
recipe: drupal8
config:
  php: '7.1'
  webroot: web
  drupal: true
  xdebug: true

.lando.yml services

services:
  # RA site database.
  ra_db:
    type: mysql:5.7
    creds:
      user: sso-ra
      password: sso-ra
      database: sso-ra
    portforward: 32777

  # RA site web server
  ra_web:
    type: php:7.1
    via: apache
    webroot: web
    ssl: true
    config:
      server: config/apache/httpd-ssl-ra.conf
    xdebug: true
    overrides:
      services:
        volumes:
          - downloads:/downloads
  # RP site database.
  rp_db:
    type: mysql:5.7
    creds:
      user: sso-rp
      password: sso-rp
      database: sso-rp
    portforward: 32778

  # RP site web server.
  rp_web:
    type: php:7.1
    via: apache
    webroot: web
    ssl: true
    config:
      server: config/apache/httpd-ssl-rp.conf
    xdebug: true

  mailhog:
    type: mailhog
    hogfrom:
      - ra_web
      - rp_web

Unquestionably Awesome

Workflow

Drumkit

Drumkit is a suite of Makefiles to simplify Drupal development

You've got a lot of nerve

Drumkit Setup

wget -O - https://raw.githubusercontent.com/ergonlogic/drumkit/master/scripts/install.sh | /bin/bash
git submodule add https://github.com/ergonlogic/drumkit .mk
echo "include .mk/GNUMakefile" >> Makefile
ln -s .mk/d
source d

Drumkit Help

Lando Calrissian!

.gitlab-ci.yml

build:make:install:
  stage: build
  before_script:
    # Bootstrap Drumkit
    - . d
  script:
    - make build VERBOSE=1
    # Check that scaffolding has been built.
    - "[ -f web/index.php ]"

test:behat:default: &test
  stage: test
  services:
    - name: mysql:5.7
      alias: cop_db
  cache:
    <<: *cache
    policy: pull
  variables:
    PROFILE: default
  before_script:
    # Bootstrap Drumkit
    - . d
    # Build the codebase.    @TODO cache this from the build/install phase.
    - make build VERBOSE=1
    # Install the site.      @TODO cache a backup from the build/install phase, and restore it here.
    - make install VERBOSE=1
    # Configure and start Apache, and related tasks.
    - ./scripts/apache/setup.sh
    # Check that sites have been installed.
    - "[ -d web/sites/cop.lndo.site ]"
    - drush --uri=cop.lndo.site status
  script:
    - make ci

Woohoo

Debugging

  • PHPStorm && XDebug
  • Lando tooling

    dynamic:
    # Just print the hostname so we know what service we are on
    cmd: printenv LANDO_SERVICE_NAME
    
    # The format :NAME will use the service from NAME flag
    # You likely will want to specify the option below 
    # and set a reasonable default
    service: :service
    
    # Specify a service option to handle the above
    options:
      service:
        default: appserver
        alias:
          - s
        describe: Run a different service
    

Lando hugs

Thanks!