<commit_before>---
layout: "intro"
page_title: "Appfile"
sidebar_current: "gettingstarted-appfile"
description: |-
  Learn about the Appfile in the Otto getting started guide.
---

# Appfile

Up to this point, we've developed and deployed a Ruby application
with _zero configuration_. For a getting started experience, it is hard
to beat that.

For real applications, Otto will likely need some minimal configuration.
The file Otto uses for configuration is the `Appfile`. The Appfile is
meant to describe everything required to develop and deploy an application.

On this page, we'll write a simple Appfile that mimics the behavior that Otto
automatically gave us with zero configuration. Then, in the following
getting started pages, we'll augment the Appfile to add new behavior
to our environment.

## A Complete Appfile

We'll start by showing the complete Appfile, and then we'll go over
each part in the following sections. Save the following file to the
root of the example application in a file named "Appfile":

```
application {
  name = "otto-getting-started"
  type = "ruby"
}

project {
  name = "otto-getting-started"
  infrastructure = "otto-getting-started"
}

infrastructure "otto-getting-started" {
  type = "aws"
  flavor = "simple"
}
```

This is functionally equivalent to the behavior of Otto with zero
configuration for our example application.

The syntax of the Appfile is [documented here](/docs/appfile).

~> **WARNING:** Make sure the name of the infrastructure is not
changed above. If you change this, Otto will "lose" your infrastructure
and you'll have to destroy it manually.

## Appfile Compilation

Changes to an Appfile don't take effect for any Otto commands such
as `otto dev` until it is recompiled. To recompile an Appfile, use
`otto compile`.

This feature is very nice since even if other members of a team
might have edited the Appfile, your environment isn't affected
until you decide to recompile.

With the Appfile above, recompiling won't have any adverse effect,
since we've created an Appfile that is functionally equivalent to what
Otto did with zero configuration.

## Appfile Sections

Now that we've written an Appfile, let's dive into the each part of it.

The **application** section defines properties related to the application.
In our Appfile, we specify the name of the application and the type.
The type of the application is what tells Otto how to build our
development environment, builds, deploys, etc. The full set of
[application types](/docs/apps/index.html) is documented.

In addition to the name and type of the application, this section
can include application dependencies, which we cover in an upcoming
step in the getting started guide.

The **project** section defines the project that this application is part
of. Projects currently aren't used for anything other than organization
within Otto. The only important configuration here is the "infrastructure"
setting which tells Otto what infrastructure to target.

The **infrastructure** section defines the infrastructure targets
that this application can be deployed to. This section can be repeated
multiple times. The name of an infrastructure must be unique _globally_
throughout your usage of Otto. If the name of an infrastructure matches
another Appfile, then Otto will assume you want to deploy to the same
infrastructure.

There is another section that an Appfile can contain which we haven't
used yet: **customization**. The customation sections change the behavior
of Otto. We'll see customizations in use in an upcoming step in the
getting started guide.

## Compile and Verify

Once you've saved the Appfile, run `otto compile` again followed by
`otto status`. The status should still look like the following:

```
==> App Info
    Application:    otto-getting-started (ruby)
    Project:        otto-getting-started
    Infrastructure: aws (simple)
==> Component Status<commit_msg>Update appfile.html.md<commit_after>---
layout: "intro"
page_title: "Appfile"
sidebar_current: "gettingstarted-appfile"
description: |-
  Learn about the Appfile in the Otto getting started guide.
---

# Appfile

Up to this point, we've developed and deployed a Ruby application
with _zero configuration_. For a getting started experience, it is hard
to beat that.

For real applications, Otto will likely need some minimal configuration.
The file Otto uses for configuration is the `Appfile`. The Appfile is
meant to describe everything required to develop and deploy an application.

On this page, we'll write a simple Appfile that mimics the behavior that Otto
automatically gave us with zero configuration. Then, in the following
getting started pages, we'll augment the Appfile to add new behavior
to our environment.

## A Complete Appfile

We'll start by showing the complete Appfile, and then we'll go over
each part in the following sections. Save the following file to the
root of the example application in a file named "Appfile":

```
application {
  name = "otto-getting-started"
  type = "ruby"
}

project {
  name = "otto-getting-started"
  infrastructure = "otto-getting-started"
}

infrastructure "otto-getting-started" {
  type = "aws"
  flavor = "simple"
}
```

This is functionally equivalent to the behavior of Otto with zero
configuration for our example application.

The syntax of the Appfile is [documented here](/docs/appfile).

~> **WARNING:** Make sure the name of the infrastructure is not
changed above. If you change this, Otto will "lose" your infrastructure
and you'll have to destroy it manually.

## Appfile Compilation

Changes to an Appfile don't take effect for any Otto commands such
as `otto dev` until it is recompiled. To recompile an Appfile, use
`otto compile`.

This feature is very nice since even if other members of a team
might have edited the Appfile, your environment isn't affected
until you decide to recompile.

With the Appfile above, recompiling won't have any adverse effect,
since we've created an Appfile that is functionally equivalent to what
Otto did with zero configuration.

## Appfile Sections

Now that we've written an Appfile, let's dive into the each part of it.

The **application** section defines properties related to the application.
In our Appfile, we specify the name of the application and the type.
The type of the application is what tells Otto how to build our
development environment, builds, deploys, etc. The full set of
[application types](/docs/apps/index.html) is documented.

In addition to the name and type of the application, this section
can include application dependencies, which we cover in an upcoming
step in the getting started guide.

The **project** section defines the project that this application is part
of. Projects currently aren't used for anything other than organization
within Otto. The only important configuration here is the "infrastructure"
setting which tells Otto what infrastructure to target.

The **infrastructure** section defines the infrastructure targets
that this application can be deployed to. This section can be repeated
multiple times. The name of an infrastructure must be unique _globally_
throughout your usage of Otto. If the name of an infrastructure matches
another Appfile, then Otto will assume you want to deploy to the same
infrastructure.

There is another section that an Appfile can contain which we haven't
used yet: **customization**. The customization sections change the behavior
of Otto. We'll see customizations in use in an upcoming step in the
getting started guide.

## Compile and Verify

Once you've saved the Appfile, run `otto compile` again followed by
`otto status`. The status should still look like the following:

```
==> App Info
    Application:    otto-getting-started (ruby)
    Project:        otto-getting-started
    Infrastructure: aws (simple)
==> Component Status
{'fraction_non_alphanumeric': 0.05577486310963963, 'fraction_numerical': 0.0, 'mean_word_length': 4.538787023977433, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '931075', 'n_tokens_mistral': 1997, 'n_tokens_neox': 1902, 'n_words': 1122}