Skip to main content
You can deploy multiple Porter apps alongside multiple Porter addons in a single porter.yaml file. Currently only in-cluster datastores are supported for now. Requires Porter CLI v0.68.30 or later. Check your version with porter version, and see the CLI installation guide to install or upgrade.
porter apply -f porter.yaml --wait
To guarantee that the datastore and its env group are ready before the app starts, use the —wait flag. Addons are always applied before apps, and --wait holds the apply until each datastore is fully available (up to 10 minutes) before any apps deploy. This guarantees that the datastores’ environment groups and credentials exist by the time the apps start. The flag also waits for each app’s rollout to succeed before exiting. Without --wait, the CLI proceeds about 10 seconds after creating a datastore. Apps may then fail their first deploy with a missing-environment-group error until the datastore finishes provisioning. When a datastore is provisioned, Porter automatically creates an environment group with the same name as the datastore. This environment group holds the datastore’s connection details (host, port, credentials, etc.) as environment variables. To link a datastore to an app, reference that environment group by name in the app’s envGroups section. The entry must match the datastore’s name exactly. For example, to connect an app to a datastore named cache:
envGroups:
  - cache
Embed the app schema as an item in the apps: list. Then attach addons as a list of addons: items.

Example Configuration

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: redis
    kind: in-cluster
    config:
      storageGigabytes: 2 # Persistent storage size in GB. Cannot be changed after creation.
      cpuCores: 0.1
      ramMegabytes: 110
  - name: db
    type: postgres
    kind: in-cluster
    config:
      storageGigabytes: 2
      cpuCores: 0.1
      ramMegabytes: 110