app.yaml is the declarative spec Levelrail reads from your repo: services, their build and runtime settings, and the managed databases they use. The control plane validates every field below against the JSON Schema embedded in it (internal/spec/schema/app.schema.json). An unknown key is an error, not something that gets quietly ignored.
Levelrail looks for the file under these names, in this order: app.yaml, app.yml, deploy.yaml, deploy.yml, then the product’s own name with a .yaml or .yml extension. The generic names come first so a repo that already committed app.yaml keeps working.
To start a new file, run levelrail-cli apps init. It writes a valid app.yaml with the optional fields listed as comments, taken from the same schema.
Minimal example
The smallest valid file deploys one prebuilt image. A flat file with onlyname, image and port at the top level fails validation: the schema needs version and a services map.
levelrail-cli apps validate --file app.yaml.
Full example
image: ghcr.io/your-org/web:1.0 on the service is shorthand for build: { type: image, image: ... }.
Field reference
Top level (Spec)
Service (an entry under services)
Build
Egress
Opt-in outbound allowlist for one service. Without it the service’s outbound traffic is unrestricted. Not valid with build.type of static or compose.
Volume (an entry under volumes)
Exactly one of name or hostPath must be set:
name: declares a named Docker volume (scoped to this service)hostPath: a bind mount of a real directory on the node where the service runs
apps create --file attaches named volumes only. A hostPath entry is refused before the app is created, with a message naming the alternative. For a host bind mount on a new app, use a compose file with apps deploy-compose <name> --file, for example - /srv/cfg:/usr/share/nginx/html:ro (the :ro suffix mounts it read-only).
Constraint: Two volumes on the same service can never share a path.
Health
Probe
A probe is either an HTTP(S) request (set path) or a command run inside the container (set exec), never both.
Health checks
Readiness gates a deploy’s cutover: the new container has to pass it before the old one is retired. Liveness runs on every reconcile pass against a running container and restarts it afterfailures consecutive failures. An HTTP probe needs a port; an exec probe does not, so a worker with nothing listening can still have one.
Ready condition (reason ReadinessFailed, RunningNotReady, LivenessDegraded, and so on), and the message says exactly what failed, for example:
GET https://127.0.0.1:32768/health returned 302 to /login; set follow_redirects or expected_status (currently 200-299)GET https://127.0.0.1:32768/ : TLS verification failed: x509: certificate signed by unknown authority; set tls_skip_verify for a self-signed certificateexec "redis-cli -p 6390 ping" exited 1: Could not connect to Redis at 127.0.0.1:6390: Connection refusedGET http://127.0.0.1:32768/healthz timed out after 2s
levelrail-cli apps health set, and through PUT /api/v1/apps/{name}/health.
A Compose file’s healthcheck: is translated into a readiness probe: a curl/wget command becomes an HTTP(S) probe that keeps the tool’s own semantics (curl -L follows redirects, curl -f accepts any status below 400, -k/--no-check-certificate skip TLS verification), start_period widens the readiness budget, and any other command (pg_isready, redis-cli ping, mysqladmin ping) becomes an exec probe. A bare /dev/tcp connect check is not translated.
Resources
Security
An app that writes elsewhere (an nginx cache under
/var/cache/nginx, a database data directory, an upload folder) needs a volume at that path, or it fails with Read-only file system in its logs. Fleet-wide true skips services that declare files.
LoadBalancer
All fields are optional. Durations are Go duration strings such as 500ms, 5s or 2m. See Load balancing for behavior.
Budget
All fields are optional, but at least one of egress and cost is required. See Spend caps for behavior.
Workload
Reserved, not yet scheduled. These fields validate, but nothing reads them yet: an app that sets them deploys exactly as before.
perNode fields (with workload: per-node):
ordered fields (with workload: ordered):
Refused for both kinds:
domains, a rollout.max_surge above 0, static and compose builds, and a service name longer than 55 characters. A per-node service also refuses replicas and strategy.
Next
With
cache: redis the deploy needs a linked Redis database (levelrail-cli databases create --name X --engine redis, then databases link). Levelrail then sets LEVELRAIL_NEXT_CACHE_URL from that link and NEXT_BUILD_ID to the deploy id at build and runtime, never overriding values you set. The cache handler package is kit/next-cache-handler.
Autoscale
max, metric and target are required. autoscale owns the replica count, so replicas must be left out. See Autoscaling for behavior.
Canary
Defaults for a staged canary release (levelrail-cli apps canary start --stages ...). Set strategy: canary or this block and a deploy saves it for the app. Unset fields use the operator’s APP_CANARY_* defaults. See Canary deploys.
Hooks
Shell commands the reconciler runs inside the service’s own container via the Docker Engine API’s exec facility (sh -c <command>), not by shelling out.
Rules
- At least one of
preDeploy/postDeploymust be set; an emptyhooks: {}block is rejected. - With more than one replica, each hook runs exactly once per deploy (against the first replica), not once per replica. Running a database migration once per replica would be wrong, even though every replica gets a fresh container from the same image.
- The most recent outcome of each hook (exit code, captured output) is queryable via
GET /api/v1/apps/{name}/hook-runs.
Job (an entry under jobs)
See Scheduled jobs for how runs, retries and catch-up behave.
EnvVar (an entry under env)
Each value under env is either a plain string scalar (a literal value) or
an object with these fields.
The object form must set at least one of
from, secret, or vault.
vault is mutually exclusive with both from and secret: a given env
var resolves its value from exactly one source.
VaultRef (external secrets integration)
VaultRef field reference
VaultRef field reference
Database (an entry under databases)
Backup
Procfile and app.json at deploy
A repo with aProcfile and no app spec (app.yaml, app.yml, deploy.yaml, deploy.yml) is translated at deploy time. A repo that has an app spec is never touched. The offline import config command uses the same rules, so you can preview the result first.
- One service per process type.
webgets the port (default 8080, set by thedeploy.procfile_default_portruntime setting) andPORTset to match. Other types are workers; the port the spec requires on every service is set but nothing needs to listen on it. release:becomeshooks.preDeployonweb, or on the first process when there is nowebline.- With a
Dockerfilein the repo, services build from it and each Procfile command replaces the imageCMDfor that service. Without one, Railpack builds the app. app.jsonkeys:healthchecksmap tohealth(startupandreadinessto readiness,livenessto liveness),cronentries tojobs,scripts.dokku.predeployandpostdeploy(andscripts.postdeploy) to hooks,formation.<type>.quantitytoreplicas,envvalues to service env.- A
CHECKSfile, when it is among the translated files andapp.jsonhas nohealthchecksforweb, maps its first path line tohealth.readiness, withTIMEOUTastimeoutandATTEMPTSasfailures. Text matches, host-prefixed lines,WAITand extra paths produce findings.app.jsonhealthchecks win when both exist. - Add-on databases are not created at deploy. Each one produces a finding telling you to create and link the database.
- Anything else, such as
environments, other scripts or healthcheck command checks, produces a finding. Findings appear as log lines in the deploy output and as warnings on the deploy result; nothing is dropped silently.
Inline Dockerfile (no git repository)
An app can build from Dockerfile text you paste or upload, with a few optional extra context files, and no git host or repository. It is the no-git counterpart of a git source’sbuild.type: dockerfile with build.path.
- Dashboard: the app’s Source tab, Inline Dockerfile card.
- CLI:
apps deploy <app> --dockerfile-file ./Dockerfileorcat Dockerfile | apps deploy <app> --dockerfile -, plus--context-file conf/app.conf(repeatable). Context files must be relative paths inside the current directory; symlinks and special files are refused. - API:
POST /api/v1/apps/{name}/buildswith{"build":{"type":"dockerfile"},"inline_source":{"dockerfile":"...","files":[{"path":"conf/app.conf","content":"..."}]}}. It cannot be combined withrepo_url,upload_hashorfrom_cache, andbuild.pathandbuild.base_directorydo not apply.
deploy.inline_source_max_bytes (default 256 KiB, the Dockerfile plus every file name and body) and deploy.inline_source_max_files (default 20). Content over either limit gets HTTP 413. File names must be clean relative paths: no .., no leading /, no backslash, and not Dockerfile itself.
The text is stored by its sha256 so a queued or retried deploy rebuilds the same bytes. Each app keeps its newest deploy.inline_source_keep sources (default 10); an hourly sweep deletes older ones unless a queued, held or running deploy still needs them. File names that differ only by case or Unicode normalization, or a file that is also a parent directory of another, are refused. In the deploy history, the deploy shows the first 12 hex characters of that hash as its commit. The build context is written to a private temporary directory (0700 directories, 0600 files) and removed after the build. Builds run in the same builder sandbox with the same base image and registry policy as a git deploy, and the same deploy permission, freeze windows and protected environments apply. The audit log records the hash, byte size and file count, never the text.
Bind addresses and exposure
Every published port (a service’sport/host_port, and a managed database’s public-access port; see managing databases) binds to bind_address, resolved by internal/bindaddr.Resolve:
Default behavior
private is the default for anything created after this field shipped. A service or database that was already publicly exposed before the field existed was backfilled to public and keeps that exposure. The private default only applies to a newly created resource when a redeploy or public-access change leaves bind_address unset.
Validation
Validation rules and implementation
Validation rules and implementation
spec.Parse (internal/spec/spec.go) runs two layers. Both must pass before a caller sees a Spec.Layer 1: Structural shape
Checked against the embedded JSON Schema atinternal/spec/schema/app.schema.json (compiled and cached by compiledAppSchema in internal/spec/schema.go).Coverage:- Required fields
- Enums
- String patterns (durations, memory sizes)
- Numeric ranges
- Rejection of unknown keys
Layer 2: Semantic rules
Checked by(*Spec).Validate in internal/spec/validate.go for anything the schema can’t express because it depends on multiple fields.Names- Service and database names must match
^[a-z][a-z0-9-]*$. - A domain can only be claimed by one service in the whole spec.
build.pathis required whenbuild.typeiscompose.build.imageis required whenbuild.typeisimageand rejected for any other type.build.pathandbuild.baseDirectoryare rejected forimage, andbuild.baseDirectoryis rejected forcompose.build.baseDirectorymust be relative and must not escape the repository root.routes,headersandstaticare only meaningful whenbuild.typeisstatic; see Static site routing rules.build.argsis only meaningful whenbuild.typeisdockerfile. Set with any other build type, it is rejected rather than silently ignored.build.secretsfollows the same rule. A secret is only usable frombuild.secretsafter it is enabled for builds, which is off by default: use the Build switch on the secret’s row on the app Environment page (it asks for confirmation when turned on), orapps secrets build-time.
portis required unlessbuild.typeisstatic.portis forbidden whenbuild.typeisstatic.
strategy, if set, must be one of the three known values (a redundant check behind the schema’s enum;Validateis documented as safe to call on a hand-builtSpecthat never went through schema validation).
ValidateLabels (internal/spec/labels.go):- At most 32 labels per service
- Keys up to 255 characters
- Values up to 4096 characters
- No empty keys
- No key starting with the reserved prefix
platform-reserved.(kept open for the platform’s own bookkeeping labels)
resources.swapMemoryrequiresresources.memoryto also be set.resources.swapMemorymust be at leastresources.memory(checked during deploy translation ininternal/deploy, since both values need byte conversion). Docker’sMemorySwapis the combined memory+swap ceiling, not swap on top of memory.
egressis rejected whenbuild.typeisstaticorcompose.modemust beallowlistwith at least oneallowentry, each a hostname or IPv4 address with a valid port.
- Each
dependsOnentry must name another service in the file, not itself, and not astaticorcomposeservice. A cycle is rejected.
jobsis rejected whenbuild.typeisstaticorcompose, for the same reason ashooks. Job names must be unique within the service, the schedule must parse as a cron expression,timezonemust be a known IANA zone, and durations must be positive.hooksis rejected whenbuild.typeisstatic(no container to run a command in) orcompose(a wrapper that expands into N real services; onehooksblock cannot unambiguously target any of them).- An empty
hooks: {}block is rejected at the schema layer (the schema’s ownminProperties: 1).
- Each volume’s
name(if a named volume) must match^[a-z][a-z0-9-]*$. - No two volumes on the same service may share a name or the same
path. - Each volume’s
hostPath(if a bind mount) must be an absolute path. hostPathis rejected under protected system paths:/,/etc,/root,/boot,/sys,/proc,/var/lib/docker,/var/run/docker.sock, or/var/run./var/run/docker.sockis excluded by design (it’s a full container-escape-to-host-root vector; this feature doesn’t grant that capability).hostPathis also rejected when it is or sits inside a credential directory (.ssh,.gnupg,.aws,.kube,.docker), is a bare home directory such as/home/deploy, or is under/var/logor/usr/local/etc. SetAPP_BIND_ALLOWED_ROOTS(colon-separated absolute directories, for example/srv/apps:/mnt/nas) on the control plane to allow bind mounts only inside those directories.readOnly: trueon a volume withnameset (nothostPath) is rejected (no meaning for a named Docker volume).
Additional guard: strict YAML parsing
spec.Parse also runs yamlUnmarshalStrict (YAML decode with KnownFields(true)) as an independent guard against struct tags and JSON Schema drifting apart. An unknown key becomes a decode error during development rather than a silently dropped field in production.Deploy trigger patterns
Trigger patterns are git source settings, notapp.yaml fields: they decide which pushed refs deploy before anything is cloned, so they live with the branch and trigger mode. Set them on the app’s Source tab, with levelrail-cli apps git-source settings <app> --tag-pattern ... --branch-pattern ..., or with PUT /api/v1/apps/{name}/git-source/deploy-settings (tag_pattern, branch_pattern).
- A list is comma or newline separated. Patterns match the short ref name:
refs/heads/andrefs/tags/are stripped, and a pattern that starts withrefs/is rejected. *matches within one path segment (not/),**matches across/,?matches one character. Allowed characters are letters, digits and- _ . / + @. There are no regular expressions, classes or braces, and matching runs in time bounded by the pattern and ref length.- A pattern starting with
!excludes. Order: if any!pattern matches the ref is skipped, whatever its position in the list; otherwise the ref deploys when a positive pattern matches; a list of only!patterns allows every other ref. - A branch pattern replaces the single branch match with the matching branches of the same repository. It never admits tags,
refs/pull/refs, other refs, or pushes for another repository. A tag pattern only narrows which tags deploy. While a branch pattern is set, the background poller does not poll the source, since one polled branch head cannot stand for a set of branches; webhooks are the only trigger. - Branch deploys come first: when branch deploys are on and a pushed branch is eligible for one, it gets its own branch environment and the trigger pattern is not consulted. Keep the branch deploy patterns and the trigger branch pattern disjoint.
- A ref longer than the
git.trigger_ref_max_bytesruntime setting, not valid UTF-8, or containing control characters never matches.git.trigger_patterns_max,git.trigger_pattern_max_lengthandgit.trigger_pattern_list_max_bytes(total bytes of one list) cap a list, which bounds the matching cost of every push; an invalid list is rejected with a 400 when saved. - A skipped push answers 200 with the reason in the webhook delivery log and does not deploy. Path filters, the CI gate, protected environments and freeze windows still apply to a push that matches. Every change writes an audit row with the pattern text.
Next steps
Getting started
Deploy your first app with an
app.yaml.Deploying apps
Secrets, environment setup, rollouts and rollbacks.
Managing databases
Database configuration and backups.
Git integrations
Branch, push versus release trigger, and webhooks. None of that lives in
app.yaml.