Working with Custom Sites

Using Lando it is easy to augment recipes with additional services, tooling or routing or to build out completely custom stacks to run your application. Before customizing or creating your own Lando app we recommend you review the three core components that drive the .lando.yml so you have a sense of how things work behind the scenes.

Now that you've read all deep magic here are some common scenarios and examples.

Overriding and Extending Recipes

It is easy to both augment the services, tooling and routes provided by recipes and to add additonal things. We recommend you run lando info on your app before you customize so you can check out the names of the services provided by your recipe. Once you change your .lando.yml file you'll likely want to lando restart or lando rebuild for the changes to apply.

Here are a few examples:

A LEMP recipe with bonus DB, phpMyAdmin and appserver overrides

# PhpMyAdmin example
name: pma

# Start with a basic LEMP recipe
recipe: lemp

# Add in a proxy route to phpmyadmin
proxy:
  pma:
    - pma.lemp.lndo.site

# Add in phpmyadmin
services:

  # Override the appsever to add some environment variables and install an extra VIM package
  appserver:
    run_as_root:
      - apt-get update -y
      - apt-get install vim -y
    overrides:
      services:
        environment:
          MYCONFIGVAR1: secretpasscode

  # Add in another database to help with this example
  database2:
    type: mariadb

  # Add a phpmyadmin db frontend
  pma:

    # Use the latest version of phpmyadmin
    type: phpmyadmin

    # The databases you want to look at, this will default to a service called
    # "database"
    #
    # You might want to run `lando info` on your app to see what databases you
    # have available
    hosts:
      - database
      - database2

    # Optionally load in a custom config file. This is relative to the app root
    #
    # You will not need to import the standard library or manage backends in this
    # file. Those are handled automatically.
    #
    # config: config.user.inc.php

    # There are various envvars you can specify to further customize how your
    # pma works.
    #
    # See: https://hub.docker.com/r/phpmyadmin/phpmyadmin/
    #
    # overrides:
      # services:
        # environment:
            # PMA_ARBITRARY: when set to 1 connection to the arbitrary server will be allowed
            # PMA_HOST: define address/host name of the MySQL server
            # PMA_VERBOSE: define verbose name of the MySQL server
            # PMA_PORT: define port of the MySQL server
            # PMA_HOSTS: define comma separated list of address/host names of the MySQL servers
            # PMA_VERBOSES: define comma separated list of verbose names of the MySQL servers
            # PMA_USER: define username to use for config authentication method
            # PMA_PASSWORD: define password to use for config authentication method
            # PMA_ABSOLUTE_URI: define user-facing URI

# Add a lando vim command
tooling:
  vim:
    service: appserver

You can check out the full code for this example over here.

A LEMP recipe with a bunch of extra tools

# Example for a basic lemp stack with some extra tools installed
name: addtools
recipe: lemp
config:
  php: '7.1'
services:
  appserver:
    composer:
      phpunit/phpunit: '*'
    run_as_root:
      - "apt-get update -y"
      - "apt-get install build-essential chrpath libssl-dev libxft-dev libfreetype6-dev libfreetype6 libfontconfig1-dev libfontconfig1 -y"
      - "wget https://github.com/Medium/phantomjs/releases/download/v2.1.1/phantomjs-2.1.1-linux-x86_64.tar.bz2"
      - "tar xvjf phantomjs-2.1.1-linux-x86_64.tar.bz2 -C /usr/local/share/"
      - "ln -sf /usr/local/share/phantomjs-2.1.1-linux-x86_64/bin/phantomjs /usr/local/bin/"
tooling:
  phpunit:
    service: appserver
    description: "Run PHP Unit tests: lando phpunit"
  phantomjs:
    service: appserver
    description: "Run phantomjs commands"
  git:
    service: appserver

You can check out the full code for this example over here.

A LEMP recipe that uses mailhog

# The name of the app
name: mailhog

# Start with the default LEMP recipe
recipe: lemp

# Additional mailhog proxy settings so we get a nice URL for the mailhog ui
proxy:
  mailhog:
    - mail.lemp.lndo.site

