Skip to main content
Skip to main content

zerops.yml Advanced Behavioral Reference

Behavioral semantics for advanced zerops.yml features: health/readiness checks, deploy strategies, cron, background processes, runtime init, envReplace, routing, and extends. Schema is in grammar.md -- this file covers what the schema cannot express.


Health / Readiness Checks & temporaryShutdown​

Health checks (run.healthCheck, continuous), readiness checks (deploy.readinessCheck, deploy-time traffic gate), the httpGet/exec shape + params + failure sequence, the dev/stage placement rule (dev uses start: zsc noop --silent, no healthCheck), and temporaryShutdown deploy ordering are all owned by zerops_knowledge uri="zerops://guides/readiness-health-checks".


Crontab Execution​

run:
crontab:
- command: "php artisan schedule:run"
timing: "* * * * *"
workingDir: /var/www/html
allContainers: false

Parameters: command (required), timing (required, 5-field cron: min hour dom mon dow), allContainers (required by the schema — false = one container, true = all containers), workingDir (optional, default /var/www).

Cron runs inside the runtime container with full env var access. When allContainers: false, Zerops picks one container (good for DB jobs). Use true for cache clearing or log rotation everywhere. Minimum granularity is 1 minute.


startCommands (Background Processes)​

Runs multiple named processes in parallel. Mutually exclusive with start.

run:
startCommands:
- command: npm run start:prod
name: server
- command: litestream replicate -config=litestream.yaml
name: replication
initCommands:
- litestream restore -if-replica-exists -if-db-not-exists $DB_NAME

Each entry: command (required — the only field the schema requires), name (optional, distinguishes processes in logs), workingDir (optional), user (optional, system user the command and its initCommands run under, default zerops, the user has to exist in the container), initCommands (optional, per-process init). DO NOT use both start and startCommands.


initCommands vs prepareCommands​

Featurerun.initCommandsrun.prepareCommands
WhenEvery container start/restartOnly when building runtime image
CachedNeverYes (base layer cache)
Use forMigrations, cache warming, cleanupOS packages, system deps
Deploy filesPresent in /var/wwwNot available -- DO NOT reference app files
Reruns onRestart, scaling, deployOnly when commands change

envReplace (Variable Substitution)​

Replaces placeholders in deployed files with env var values at deploy time.

run:
envReplace:
delimiter: "%%"
target: [./config/, ./templates/settings.json]

File containing %%DATABASE_URL%% gets the placeholder replaced with the actual value. Multiple delimiters supported: delimiter: ["%%", "##"]. Use for: secrets in config files, PEM certificates, frontend configs.

Directory targets are NOT recursive -- ./config/ processes only files directly in that directory. Specify subdirectories explicitly.


routing (Static Services Only)​

run:
routing:
cors: "'*' always"
redirects:
- { from: /old, to: /new, status: 301 }
- { from: /blog/*, to: /articles/, preservePath: true, status: 302 }
headers:
- for: "/*"
values: { X-Frame-Options: "'DENY'" }
  • cors: Sets Access-Control-Allow-Origin, -Allow-Methods, -Allow-Headers and -Expose-Headers to the same value. "*" auto-converted to '*'
  • redirects[]: from (exact path, or prefix with trailing *, or absolute URL matched on the domain), to, status (omit for a masked redirect, 301/302 only for absolute from), preservePath, preserveQuery (both only with a status)
  • headers[]: for (same matching as from, "/*" for everything, "/" is the homepage only), values (header key-value pairs, quotes included: "'DENY'"). Only the best-matching rule applies, rules are not merged.
  • root: Folder served, relative to /var/www. The Static service ignores run.documentRoot, this is its replacement.

DO NOT use on non-static services -- silently ignored. Conversely documentRoot is ignored on Static, and siteConfigPath is ignored on Static whenever routing is present.


extends (Configuration Inheritance)​

zerops:
- setup: base
build: { buildCommands: [npm run build], deployFiles: ./dist }
run: { start: npm start }
- setup: prod
extends: base
run: { envVariables: { NODE_ENV: production } }

The child is a deep copy of the resolved parent with its own keys applied on top. The merge is recursive, key by key:

  • Nested objects (build, run, deploy, healthCheck, readinessCheck, routing, ...): only the keys the child specifies are overwritten, everything else is inherited. run: { start: x } in the child keeps the parent's run.envVariables, run.ports, etc.
  • Maps (envVariables): merged. Child keys are added, same-named keys take the child value, remaining parent keys stay. KEY: null removes an inherited variable (KEY: "" is a regular empty value); envVariables: null drops the whole inherited map.
  • Lists (buildCommands, prepareCommands, initCommands, deployFiles, ports, startCommands, crontab, cache as a list): replaced as a whole, never appended. Repeat the full list in the child. [] clears it.
  • Chains resolve transitively (prod extends staging extends base) in any file order, up to 25 levels deep. A setup cannot extend itself.
  • Must reference another setup name in the same file.
  • Multiple parents (extends: [base, logging]): resolved exactly as if logging extended base and the child extended logging. Later parents win over earlier ones (including their own ancestry), the child's own keys win over all parents. Same map-merge / list-replace rules apply at every step.
zerops:
- setup: base
build: { buildCommands: [npm ci, npm run build], deployFiles: ./dist }
run: { start: npm start, envVariables: { LOG_LEVEL: info, NODE_ENV: development } }
- setup: prod
extends: base
build: { buildCommands: [npm ci, npm run build -- --mode=production] } # list replaced, deployFiles inherited
run: { envVariables: { NODE_ENV: production, LOG_LEVEL: null } } # merged: NODE_ENV=production, LOG_LEVEL removed; start inherited
- setup: logging
run: { envVariables: { LOG_LEVEL: debug, LOG_FORMAT: json } }
- setup: prod-debug
extends: [prod, logging] # everything from prod, then LOG_LEVEL=debug and LOG_FORMAT=json from logging; NODE_ENV=production inherited via prod

Base Images​

Available runtimes and versions are listed in Service Stacks (live) -- injected by zerops_knowledge and workflow responses. Some key rules:

  • The OS is part of the base value — ubuntu/nodejs@22 or alpine/nodejs@22 — with no separate os: field; use the same prefix in build.base and run.base (a bare nodejs@22 resolves to Alpine, and run.base rewrites the service OS on deploy)
  • PHP: build <os>/php@X, run <os>/php-nginx@X or <os>/php-apache@X (different bases)
  • Deno: ships only as ubuntu/deno@X (no Alpine image). Gleam runs on both Alpine and Ubuntu.
  • Static sites: build alpine/nodejs@latest, run alpine/static (the bare static shorthand means the same)
  • @latest = newest stable version