Skip to main content
Skip to main content
🚧 Work in Progress

Zerops YAML Configuration

The zerops.yml file is crucial for defining how Zerops should build and deploy your application. Add the zerops.yml file to the root of your repository and customize it to suit your application's needs.


🙌Quick Links to Runtime-Specific Guides

Basic Structure​

zerops.yml
zerops:
- setup: <service_name>
build: ...
run: ...
  • The top-level element is always zerops.
  • setup contains the hostname of your service (must exist in Zerops).
  • Multiple services can be defined in a single zerops.yml (useful for monorepos):
zerops:
- setup: app
build: ...
run: ...

- setup: api
build: ...
run: ...

Each service configuration requires build and run sections. An optional deploy section can be added for readiness checks.

Build Configuration​

base ​

Sets the base technology for the build environment. See available options.

build:
base: nodejs@latest

You can specify multiple technologies:

build:
base:
- nodejs@latest
prepareCommands:
- zsc add python@3.9

os ​

Sets the operating system for the build environment. Options:

  • alpine (default)
  • ubuntu

Current versions:

  • Alpine 3.20
  • Ubuntu 24.04
build:
os: ubuntu

prepareCommands ​

Customizes the build environment by installing additional dependencies or tools.

build:
prepareCommands:
- apt-get update
- apt-get install -y some-package

buildCommands ​

Defines the commands to build your application.

build:
buildCommands:
- npm install
- npm run build

Running commands in a single shell instance:​

buildCommands:
- |
npm install
npm run build

deployFiles ​

Specifies which files or folders to deploy after a successful build.

build:
deployFiles:
- dist
- package.json
- node_modules

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/.

deployFiles: ./path/~/to/file.txt

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.

Tip

For consistency, it's recommended to configure both your .gitignore and .deployignore files with the same patterns.

Examples:

zerops.yml
zerops:
- setup: app
build:
deployFiles: ./
.deployignore
/src/file.txt

The example above ignores file.txt only in the root src directory.

.deployignore
src/file.txt

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
Note

.deployignore file also works with zcli service deploy command.

cache ​

Defines which files or folders to cache for subsequent builds.

build:
cache: node_modules

For more information, see our detailed guide on build cache, complete with extensive examples.

envVariables ​

Sets environment variables for the build environment.

build:
envVariables:
DB_NAME: db
DB_HOST: db
DB_USER: db
DB_PASS: ${db_password}
Info

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.

Runtime Configuration​

base ​

Sets the base technology for the runtime environment. If not specified, the current version is maintained.

run:
base: nodejs@latest

os ​

Sets the operating system for the runtime environment. Options and versions are the same as for the build environment.

ports ​

Specifies the internal ports on which your application will listen.

run:
ports:
- port: 8080
protocol: TCP # Optional
httpSupport: true # Optional
- port: 8081
...

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) or UDP

httpSupport ​

Indicates whether the port is running a web server:

  • Default value: true
  • Set to false if a web server isn't 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.

addToRunPrepare ​

Defines files or folders to be copied from the build container to the prepare runtime container.

initCommands ​

Defines commands to run each time a new runtime container starts or restarts.

run:
initCommands:
- rm -rf ./cache

start ​

Defines the start command for your application.

run:
start: npm start

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.yml
name: replication
# restore the database on container init
initCommands:
- litestream restore -if-replica-exists -if-db-not-exists -config=litestream.yml $DB_NAME

See start-commands-example

documentRoot ​

Customizes the root folder for publicly accessible web server content (available only for webserver runtimes).

siteConfigPath ​

Sets the custom webserver configuration (available only for webserver runtimes).

envVariables ​

Defines environment variables for the runtime environment.

    run:
base: nodejs@20
envVariables:
DB_NAME: db
DB_HOST: db
DB_USER: db
DB_PASS: ${db_password}

healthCheck ​

Defines a health check for your application.

run:
healthCheck:
httpGet:
port: 80
path: /status

crontab ​

Defines scheduled commands to run as cron jobs within a service.

run:
crontab:
- command: "date >> /var/log/cron.log"
timing: "0 * * * *"

Setup cron jobs. See examples.

Deploy Configuration​

readinessCheck ​

Defines a readiness check for your application. (See readiness checks)

deploy:
readinessCheck:
httpGet:
port: 80
path: /status
host: 127.0.0.1
scheme: https

# Or use commands
exec:
command: |
touch grass
rm -rf life
mv /outside/user /home/user
Note

For more detailed information on specific configurations, refer to the runtime-specific guides linked at the beginning of this document.