dockerlando

How to create proper .lando.yml custom file?


is there any way how to create a proper, really custom .lando.yml file so it will not use any recipe? How do I specify "just give me Apache, MariaDB, PHP" in Lando?

I tried this

    # The name of the app
    name: mariadb

    # Give me http://mariadb.lndo.site and https://mariadb.lndo.site
    proxy:
      html:
        - mariadb.lndo.site

    # Set up my services
   services:

  # Set up a basic webserver running the latest nginx with ssl turned on
  html:
    type: nginx
    ssl: true
    webroot: www

  # Spin up a mariadb container called "database"
  # NOTE: "database" is arbitrary, you could just as well call this "db" or "kanye"
  database:

    # Use mariadb version 10.1
    type: mariadb:10.1

    # Optionally allow access to the database at localhost:3307
    # You will need to make sure port 3307 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: 3307

    # Optionally set the default db credentials
    #
    # Note: You will need to `lando destroy && lando start` to change these if you've
    # already started your app
    # See: https://docs.devwithlando.io/tutorials/lando-info.html
    creds:
      user: mariadb
      password: mariadb
      database: mariadb

    # Optionally load in all the mariadb config files in the config directory
    # This is relative to the app root
    # NOTE: these files need to end in .cnf
    config:
      confd: config

but after lando start I am getting a ERROR: No such service: appserver error and the documentation for this is extremely confusing.

Thanks.


Solution

  • You'll want to look at the Building a Custom Stack section of the lando custom project page.

    I won't do your entire project, but the basics are as follows:

    # LAMP stack example
    name: lamp
    
    proxy:
      appserver:
        - lamp.lndo.site  # Allows you to access the site at http[s]://lamp.lndo.site
                          # This may actually get done automatically
    
    services: # Define your services
      appserver:  # Create a web server container
        type: php:5.3 # Specify what version of php to use
        via: apache   # This could be nginx, should you choose so
        webroot: www  # Specify webroot
        config:  # If you want to add/edit
          server: config/apache/lamp.conf  # Use an alternate apache config file
          conf: path/from/app/root/php.ini # Alter php configuration with a custom file
      database:  # Create a database server container
        type: mysql
        portforward: 3308
        creds:  # Specify what creds/db to use
          user: lamp
          password: lamp
          database: lamp
    
    tooling:  # These toolings allow you to connect land <command> to the appropriate containers
      composer: # Call with "lando composer..."
        service: appserver
        description: Run composer commands
        cmd: composer --ansi
      php:      # Call with "lando php..."
        service: appserver
      mysql:    # Call with "lando mysql..."
        user: root
        service: database
        description: Drop into a MySQL shell