github.com/dahs81/otto@v0.2.1-0.20160126165905-6400716cf085/website/source/intro/getting-started/deps.html.md (about)

     1  ---
     2  layout: "intro"
     3  page_title: "App Dependencies"
     4  sidebar_current: "gettingstarted-deps"
     5  description: |-
     6    In this step, we introduce dependencies to our application and show Otto manages those dependencies.
     7  ---
     8  
     9  # Dependencies
    10  
    11  A modern application usually has many dependencies: other applications they
    12  depend on to function. These can be things such as databases or other applications
    13  that they need to communicate with such as in a
    14  [microservice architecture](http://martinfowler.com/articles/microservices.html).
    15  
    16  Dependencies introduce many complexities to the development and deployment
    17  process: they need to be installed, configured, and started in development.
    18  This puts a burden on the developer. And in production, they need to be
    19  separately deployed, scaled, etc.
    20  
    21  Otto supports microservices and dependencies as first class features.
    22  
    23  ## Declaring Dependencies
    24  
    25  Declaring dependencies is simple.
    26  
    27  Modify the Appfile `application` section to look like the following:
    28  
    29  ```
    30  application {
    31    name = "otto-getting-started"
    32    type = "ruby"
    33  
    34    dependency {
    35      source = "github.com/hashicorp/otto/examples/mongodb"
    36    }
    37  }
    38  ```
    39  
    40  The `dependency` block specifies a dependency of the application. Multiple
    41  of these can be specified. Within the block, the `source` is a URL
    42  pointer to the application. Otto expects an Appfile to exist there to describe
    43  how to develop and deploy that dependency.
    44  
    45  In the above example, we've added MongoDB as a dependency to our application.
    46  
    47  An important feature of Otto is that you only need to specify the immediate
    48  dependencies; dependencies of dependencies do not need to be specified.
    49  Otto automatically fetches the dependency and inspects it for more
    50  dependencies, and continues this process.
    51  
    52  ## Develop
    53  
    54  Once you've declared a dependency, run `otto compile` and `otto dev` again. 
    55  If you have a development environment already created, run `otto dev destroy` first.
    56  
    57  Once this process completes, you should notice some output about
    58  setting up "mongodb" in various places. Otto automatically installs
    59  and configures dependencies within the development environment. The
    60  dependencies are also automatically started.
    61  
    62  Dependencies are exposed via DNS by their name. If you SSH into the
    63  development environment and look up `mongodb.service.consul`, then
    64  you'll find the IP address for MongoDB (which should be local). In production,
    65  this will likely point to another machine.
    66  
    67  Notice how with only a few lines, and zero instructions for how to setup
    68  the dependency, Otto knows how to automatically install, configure, and
    69  start it in a development environment. As the number of dependencies
    70  increases, this becomes more and more valuable.
    71  
    72  ## Next
    73  
    74  Otto makes developing and deploying applications with dependencies
    75  incredibly simple, and a huge improvement over other tools.
    76  
    77  Modern application development is moving further and further towards
    78  microservices and many separate applications communicating together.
    79  By representing dependencies as a first class citizen, Otto eliminates
    80  much of the friction associated with this model.
    81  
    82  Next, we'll learn how to
    83  [teardown](/intro/getting-started/teardown.html)
    84  all the resources we've created with Otto.
    85