> ## Documentation Index
> Fetch the complete documentation index at: https://porter-mintlify-78b560c4.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Deploying multiple apps with porter.yaml

> Define and deploy multiple Porter applications alongside datastores and custom Helm chart addons in a single porter.yaml file using porter apply

You can deploy multiple Porter apps alongside multiple Porter addons in a single `porter.yaml` file. This is particularly useful when you need to deploy related services that work together, such as a web application with its associated database or cache.

<Warning> This feature is in development and is subject to change. </Warning>

### Usage

Run `porter apply` against a `porter.yaml` that uses the top-level `apps:` and `addons:` arrays. The CLI automatically detects the multi-app format and applies each addon and app in sequence.

```bash theme={null}
porter apply -f porter.yaml
```

### Waiting for addons to become available

Pass the `--wait` (`-w`) flag to block until each datastore addon reaches the `AVAILABLE` state before any apps are deployed. This is useful when your apps reference an addon's connection environment group (for example `db` or `cache` in the example below) — without `--wait`, an app can start rolling out before the datastore (and its generated env group) is ready, causing the app to crash on startup.

```bash theme={null}
porter apply -f porter.yaml --wait
```

`--wait` polls each addon for up to 10 minutes. After all addons are available, Porter applies the apps and, as before, waits for each app's rollout to complete.

## Example Configuration

```yaml theme={null}
apps:
  - version: v2
    name: backend
    services:
      - name: server
        run: ""
        type: web
        instances: 1
        cpuCores: 0.2
        ramMegabytes: 100
        terminationGracePeriodSeconds: 30
        port: 80
        sleep: false
        private: true
    envGroups: # Environment groups can be used to inject environment variables from the addons into the service.
      - cache
      - db
    image:
      repository: nginx
      tag: latest
  - version: v2
    name: frontend
    services:
      - name: dashboard
        run: ""
        type: web
        instances: 1
        cpuCores: 0.2
        ramMegabytes: 100
        terminationGracePeriodSeconds: 30
        port: 80
        sleep: false
        private: true
    envGroups:
      - cache
      - db
    image:
      repository: nginx
      tag: latest
  - version: v2
    name: api
    services:
      - name: worker
        run: ""
        type: worker
        instances: 1
        cpuCores: 0.2
        ramMegabytes: 100
        terminationGracePeriodSeconds: 30
        port: 80
        sleep: false
    envGroups:
      - cache
      - db
    image:
      repository: nginx
      tag: latest
addons:
  - name: cache
    type: MANAGED-REDIS
    engine: REDIS
    values:
      config:
        name: cache
        masterUserPassword: password
        allocatedStorage: 2 # Persistent storage size in GB. Cannot be changed after creation.
        cpuCores: 0.1
        ramMegabytes: 110
  - name: db
    type: MANAGED-POSTGRES
    engine: POSTGRES
    values:
      config:
        name: db
        masterUserPassword: password
        allocatedStorage: 2
        cpuCores: 0.1
        ramMegabytes: 110
```
