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
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.
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
| Feature | run.initCommands | run.prepareCommands |
|---|---|---|
| When | Every container start/restart | Only when building runtime image |
| Cached | Never | Yes (base layer cache) |
| Use for | Migrations, cache warming, cleanup | OS packages, system deps |
| Deploy files | Present in /var/www | Not available -- DO NOT reference app files |
| Reruns on | Restart, scaling, deploy | Only when commands change |
envReplace (Variable Substitution)
Replaces placeholders in deployed files with env var values at deploy time.
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)
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/302only for absolutefrom),preservePath,preserveQuery(both only with astatus)headers[]:for(same matching asfrom,"/*"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 ignoresrun.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)
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'srun.envVariables,run.ports, etc. - Maps (
envVariables): merged. Child keys are added, same-named keys take the child value, remaining parent keys stay.KEY: nullremoves an inherited variable (KEY: ""is a regular empty value);envVariables: nulldrops the whole inherited map. - Lists (
buildCommands,prepareCommands,initCommands,deployFiles,ports,startCommands,crontab,cacheas a list): replaced as a whole, never appended. Repeat the full list in the child.[]clears it. - Chains resolve transitively (
prodextendsstagingextendsbase) in any file order, up to 25 levels deep. A setup cannot extend itself. - Must reference another
setupname in the same file. - Multiple parents (
extends: [base, logging]): resolved exactly as ifloggingextendedbaseand the child extendedlogging. 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@22oralpine/nodejs@22— with no separateos:field; use the same prefix inbuild.baseandrun.base(a barenodejs@22resolves to Alpine, andrun.baserewrites the service OS on deploy) - PHP: build
<os>/php@X, run<os>/php-nginx@Xor<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, runalpine/static(the barestaticshorthand means the same) @latest= newest stable version