Let’s say, you have a Node.js application which needs to connect to a MongoDB. You can easily set up and host a project with both applications nested in its own Docker container using sloppy.

Just use the example JSON configuration file provided on this page.

For our example we assume, that your Node.js application is already containerized and available in the Docker Hub Registry. As for the MongoDB, we are also using the official image available from Docker Hub.

Please note, that you will have to change the values for YOURDOMAIN accordingly in the JSON configuration.

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