Config as code: dispra.yaml
Describe an environment in one file, review what applying it would change, then apply exactly that. Keep the file in YAML in your repository, and send it as JSON to Plan a config file and Apply a config file (any YAML library converts it).
# dispra.yaml
project: prj_01jdk3m9x2v7c4q8w5n6b1t0ra # optional: refused for another project
environment: production # optional: refused for another environment
groups: [web, data]
variables: # the environment's shared variables
NODE_ENV: production
services:
api:
source: { repo: acme/api, branch: main } # or { image: ghcr.io/acme/api:1.4.2 }
group: web
build: { command: npm run build } # builder: railpack | dockerfile, dockerfile: path
start: { command: npm start, port: 3000 }
health: { path: /healthz, timeout_s: 5 }
restart: { policy: on_failure, max: 5 }
size: { cpu: 1000m, memory: 1Gi, disk: 2Gi } # per replica
regions: { india: 2, us: 1 } # or replicas: 2
variables:
DATABASE_URL: "{{ project.DATABASE_URL }}"
STRIPE_KEY: "${{ secret }}" # declared here, its value set through the API
domains: [api.acme.com]
worker:
source: { repo: acme/api, branch: main }
start: { command: node worker.js }
volumes: { uploads: /data }
volumes:
uploads: { size: 10Gi, backups: { every: 6h, keep: 7 } }
What the file manages. Only what it says. A service without health keeps its health check; a service of the environment the file doesn't name is listed as unmanaged, never touched. With prune, what the file leaves out is deleted: services, their variables, domains and regions, groups and shared variables. Volumes are never deleted by apply.
Secrets. Never put secret values in the file. ${{ secret }} declares a variable whose value you set with Set a service variable (or on the dashboard); the plan warns when it has no value yet.
Sizes. CPU in cores or millicores (1, 0.5, 500m), memory and disk with a unit (512Mi, 1Gi; disk in whole Gi). A service with a volume runs one replica in one region.
Plan, then apply.
- Plan: you get every change in order (
create service worker,update service api: replicas 1 → 2), what is unmanaged, and warnings. - Apply with the plan's
plan_hash. If the environment changed since, apply refuses with409 plan_staleand the new plan. - Every service that was created or changed is deployed (
deploy: falseto skip).
Start from what you have. Export the environment writes the current environment as a file. Planning it changes nothing, so you can commit it and manage the environment from Git from then on.