Skip to main content
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 only name, image and port at the top level fails validation: the schema needs version and a services map.
Check any file before you deploy it with levelrail-cli apps validate --file app.yaml.

Full example

A prebuilt image needs no build block: 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 after failures consecutive failures. An HTTP probe needs a port; an exec probe does not, so a worker with nothing listening can still have one.
Every probe result lands in the app’s 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 certificate
  • exec "redis-cli -p 6390 ping" exited 1: Could not connect to Redis at 127.0.0.1:6390: Connection refused
  • GET http://127.0.0.1:32768/healthz timed out after 2s
The same settings are editable in the dashboard (app, then Health), with 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/postDeploy must be set; an empty hooks: {} 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)

The value is read fresh from Vault immediately before the container is created and is never persisted by Levelrail.If Vault is unreachable, not configured, or the secret/field doesn’t exist, the deploy fails loudly rather than starting the container with the variable empty.

Database (an entry under databases)

Backup

Procfile and app.json at deploy

A repo with a Procfile 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. web gets the port (default 8080, set by the deploy.procfile_default_port runtime setting) and PORT set to match. Other types are workers; the port the spec requires on every service is set but nothing needs to listen on it.
  • release: becomes hooks.preDeploy on web, or on the first process when there is no web line.
  • With a Dockerfile in the repo, services build from it and each Procfile command replaces the image CMD for that service. Without one, Railpack builds the app.
  • app.json keys: healthchecks map to health (startup and readiness to readiness, liveness to liveness), cron entries to jobs, scripts.dokku.predeploy and postdeploy (and scripts.postdeploy) to hooks, formation.<type>.quantity to replicas, env values to service env.
  • A CHECKS file, when it is among the translated files and app.json has no healthchecks for web, maps its first path line to health.readiness, with TIMEOUT as timeout and ATTEMPTS as failures. Text matches, host-prefixed lines, WAIT and extra paths produce findings. app.json healthchecks 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’s build.type: dockerfile with build.path.
  • Dashboard: the app’s Source tab, Inline Dockerfile card.
  • CLI: apps deploy <app> --dockerfile-file ./Dockerfile or cat 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}/builds with {"build":{"type":"dockerfile"},"inline_source":{"dockerfile":"...","files":[{"path":"conf/app.conf","content":"..."}]}}. It cannot be combined with repo_url, upload_hash or from_cache, and build.path and build.base_directory do not apply.
Limits are runtime settings: 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’s port/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

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 at internal/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
YAML is decoded generically and round-tripped through JSON so the schema validator sees the same shapes as real JSON input.

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 configuration
  • build.path is required when build.type is compose.
  • build.image is required when build.type is image and rejected for any other type. build.path and build.baseDirectory are rejected for image, and build.baseDirectory is rejected for compose.
  • build.baseDirectory must be relative and must not escape the repository root.
  • routes, headers and static are only meaningful when build.type is static; see Static site routing rules.
  • build.args is only meaningful when build.type is dockerfile. Set with any other build type, it is rejected rather than silently ignored. build.secrets follows the same rule. A secret is only usable from build.secrets after 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), or apps secrets build-time.
Example of a build secret:
Port configuration
  • port is required unless build.type is static.
  • port is forbidden when build.type is static.
Strategy
  • strategy, if set, must be one of the three known values (a redundant check behind the schema’s enum; Validate is documented as safe to call on a hand-built Spec that never went through schema validation).
Service labelsChecked by 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)
Resource limits
  • resources.swapMemory requires resources.memory to also be set.
  • resources.swapMemory must be at least resources.memory (checked during deploy translation in internal/deploy, since both values need byte conversion). Docker’s MemorySwap is the combined memory+swap ceiling, not swap on top of memory.
Egress
  • egress is rejected when build.type is static or compose. mode must be allowlist with at least one allow entry, each a hostname or IPv4 address with a valid port.
Dependencies
  • Each dependsOn entry must name another service in the file, not itself, and not a static or compose service. A cycle is rejected.
Hooks
  • jobs is rejected when build.type is static or compose, for the same reason as hooks. Job names must be unique within the service, the schedule must parse as a cron expression, timezone must be a known IANA zone, and durations must be positive.
  • hooks is rejected when build.type is static (no container to run a command in) or compose (a wrapper that expands into N real services; one hooks block cannot unambiguously target any of them).
  • An empty hooks: {} block is rejected at the schema layer (the schema’s own minProperties: 1).
Volumes
  • 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.
  • hostPath is rejected under protected system paths: /, /etc, /root, /boot, /sys, /proc, /var/lib/docker, /var/run/docker.sock, or /var/run. /var/run/docker.sock is excluded by design (it’s a full container-escape-to-host-root vector; this feature doesn’t grant that capability).
  • hostPath is 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/log or /usr/local/etc. Set APP_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: true on a volume with name set (not hostPath) 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, not app.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/ and refs/tags/ are stripped, and a pattern that starts with refs/ 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_bytes runtime setting, not valid UTF-8, or containing control characters never matches. git.trigger_patterns_max, git.trigger_pattern_max_length and git.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.
Last modified on November 12, 2026