dependencies help you to make sure that your applications are started in the expected order. This way, you can easily control the start/stop and upgrade order of the applications in a project.

Usage

To define a dependency you have to point one application to second one, that the first one requires to be running. All you need to do is to provide the required apps relative path in your project’s tree, like this:

{"apps": [
   (...)
   {
   "dependencies": [
      "../../service-name/required-app"
      ]
   },
   (...)

You can also define multiple dependencies for an app, like this:

{"apps": [
   (...)
   {
   "dependencies": [
      "../../service1/required-app1"
      "../../service1/required-app2"
      "../../service2/required-app3"
      ]
   },
   (...)}

When using a docker-compose.yml depends_on is mapped to dependencies.

Example

Here is a full example, where a node.js application is dependent on a MongoDB app in the project to be started first.

{
  "project": "lets-chat",
  "services": [
    {
      "id": "frontend",
      "apps": [
        {
          "id": "node",
          "domain": {,
            "uri": "YOURDOMAIN.sloppy.zone"
          },
          "image": "sdelements/lets-chat",
          "port_mappings": [
            {
              "container_port": 5000
            }
          ],
          "env": {
            "LCB_DATABASE_URI": "mongodb://mongodb.backend.lets-chat/lets-chat"
          },
          "dependencies": [
            "../backend/mongodb"
          ]
        }
      ]
    },
    {
      "id": "backend",
      "apps": [
        {
          "id": "mongodb",
          "image": "mongo",
          "port_mappings": [
            {
              "container_port": 27017
            }
          ]
        }
      ]
    }
  ]
}
Did this answer your question?