node

Node.js is a JavaScript runtime built on Chrome's V8 JavaScript engine and uses an event-driven, non-blocking I/O model that makes it lightweight and efficient. Beyond running web applications, it is also commonly used for front-end tooling. You can easily add it to your Lando app by adding an entry to the services key in your app's .lando.yml.

Supported versions

Example

# Express server example
name: express

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

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

# Spin up services to run a basic node server
services:

  # Create a node instance
  appserver:

    # Node version 6.10
    type: node:6.10

    # Optionally create certs in /certs that can be used by your application
    # to listen over https. Creates the following certs your app can use
    #
    #   - /certs/cert.key
    #   - /certs/cert.crt
    #   - /certs/cert.pem
    #
    ssl: true

    # Optionally install the following npm dependencies globally
    # These follow the normal package.json form
    #
    # Note that most deps should be installed by the normal npm install, this is
    # for things like gulp/grunt cli that are global dependencies
    globals:
      gulp-cli: "latest"

    # Optionally specify a command to run when you start your node service up.
    #
    # If you are using node as a server you are going to want to define this.
    # This can be either a string or array.
    #
    # If you are just spinning up a node container to run front end dependencies
    # you can leave this blank and the container will boot up and stay on
    #
    # You will likely want to run `lando npm install` first so needed dependencies are
    # installed before your server starts up.
    #
    command: npm start

    # Install some extra server packages
    # extras:
    #  - "apt-get update -y"
    #  - "apt-get install vim -y"

    # Print a message just to demonstrate this
    # build:
    # - "cd $LANDO_MOUNT & echo 'Holla!'"

# Add some nice command routing
tooling:

  # Any node service with a defined command (aka not running in cli only mode)
  # Will also spin up a node cli container called `SERVICENAME_cli` (appserver_cli)
  # in this example.
  #
  # This will allow you to run things like `lando npm install` without needing
  # to `lando start` first. This is particularly needed for node based projects
  # since you almost always need to run `npm install` before you can boot up your
  # app successfully.
  npm:
    service: appserver_cli
  node:
    service: appserver_cli
  yarn:
    service: appserver_cli

  # This should be available ONLY AFTER you start up the app since it gets installed
  # globally in the `globals` key in the appserver definition above
  gulp:
    service: appserver

  # Extra commands for fun
  vim:
    service: appserver

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.

results matching ""

    No results matching ""