Advanced Service Configuration

Using Dockerfiles

You can use your own images by overriding any service to build from a Dockerfile that lives somewhere inside your app. Here is an example that extends our base php image to add another extension.

Landofile (.lando.yml)

# Dockerfile example
name: dockerfile

# Start with the default LEMP recipe
recipe: lemp

# Override the recipe image with a build location

    # You probably want to set this to custom
    type: php:custom

        # This should relative to your app root
        build: ./php

        # Optionally specify a name and tag for the built image so you can
        # user it elsewhere later
        # NOTE: Docker may throw a warning like:
        #   WARNING: Image for service appserver was built because it did not already exist.
        # This is safe to ignore
        image: pirog/php:7.1-fpm-custom

        # This is not needed it only serves to illustrate how you can map internal container things
        # to your app directory for easy editability
          - ./config/custom.ini:/usr/local/etc/php/conf.d/zzzz-custom.ini
          - ./logs:/var/logs


FROM devwithlando/php:7.1-fpm

RUN apt-get update -y \
  && docker-php-ext-install pcntl

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

Overriding with Docker Compose

Our recipes and services layers are two levels of abstraction on top of the Docker compose v3 file format.

Lando will translate the configuration you specify for each recipe and/or service into relevant Docker Compose files and execute them at runtime. This gives you a lot of power to hypertune your services at the Docker Compose level.

You can pass Docker Compose config into each service using the overrides key.

Here is an example of an overriden apache service that uses a custom image and injects some additional environment variables.

    type: apache:custom
          STUFF: THINGS
          THINGS: GUYS
        image: pirog/myapache:2

Building a Custom Service

You can also use our "catch all" service that allows power users to specify custom services that are not currently one of Lando's "supported" services. Technically speaking, this service is just a way for a user to define a service directly using the Docker Compose V3 file format. THIS MEANS THAT IT IS UP TO THE USER TO DEFINE A SERVICE CORRECTLY.

This service is useful if you are:

  1. Thinking about contributing your own custom Lando service and just want to prototype something
  2. Using Docker Compose config from other projects
  3. Need a service not currently provided by Lando itself

# The name of my app
name: compose

# Use the lando proxy to map to the custom service

# Configure my services

  # Create a service called "custom"

    # Use docker compose to create a custom service.
    type: compose

    # Specify the docker compose v3 services options here

      # Specify what container to run to provide the service.
      image: drupal:8

      # Required.
      # You will need to investigate the images Dockerfile to find the "entrypoint" and "command"
      # and then define the command as `ENTRYPOINT COMMAND`
      # You can also try a completely custom command but YMMV
      command: docker-php-entrypoint apache2-foreground

  # Spin up a DB to go with this
    type: mysql

You will need to rebuild your app with lando rebuild to apply the changes to this file. You can check out the full code for this example over here.

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

results matching ""

    No results matching ""