40

A Local Dev Tool For Every Project | Lando

 3 years ago
source link: https://lando.dev/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Initialize a codebase to get a Landofile

Here are a few examples...

# Interactively initialize your code

lando init

# Set up a mean recipe that runs on a particular port with a particular command

lando init --source cwd \
  --recipe mean \
  --option port=3000 \
  --option command="yarn watch" \
  --name meanest-app-youve-ever-seen

# Interactively clone a site from Pantheon

lando init --source pantheon

# Spin up a new Drupal 7 site

lando init \
  --source remote \
  --remote-url https://ftp.drupal.org/files/projects/drupal-7.71.tar.gz \
  --remote-options="--strip-components 1" \
  --recipe drupal7 --webroot . \
  --name hello-drupal7

Optionally customize your Landofile for MOAR POWER

Here is a progressively complexifying WordPress example...

# Default WordPress recipe Landofile config, good for most use cases out of the box

name: my-app
recipe: wordpress

# Add some basic recipe config

name: my-app
recipe: wordpress
config:
  database: postgres
  php: '7.3'
  xdebug: true

# Add node tooling, solr, phpmyadmin and custom php config

name: my-app
recipe: wordpress
config:
  database: postgres
  php: '7.3'
  xdebug: true
  config:
    php: my-custom-php.ini
proxy:
  pma:
   - database-my-app.lndo.site
services:
  index:
    type: solr
  node:
    type: node:10
    globals:
      gulp: latest
  pma:
    type: phpmyadmin
    hosts:
      - database
tooling:
  yarn:
    service: node
  node:
    service: node

# Add php extensions, build steps, automation, docker overrides

name: my-app
recipe: wordpress
config:
  database: postgres
  php: '7.3'
  xdebug: true
  config:
    php: my-custom-php.ini
events:
  post-db-import:
    - appserver: wp search-replace
proxy:
  pma:
   - database-my-app.lndo.site
services:
  appserver:
    build_as_root:
      - apt update -y && apt-get install vim -y
      - /helpers/my-script-to-install-php-extension.sh memcached
    build:
      - composer install
    overrides:
      environment:
        APP_LEVEL: dev
        TAYLOR: swift
  index:
    type: solr
  node:
    type: node:10
    globals:
      gulp: latest
    build:
      - yarn
  frontend:
    type: node:10
    command: yarn start
    build:
      - yarn
  pma:
    type: phpmyadmin
    hosts:
      - database
tooling:
  yarn:
    service: node
  node:
    service: node
  gulp:
    service: node
  test:
    cmd:
      - appserver: composer test
      - frontend: yarn test
  deploy:
    service: appserver
    cmd: /path/to/script.sh

Start it up and try out some tooling commands

Here are some commands for our complex WordPress config above.

# Start your app

lando start

# Explore its tooling options

# See what tools are available in your app
lando

# Run wp-cli commands
lando wp

# Drop into a postgres shell
lando psql

# Import a database
lando db-import dump.sql

# Run composer and yarn tests
lando test

# Install more node packages
lando yarn add bootstrap

# Start up gulp watch
lando gulp watch

Commit and distribute

Once you are feeling good about your Landofile, commit it to your repository so other developers can easily get spun up.

# Project lead commits to the repo

git add .lando.yml
git commit -m "Supercharge my dev"
git push

# Now subsequent developers only need to git clone and lando start

git clone my-project & cd my-project & lando start

Focus on more important shit

Enjoy the benefits of lives-in-repo config, per-app local dev dependency management and standardization.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK