Zerops YAML Configuration
The zerops.yaml file is crucial for defining how Zerops should build and deploy your application.
Add the zerops.yaml file to the root of your repository and customize it to suit your application's needs.
Not all parameters are available for every service type. Most parameters work across different runtime services, but some are specific to certain service types (e.g., documentRoot for webserver services, routing for Static services). This documentation covers zerops.yaml configuration for runtime services.
Basic Structure
Multiple services can be defined in a single zerops.yaml (useful for monorepos):
Each service configuration requires a run section. Optional build and deploy sections can be added to further customize your process.
Service Configuration
setup
Contains the hostname of your service (must exist in Zerops).
extends
The extends key allows you to inherit configuration from another service defined in the same zerops.yaml file. This is useful for creating environment-specific configurations while maintaining a common base.
When using extends:
- The
extendsvalue must refer to another service'ssetupvalue in the same file - The child service starts as a full copy of the base service, then its own keys are applied on top
- Merging is recursive, key by key. Redefining
runin the child does not replace the wholerunsection, only the keys you specify inside it. The same applies to nested objects such ashealthCheckorreadinessCheck - Maps such as
envVariablesare merged: the child's keys are added to the base's keys, and a key defined in both takes the child's value. Setting a key tonullremoves the inherited variable (an empty string""is a regular value), andenvVariables: nulldrops the whole inherited map - Lists such as
buildCommands,initCommands,deployFiles,portsorstartCommandsare replaced as a whole, never appended. If you need to change a list, define the full list in the child - A base service can itself extend another service. Chains are resolved regardless of the order of services in the file. A service cannot extend itself
extendsalso accepts a list, for exampleextends: [base, logging]. The child is then resolved exactly as ifloggingextendedbaseand the child extendedlogging: later services in the list override earlier ones, and the child's own keys override all of them
The following example shows how maps and lists behave differently:
zerops:
- setup: base
build:
base: nodejs@22
buildCommands:
- npm ci
- npm run build
deployFiles: ./dist
run:
base: nodejs@22
start: npm start
envVariables:
LOG_LEVEL: info
NODE_ENV: development
- setup: prod
extends: base
build:
buildCommands:
- npm ci
- npm run build -- --mode=production
run:
envVariables:
NODE_ENV: production
LOG_LEVEL: null
- setup: dev
extends: base
run:
envVariables:
DEBUG: "1"
The resolved prod service is:
setup: prod
build:
base: nodejs@22 # inherited
buildCommands: # list replaced as a whole
- npm ci
- npm run build -- --mode=production
deployFiles: ./dist # inherited
run:
base: nodejs@22 # inherited
start: npm start # inherited
envVariables: # map merged key by key, LOG_LEVEL removed by null
NODE_ENV: production
And dev keeps everything from base and adds DEBUG:
Create a base service with common configuration and extend it for environment-specific services to keep your zerops.yaml file DRY (Don't Repeat Yourself).
Build Configuration
base
Sets the base technology for the build environment. See available options.
You can specify multiple technologies:
os
Deprecated. The operating system is part of the base value, for example ubuntu/nodejs@22 or alpine/nodejs@22. Use the OS-prefixed form in both build.base and run.base instead of setting os. A bare nodejs@22 defaults to Alpine.
Current versions:
- Alpine Linux
- Ubuntu
prepareCommands
Customizes the build environment by installing additional dependencies or tools.
build.prepareCommands run in the /home/zerops directory.
buildCommands
Defines the commands to build your application.
build.buildCommands run in the /build/source directory.
Running commands in a single shell instance:
deployFiles
Specifies which files or folders to deploy after a successful build.
The files/folders will be placed into /var/www folder in runtime, e.g. ./src/assets/fonts would result in /var/www/src/assets/fonts.
Using wildcards:
Zerops supports the ~ character as a wildcard for one or more folders in the path.
Deploys all file.txt files that are located in any path that begins with /path/ and ends with /to/.
By default, ./src/assets/fonts deploys to /var/www/src/assets/fonts, keeping the full path. Adding ~, like ./src/assets/~fonts, shortens it to /var/www/fonts
.deployignore
Add a .deployignore file to the root of your project to specify which files and folders Zerops should ignore during deploy. The syntax follows the same pattern format as .gitignore.
To ignore a specific file or directory path, start the pattern with a forward slash (/). Without the leading slash, the pattern will match files with that name in any directory.
For consistency, it's recommended to configure both your .gitignore and .deployignore files with the same patterns.
Examples:
The example above ignores file.txt only in the root src directory.
This example above ignores file.txt in ANY directory named src, such as:
/src/file.txt/folder2/folder3/src/file.txt/src/src/file.txt
.deployignore file also works with zcli service deploy command.
cache
Defines which files or folders to cache for subsequent builds.
For more information, see our detailed guide on build cache, complete with extensive examples.
addToRunPrepare
Defines files or folders to be copied from the build container to the prepare runtime container.
envVariables
Sets environment variables for the build environment.
The yamlPreprocessor option in your project & service import YAML allows you to generate random secret values, passwords, and public/private key pairs. For more information, see the yamlPreprocessor page.
Deploy Configuration
temporaryShutdown
Controls the container replacement order during deployment.
- Type:
boolean - Default:
false
When false (default): New containers are started before old containers are removed, ensuring zero-downtime deployment.
When true: Old containers are removed before new containers are started, causing temporary downtime but using fewer resources during deployment.
readinessCheck
Defines a readiness check for your application. Requires either httpGet object or exec object.
Readiness checks work similarly to health checks but are specifically for deployment. They verify if a new deployment is ready to receive traffic.
Available parameters:
httpGet and exec
The httpGet and exec options work the same way as in health checks. See that section for detailed parameter descriptions.
Common parameters
The following parameters can be used with either httpGet or exec readiness checks:
- failureTimeout - Time until container is marked as failed. Use a duration string with a unit, for example
"60s". - retryPeriod - Time interval between readiness check attempts, for example
"10s"(equivalent toexecPeriodin health checks).
Unlike health checks which run continuously, readiness checks only run during deployments to determine when your application is ready to accept traffic.
Runtime Configuration
base
Sets the base technology for the runtime environment. If not specified, the current version is maintained.
os
Deprecated, same as for the build environment: put the OS into run.base (ubuntu/nodejs@22) instead.
ports
Specifies the internal ports on which your application will listen.
Available parameters:
port
Defines the port number on which your application listens. Must be between 10 and 65435, as ports outside this range are reserved for internal Zerops systems.
protocol
Specifies the network protocol to use:
- Allowed values:
TCP(default) orUDP
httpSupport
Indicates whether the port is running a web server:
- Default value:
false - Set to
trueif a web server is running on the port - Only available with TCP protocol
- Used by Zerops for public access configuration
prepareCommands
Customizes the runtime environment by installing additional dependencies or tools.
run.prepareCommands run in the /home/zerops directory.
initCommands
Defines commands to run each time a new runtime container starts or restarts.
run.initCommands run in the /var/www directory.
start
Defines the start command for your application.
startCommands
Defines start commands.
Unlike start, you can define multiple commands that starts their own processes.
run:
startCommands:
# start the application
- command: npm run start:prod
name: server
# start the replication
- command: litestream replicate -config=litestream.yaml
name: replication
# restore the database on container init
initCommands:
- litestream restore -if-replica-exists -if-db-not-exists -config=litestream.yaml $DB_NAME
Each entry supports:
command(required) - the command to runname(optional) - distinguishes the process in logsworkingDir(optional, default/var/www) - the directory the command and itsinitCommandsrun inuser(optional, defaultzerops) - the system user the command and itsinitCommandsrun under. The user has to exist in the runtime container, create it inprepareCommands.initCommands(optional) - commands run before this process starts, each time a container starts or restarts