special sponsors

Lagoon (experimental)

Lagoon solves what developers are dreaming about: A system that allows developers to locally develop their code and their services with Docker and run the exact same system in production. The same Docker images, the same service configurations and the same code.

This is currently a very experimental integration that has the following serious caveats:

  • This only supports projects based on or extended from this example
  • This only supports Lagoon's php-fpm, nginx, php-cli, and mariadb containers.
  • It's not yet clear how much customization to your project is currently supported

However, if you'd like to try it out and give your feedback on what worked and what didn't then please continue.

You can report any issues or feedback over here.

Getting Started

EXPERIMENTAL FEATURE

To access this feature you will need:

Before you get started with this recipe we assume that you have:

  1. Installed Lando and gotten familiar with its basics
  2. Initialized a Landofile for your codebase for use with this recipe
  3. Read about the various services, tooling, events and routing Lando offers.

However, because you are a developer and developers never ever RTFM, you can also run the following commands to try out this recipe against the Amazee.io Drupal 8 Example.

# Get the D9 example rolling
lando init \
  --source remote \
  --remote-url git://github.com/amazeeio/drupal-example-simple.git \
  --remote-options="--branch 9.x" \
  --recipe lagoon

# Start it up
lando start

# Install drupal
lando drush si -y

# See list of commands you can run
lando

# List information about this apps services.
lando info

Configuration

While Lando recipes set sane defaults so they work out of the box, they are also configurable.

Here are the configuration options, set to the default values, for this recipe's Landofile. If you are unsure about where this goes or what this means we highly recommend scanning the recipes documentation to get a good handle on how the magicks work.

recipe: lagoon
config:
  flavor: drupal
  build:
    - composer install

If you do not already have a Landofile for your Lagoon site, we highly recommend you use lando init to get one as that will automatically populate the above defaults for you. Manually creating a Landofile with these things set correctly can be difficult and is highly discouraged.

Note that if the above config options are not enough, all Lando recipes can be further extended and overriden.

Flavor

This is not configurable. Lando only support Drupal projects currently.

Build steps

If you have steps you need to run to get your site into a workable place you can put them in the build key of your recipes config. By default, we will run composer install but you may wish to augment that with any front end compilation tasks you may have as in the example below:

recipe: lagoon
config:
  flavor: drupal
  build:
    - composer install
    - yarn run compile:sass
    - drush sql-sync my-database

These will run against the Lagoon PHP CLI Drupal container so you will have access to all the tools there as well as the ones it inherits from the base PHP CLI container.

Note that these will run the first time you run lando start. You will need to run lando rebuild to trigger them again if you make changes.

Customizing the stack

Customizations not fully tested

We think most of the customizations below should work but they have been very minimally tested. If you try one and it doesn't work, please report an issue.

Lando will read and interpret your normal .lagoon.yml and its associated Docker Compose files. This means that you should be able to do the customizations Lagoon has documented, run a lando rebuild and see the changes.

The services we currently support with links to their associated Lagoon docs is shown below:

Note that we are testing against the "Drupal" variants of the above but it's possible the base services work as well.

External access

If you would like to connect to your database, or some other service, from your host using a GUI client like SequelPro, you can run lando info and use the external_connection information and any relevant creds for the service you want to connect to.

You can also check out the environment variable LANDO INFO, which is available in every Lando container, as it contains useful information about how your application can access other Lando services.

Some example connection info for the mariadb service is shown below:

lando info --service mariadb --format default

[ { service: 'mariadb',
    urls: [],
    type: 'lagoon-mariadb',
    healthy: true,
    creds: { user: 'drupal', password: 'drupal', database: 'drupal', rootpass: 'Lag00n' },
    internal_connection: { host: 'mariadb', port: '3306' },
    external_connection: { host: '127.0.0.1', port: '32790' },
    config: {},
    version: 'custom',
    meUser: 'mysql',
    hostnames: [ 'mariadb.drupalexample.internal' ] }]

Tooling

Each Lando Lagoon recipe will also ship with the Lagoon toolchain. This means you can use drush and other tools via Lando and avoid mucking up your actual computer trying to manage php versions and tooling. Here are the things that ship with the drupal flavor by default.

You can also run lando from inside your app directory for a complete list of commands.

lando composer          Runs composer commands
lando db-export [file]  Exports database from a database service to a file
lando db-import <file>  Imports a dump file into a database service
lando drush             Runs drush commands
lando mysql             Drops into a MySQL shell on a database service
lando node              Runs node commands
lando npm               Runs npm commands
lando php               Runs php commands
lando yarn              Runs yarn commands

Note that you can define your own commands by using out tooling framework. Also check out the guides for the powerful DB Export and DB Import commands.

Mailhog

If you're using a Lagoon php container we will automatically set up mailhog for you so you can capture emails. You will see urls to access its web interface after you run lando start or if you run lando info.

NAME          drupal-example
LOCATION      /Users/pirog/work/lando/examples/lagoon-drupal/drupal
SERVICES      cli, nginx, php, mariadb, redis, solr, mailhog
MAILHOG URLS  http://localhost:32792
              http://inbox.drupal-example.lndo.site/