MongoDB

MongoDB is a free and open-source cross-platform document-oriented database program. Classified as a NoSQL database program, MongoDB uses JSON-like documents with schemas. 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

# Mongo example
name: mongo

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

# Give me http://mongo.lndo.site
proxy:
  appserver:
    - mongo.lndo.site

# Spin up a basic nodes server with mongo backend
services:

  # Spin up a mongo container called "database"
  # NOTE: "database" is arbitrary, you could just as well call this "thing" or "stuff"
  database:

    # Use latest stable version of mongo
    type: mongo

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

    # Optionally use the following mongo config file
    # This is relative to the app root
    config: config.yml

  # Spin up services to run a basic node server
  appserver:
    type: node:6.10
    command: npm start
    globals:
      gulp-cli: "latest"

# Add some nice command routing
tooling:
  npm:
    service: appserver_cli
  gulp:
    service: appserver
  node:
    service: appserver_cli
  # Add a route to the mongo shell
  mongo:
    service: database
    description: Drop into the mongo shell

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.

Getting information

You can get connection and credential information about your mongo instance by running lando info from inside your app.

# Navigate to the app
cd /path/to/app

# Get info (app needs to be running to get this)
lando info

{
  "database": {
    "type": "mongo",
    "version": "latest",
    "internal_connection": {
      "host": "database",
      "port": 27017
    },
    "external_connection": {
      "host": "localhost",
      "port": "27018"
    }
  },
  "appserver": {
    "type": "node",
    "version": "6.10",
    "urls": [
      "http://localhost:32835",
      "http://mongo.lndo.site",
      "https://mongo.lndo.site"
    ]
  }
}

results matching ""

    No results matching ""