# Mailhog things
services:

  # Spin up a mailhog container called "mailhog"
  # NOTE: "mailhog" is arbitrary, you could just as well call this "blackhole" or "weezer"
  mailhog:

    # Use the latest mailhog version
    type: mailhog

    # List of services that we want to capture mail from
    # You can run `lando info` to get a list of services that are available
    # Mailhog expects that these services will be php services
    hogfrom:
      - appserver

    # Optionally allow access to the smtp service at localhost:1026
    # You will need to make sure port 1026 is open on your machine
    #
    # You can also set `portforward: true` to have Lando dynamically assign
    # an open port. Unlike specifying an actual port setting this to true will give you
    # a different port every time you restart your app
    portforward: 1026

You can check out the full code for this example over here.

Building A Custom Stack

You also can build up a custom stack by creating a .lando.yml file from scratch and putting it in your applications code root. This means you don't have to run lando init.

LAMP recipe without the recipe

# LAMP stack example
name: lamp

# Give me http://lamp.lndo.site and https://lamp.lndo.site
proxy:
  appserver:
    - lamp.lndo.site

# Spin up services to run a basic LAMP stack
services:

  # Create a php 5.3 instance served by the latest apache with https turned on
  appserver:

    # PHP version 5.3
    type: php:5.3

    # Serve php by either apache or nginx. You can put in any `service:version`
    # string that is supported by Lando's nginx and apache services.
    via: apache

    # Optionally serve php over https
    ssl: true

    # Optionally specify a webroot if it is a subdirectory of the appRoot
    webroot: www

    # Optionally customize the configuration for php and its underlying webserver
    # These paths are both relative to (and must reside within) the app root directory
    #
    # For some examples that use this fairly well please check out
    # https://github.com/lando/lando/tree/master/examples
    # config:
      # Use a custom apache config file
      # server: config/apache/lamp.conf

      # Use a custom php.ini
      # This **should** load last which means you should be able to override
      # any previously set php settings.
      # conf: config/php/php.ini

    # Optionally activate xdebug
    #
    # If you are having trouble getting xdebug to work please see:
    # https://docs.devwithlando.io/services/php.html#using-xdebug
    xdebug: true

    # Optionally install the following composer dependencies globally
    # These follow the normal composer.json form
    # Note that many composer dependencies should not be installed globally but
    # on a per-project basis
    # composer:
    #   drush/drush: "~8"

    # Optionally run the following build steps
    # run:
    #  - "cd $LANDO_MOUNT && composer install"

    # Optionally install additional server software
    # run_as_root:
    #  - "apt-get update -y"
    #  - "apt-get install netcat -y"

  # My database service
  database:
    type: mysql
    portforward: 3308
    creds:
      user: lamp
      password: lamp
      database: lamp

# Add some nice command routing
tooling:
  composer:
    service: appserver
    description: Run composer commands
    cmd:
      - composer
      - --ansi
  php:
    service: appserver
  mysql:
    user: root
    service: database
    description: Drop into a MySQL shell

You can check out the full code for this example over here.

Node webserver with elasticsearch

# elasticsearch example
name: elasticsearch

#
# You need to run `lando npm install` before you run `lando start` for this
# example to work
#

# Give me http://elasticsearch.lndo.site
proxy:
  appserver:
    - elasticsearch.lndo.site

# Spin up a basic nodes server with elasticsearch backend
services:

  # Spin up a memcache container called "search"
  # NOTE: "search" is arbitrary, you could just as well call this "theboss" or "eljefe"
  search:

    # Use version 5.4 of elasticsearch
    type: elasticsearch:5.4

    # Optionally allow access to the cache at localhost:9999
    # You will need to make sure port 9999 is open on your machine
    #
    # You can also set `portforward: true` to have Lando dynamically assign
    # a port. Unlike specifying an actual port setting this to true will give you
    # a different port every time you restart your app
    portforward: 9999

    # Optionally load in a custom config file. This is relative to the app root.
    #
    # config: customElasticsearch.yml

    # There are various envvars you can specify to further customize how
    # elasticsearch works.
    #
    # See: https://hub.docker.com/r/itzg/elasticsearch/
    #
    # overrides:
      # services:
        # environment:
          # ES_JAVA_OPTS: -Xms16g -Xmx16g
          # PLUGINS: elasticsearch/marvel/latest

  # Spin up services to run a basic node server
  appserver:
    type: node:6.10
    command: npm start

# Add some nice command routing
tooling:
  yarn:
    service: appserver_cli
  npm:
    service: appserver_cli
  node:
    service: appserver_cli

You can check out the full code for this example over here.

Read More

Workflow Docs

Advanced Usage

results matching ""

    No results matching ""