---------------------------------------- # Alpine > How To > Build Pipeline Zerops provides a customizable build and runtime environment for your Alpine application. ## Add zerops.yaml to your repository Start by adding `zerops.yaml` file to the **root of your repository** and modify it to fit your application: ```yaml zerops: # define hostname of your service - setup: app # ==== how to build your application ==== build: # REQUIRED. Set the base technology for the build environment: base: alpine@3.20 # OPTIONAL. Customize the build environment by installing additional packages # or tools to the base build environment. prepareCommands: - sudo apk add --no-cache something - curl something else # OPTIONAL. Build your application buildCommands: - # REQUIRED. Select which files / folders to deploy after # the build has successfully finished deployFiles: app # OPTIONAL. Which files / folders you want to cache for the next build. # Next builds will be faster when the cache is used. cache: some_file # ==== how to run your application ==== run: # OPTIONAL. Sets the base technology for the runtime environment: base: alpine@3.20 # OPTIONAL. Sets the internal port(s) your app listens on: ports: # port number - port: 8080 # OPTIONAL. Customize the runtime Alpine environment by installing additional # dependencies to the base Alpine runtime environment. prepareCommands: - sudo apk add --no-cache something - curl something else # OPTIONAL. Run one or more commands each time a new runtime container # is started or restarted. These commands are triggered before # your Alpine application is started. initCommands: - rm -rf ./cache # OPTIONAL. Your Alpine application start command start: ./app ``` The top-level element is always `zerops`. ### Setup The first element `setup` contains the **hostname** of your service. A runtime service with the same hostname must exist in Zerops. Zerops supports the definition of multiple runtime services in a single `zerops.yaml`. This is useful when you use a monorepo. Just add multiple setup elements in your `zerops.yaml`: ```yaml zerops: # definition for app service - setup: app # optional build: ... # optional deploy: ... # required run: ... # definition for api service - setup: api # optional build: ... # optional deploy: ... # required run: ... ``` Each service configuration contains at least the `run` section. Optional `build` and `deploy` sections can be added to further customize your process. ## Build pipeline configuration ### base _REQUIRED._ Sets the base technology for the build environment. Following options are available for Alpine builds: - `alpine@3.23`, `alpine@latest` - `alpine@3.22` - `alpine@3.21` - `alpine@3.20` - `alpine@3.19` - `alpine@3.18` - `alpine@3.17` ```yaml zerops: # hostname of your service - setup: app # ==== how to build your application ==== build: # REQUIRED. Sets the base technology for the build environment: base: alpine@3.20 ... ```

The base build environment contains {data.alpine.default}, [Zerops command line tool](/references/cli), `git` and `wget`.

:::info You can change the base environment when you need to. Just simply modify the `zerops.yaml` in your repository. ::: If you need to install more technologies to the build environment, set multiple values as a yaml array. For example: ```yaml zerops: # hostname of your service - setup: app # ==== how to build your application ==== build: # REQUIRED. Sets the base technology for the build environment: base: - alpine@3.20 prepareCommands: - zsc add nodejs@latest ... ``` See the full list of supported [build base environments](/zerops-yaml/base-list#runtime-services). To customize your build environment use the [prepareCommands](#preparecommands) attribute. :::note Modifying the base technology will invalidate your build cache. See our [Build Cache Documentation](/features/build-cache) for more details about cache invalidation. ::: ### prepareCommands _OPTIONAL._ Customizes the build environment by installing additional dependencies or tools to the base build environment. The base build environment contains: - {data.alpine.default} - [Zerops command line tool](/references/cli) - `git` and `wget` To install additional packages or tools add one or more prepare commands: ```yaml zerops: # hostname of your service - setup: app # ==== how to build your application ==== build: # REQUIRED. Set the base technology for the build environment: base: alpine@3.20 # OPTIONAL. Customize the build environment by installing additional packages # or tools to the base build environment. prepareCommands: - sudo apk add --no-cache something - curl something else ... ``` When the first build is triggered, Zerops will 1. create a build container 2. download your application code from your repository 3. run the prepare commands in the defined order The application code is available in `/build/source` before the prepare commands are triggered, so you can use any file from your repository in your prepare commands (e.g. a configuration file). The commands themselves run in the `/home/zerops` directory. :::note These commands are skipped when using cached environment. Modifying `prepareCommands` will invalidate your build cache. See our [Build Cache Documentation](/features/build-cache) for details about cache invalidation. ::: #### Command exit code If any command fails, it returns an exit code other than 0 and the build is canceled. Read the [build log](/alpine/how-to/logs#build-log) to troubleshoot the error. If the command ends successfully, it returns the exit code 0 and Zerops triggers the following command. When all prepare commands are finished, your custom build environment is ready for the build phase. #### Single or separated shell instances You can configure your prepare commands to be run in a single shell instance or multiple shell instances. The format is identical to [build commands](#buildcommands). ### buildCommands _OPTIONAL._ Defines build commands. ```yaml zerops: # hostname of your service - setup: app # ==== how to build your application ==== build: # REQUIRED. Set the base technology for the build environment: base: alpine@3.20 # OPTIONAL. Build your application buildCommands: - ... ``` Build commands are optional. Zerops triggers each command in the defined order in a dedicated build container, running from the `/build/source` directory. Before the build commands are triggered the build container contains: 1. base environment defined by the [base](#base) attribute 2. optional customisation of the base environment defined in the [prepareCommands](#preparecommands) attribute 3. your application code For detailed information about build commands, refer to the documentation for your specific technology (e.g., [Node.js](/nodejs/how-to/build-pipeline), [Go](/go/how-to/build-pipeline), [Python](/python/how-to/build-pipeline), etc.). #### Run build commands as a single shell instance Use following syntax to run all commands in the same environment context. For example, if one command changes the current directory, the next command continues in that directory. When one command creates an environment variable, the next command can access it. ```yaml buildCommands: - | cd src ./build.sh ``` #### Run build commands as separate shell instances When the following syntax is used, each command is triggered in a separate environment context. For example, each shell instance starts in the home directory again. When one command creates an environment variable, it won't be available for the next command. ```yaml buildCommands: - cd src - ./build.sh ``` #### Command exit code If any command fails, it returns an exit code other than 0 and the build is canceled. Read the [build log](/alpine/how-to/logs#build-log) to troubleshoot the error. If the command ends successfully, it returns the exit code 0 and Zerops triggers the following command. When all `buildCommands` are finished, the application build is completed and ready for the deploy phase. ### deployFiles _REQUIRED._ Selects which files or folders will be deployed after the build has successfully finished. To filter out specific files or folders, use [`.deployignore`](#deployignore) file. ```yaml # REQUIRED. Select which files / folders to deploy after # the build has successfully finished deployFiles: - app ``` Determines files or folders produced by your build, which should be deployed to your runtime service containers. The path starts from the **root directory** of your project (the location of `zerops.yaml`). You must enclose the name in quotes if the folder or the file name contains a space. 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`. #### Examples Deploys a folder, and a file from the project root directory: ```yaml deployFiles: - app - file.txt ``` Deploys the whole content of the build container: ```yaml deployFiles: . ``` Deploys a folder, and a file in a defined path: ```yaml deployFiles: - ./path/to/file.txt - ./path/to/dir/ ``` #### How to use a wildcard in the path 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/` ```yaml deployFiles: ./path/~/to/file.txt ``` Deploys all folders that are located in any path that begins with `/path/to/` ```yaml deployFiles: ./path/to/~/ ``` Deploys all folders that are located in any path that begins with `/path/` and ends with `/to/` ```yaml deployFiles: ./path/~/to/ ``` :::note Example 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`](https://git-scm.com/docs/gitignore#_pattern_format). 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: ```yaml title="zerops.yaml" zerops: - setup: app build: deployFiles: ./ ``` ```text title=".deployignore" /src/file.txt ``` The example above ignores `file.txt` only in the root src directory. ```text title=".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`](/references/zcli/commands#deploy) command. ::: ### cache _OPTIONAL._ Defines which files or folders will be cached for the next build. ```yaml # OPTIONAL. Which files / folders you want to cache for the next build. # Next builds will be faster when the cache is used. cache: file.txt ``` The cache attribute helps optimize build times by preserving specified files between builds. The cache attribute supports the [~ wildcard character](#how-to-use-a-wildcard-in-the-path). Learn more about the [build cache system](/features/build-cache) in Zerops. ### envVariables _OPTIONAL._ Defines the environment variables for the build environment. Enter one or more env variables in following format: ```yaml zerops: # define hostname of your service - setup: app # ==== how to build your application ==== build: base: alpine@3.20 … # OPTIONAL. Defines the env variables for the build environment: envVariables: MODE: production DB_NAME: db DB_HOST: db DB_USER: db DB_PASS: ${db_password} ``` Read more about [environment variables](/alpine/how-to/env-variables) in Zerops. ## Runtime configuration ### base _OPTIONAL._ Sets the base technology for the runtime environment. If you don't specify the `run.base` attribute, Zerops keeps the current Alpine version for your runtime. Following options are available for Alpine builds: - `alpine@3.23`, `alpine@latest` - `alpine@3.22` - `alpine@3.21` - `alpine@3.20` - `alpine@3.19` - `alpine@3.18` - `alpine@3.17` ```yaml zerops: # hostname of your service - setup: app # ==== how to build your application ==== build: # REQUIRED. Sets the base technology for the build environment: base: alpine@3.20 ... # ==== how to run your application ==== run: # OPTIONAL. Sets the base technology for the runtime environment: base: alpine@3.20 ... ```

The base runtime environment contains {data.alpine.default}, Zerops command line tool, `git` and `wget`.

:::info You can change the base environment when you need to. Just simply modify the `zerops.yaml` in your repository. ::: If you need to install more technologies to the runtime environment, set multiple values as a yaml array. For example: ```yaml zerops: # hostname of your service - setup: app # ==== how to build your application ==== build: # REQUIRED. Sets the base technology for the build environment: base: alpine@3.20 ... # ==== how to run your application ==== run: # OPTIONAL. Sets the base technology for the runtime environment: base: - alpine@3.20 prepareCommands: - zsc add nodejs@latest ... ``` See the full list of supported [run base environments](/zerops-yaml/base-list). To customise your build environment use the `prepareCommands` attribute. ### ports _OPTIONAL._ Specifies one or more internal ports on which your application will listen. Projects in Zerops represent a group of one or more services. Services can be of different types (runtime services, databases, message brokers, object storage, etc.). All services of the same project share a **dedicated private network**. To connect to a service within the same project, just use the service hostname and its internal port. For example, to connect to an Alpine service with hostname = "app" and port = 8080 from another service of the same project, simply use `app:8080`. Read more about [how to access an Alpine service](/references/networking/internal-access#basic-service-communication). Each port has following attributes:
Parameter Description
port Defines the port number. You can set any port number between 10 and 65435. Ports outside this interval are reserved for internal Zerops systems.
protocol Optional. Defines the protocol. Allowed values are TCP or UDP. Default value is TCP.
httpSupport Optional. httpSupport = true is the default setting for TCP protocol. Set httpSupport = false if a web server isn't running on the port. Zerops uses this information for the configuration of [public access](/features/access). httpSupport = true is available only in combination with the TCP protocol.
### prepareCommands _OPTIONAL._ Customises the Alpine runtime environment by installing additional dependencies or tools to the runtime base environment.

The base Alpine environment contains {data.alpine.default}, [Zerops command line tool](/references/cli) and `git` and `wget`. To install additional packages or tools add one or more prepare commands:

```yaml zerops: # hostname of your service - setup: app # ==== how to build your application ==== build: ... # ==== how to run your application ==== run: # OPTIONAL. Customise the runtime environment by installing additional packages # or tools to the base Alpine runtime environment. prepareCommands: - sudo apk add --no-cache something - curl something else ... ``` When the first deploy with a defined prepare attribute is triggered, Zerops will 1. create a prepare runtime container 2. optionally: [copy selected folders or files from your build container](#copy-folders-or-files-from-your-build-container) 3. run the `prepareCommands` commands in the defined order :::note `run.prepareCommands` run in the `/home/zerops` directory. ::: #### Command exit code If any command fails, it returns an exit code other than 0 and the deploy is canceled. Read the [prepare runtime log](/alpine/how-to/logs#prepare-runtime-log) to troubleshoot the error. If the command ends successfully, it returns the exit code 0 and Zerops triggers the following command. When all `prepareCommands` commands are finished, your custom runtime environment is ready for the deploy phase. #### Cache of your custom runtime environment Some packages or tools can take a long time to install. Therefore, Zerops caches your custom runtime environment after the installation of your custom packages or tools is completed. When the second or following deploy is triggered, Zerops will use the custom runtime cache from the previous deploy if following conditions are met: 1. Content of the [build.addToRunPrepare](#copy-folders-or-files-from-your-build-container) and `run.prepareCommands` attributes didn't change from the previous deploy 2. The custom runtime cache wasn't invalidated in the Zerops GUI. To invalidate the Zerops runtime cache go to your service detail in Zerops GUI, choose **Service dashboard & runtime containers** from the left menu and click on the **Open pipeline detail** button. Then click on the **Clear runtime prepare cache** button. When the prepare cache is used, Zerops doesn't create a prepare runtime container and executes the deployment of your application directly. #### Single or separated shell instances You can configure your prepare commands to be run in a single shell instance or multiple shell instances. The format is identical to [build commands](#buildcommands). ### Copy folders or files from your build container

The prepare runtime container contains {data.alpine.default}, [Zerops command line tool](/references/cli) and `git` and `wget`.

The prepare runtime container does not contain your application code nor the built application. If you need to copy some folders or files from the build container to the runtime container (e.g. a configuration file) use the `addToRunPrepare` attribute in the [build section](#build-pipeline-configuration). ```yaml zerops: # hostname of your service - setup: app # ==== how to build your application ==== build: ... addToRunPrepare: ./runtime-config.yaml # ==== how to run your application ==== run: # OPTIONAL. Customise the runtime environment by installing additional packages # or tools to the base Alpine runtime environment. prepareCommands: - sudo apk add --no-cache something - curl something else ... ``` In the example above Zerops will copy the `runtime-config.yaml` file from your build container **after the build has finished** into the new **prepare runtime** container. The copied files and folders will be available in the `/home/zerops` folder in the new prepare runtime container before the prepare commands are triggered. ### initCommands _OPTIONAL._ Defines one or more commands to be run each time a new runtime container is started or a container is restarted. ```yaml zerops: # hostname of your service - setup: app # ==== how to build your application ==== build: ... # ==== how to run your application ==== run: # OPTIONAL. Run one or more commands each time a new runtime container # is started or restarted. These commands are triggered before # your Alpine application is started. initCommands: - rm -rf ./cache ``` These commands are triggered in the runtime container before your Alpine application is started via the [start command](#start). :::note `run.initCommands` run in the `/var/www` directory. ::: Use init commands to clean or initialise your application cache or similar operations. :::caution The init commands will delay the start of your application each time a new runtime container is started (including the horizontal [scaling](/alpine/how-to/scaling) or when a runtime container is restarted). Do not use the init commands for customising your runtime environment. Use the [run:prepareCommands](#preparecommands-1) attribute instead. ::: #### Command exit code If any of the `initCommands` fails, it returns an exit code other than 0, but deploy is **not** canceled. After all init commands are finished, regardless of the status code, the application is started. Read the [runtime log](/alpine/how-to/logs#runtime-log) to troubleshoot the error. #### Single or separated shell instances You can configure your `initCommands` to be run in a single shell instance or multiple shell instances. The format is identical to [build commands](#buildcommands). ### envVariables _OPTIONAL._ Defines the environment variables for the runtime environment. Enter one or more env variables in following format: ```yaml zerops: # define hostname of your service - setup: app # ==== how to run your application ==== run: # OPTIONAL. Defines the env variables for the runtime environment: envVariables: MODE: production DB_NAME: db DB_HOST: db DB_USER: db DB_PASS: ${db_password} ``` Read more about [environment variables](/alpine/how-to/env-variables) in Zerops. ### start _OPTIONAL._ Defines the start command for your Alpine application. ```yaml zerops: # hostname of your service - setup: app # ==== how to build your application ==== build: ... # ==== how to run your application ==== run: # OPTIONAL. Your Alpine application start command start: ./app ``` ### health check _OPTIONAL._ Defines a health check. `healthCheck` requires either one `httpGet` object or one `exec` object. #### httpGet Configures the health check to request a local URL using a HTTP GET method. Following attributes are available:
Parameter Description
port Defines the port of the HTTP GET request. The readiness check will trigger a GET request on {'http://127.0.0.1:{port}/{path}'}
path Defines the URL path of the HTTP GET request. The readiness check will trigger a GET request on {'http://127.0.0.1:{port}/{path}'}
host Optional. The readiness check is triggered from inside of your runtime container so it always uses the localhost 127.0.0.1. If you need to add a host to the request header, specify it in the host attribute.
scheme Optional. The readiness check is triggered from inside of your runtime container so no https is required. If your application requires a https request, set scheme: https
**Example:** ```yaml zerops: # hostname of your service - setup: app # ==== how to build your application ==== build: ... # ==== how to run your application ==== run: # OPTIONAL. Your Alpine application start command start: ./app # OPTIONAL. Define a health check with a HTTP GET request option. # Configures the check on http://127.0.0.1:80/status healthCheck: httpGet: port: 80 path: /status ``` #### exec Configures the health check to run a local command. Following attributes are available:
Parameter Description
command Defines a local command to be run. The command has access to the same [environment variables](/alpine/how-to/create#set-secret-environment-variables) as your Alpine application. A single string is required. If you need to run multiple commands create a shell script or, use a multiline format as in the example below.
**Example:** ```yaml zerops: # hostname of your service - setup: app # ==== how to build your application ==== build: ... # ==== how to run your application ==== run: # REQUIRED. Your Alpine application start command start: ./app # OPTIONAL. Define a health check with a shell command. healthCheck: exec: command: | touch grass rm -rf life mv /outside/user /home/user ``` ### crontab _OPTIONAL._ Defines cron jobs. Setup cron jobs in the following format: ```yaml zerops: # define hostname of your service - setup: app # ==== how to run your application ==== run: crontab: # REQUIRED. Sets the command to execute: - command: "" # REQUIRED. Sets the interval time to execute: timing: "0 * * * *" ``` Read more about setting up [cron](/zerops-yaml/cron) in Zerops. ## Deploy configuration ### readiness check _OPTIONAL._ Defines a readiness check. Read more about how the [readiness check works](/alpine/how-to/deploy-process#readiness-checks) in Zerops. `readinessCheck` requires either one `httpGet` object or one `exec` object. #### httpGet Configures the readiness check to request a local URL using a http GET method. Following attributes are available:
Parameter Description
port Defines the port of the HTTP GET request. The readiness check will trigger a GET request on {'http://127.0.0.1:{port}/{path}'}
path Defines the URL path of the HTTP GET request. The readiness check will trigger a GET request on {'http://127.0.0.1:{port}/{path}'}
host Optional. The readiness check is triggered from inside of your runtime container so it always uses the localhost 127.0.0.1. If you need to add a host to the request header, specify it in the host attribute.
scheme Optional. The readiness check is triggered from inside of your runtime container so no https is required. If your application requires a https request, set scheme: https
**Example:** ```yaml zerops: # hostname of your service - setup: app # ==== how to build your application ==== build: ... # ==== how to deploy your application ==== deploy: # OPTIONAL. Define a readiness check with a HTTP GET request option. # Configures the check on http://127.0.0.1:80/status readinessCheck: httpGet: port: 80 path: /status # ==== how to run your application ==== run: ... ``` Read more about how the [readiness check works](/alpine/how-to/deploy-process#readiness-checks) in Zerops. #### exec Configures the readiness check to run a local command. Following attributes are available:
Parameter Description
command Defines a local command to be run. The command has access to the same [environment variables](/alpine/how-to/create#set-secret-environment-variables) as your Alpine application. A single string is required. If you need to run multiple commands create a shell script or, use a multiline format as in the example below.
**Example:** ```yaml zerops: # hostname of your service - setup: app # ==== how to build your application ==== build: ... # ==== how to deploy your application ==== deploy: # OPTIONAL. Define a readiness check with a HTTP GET request option. # Configures the check on http://127.0.0.1:80/status readinessCheck: exec: command: | touch grass rm -rf life mv /outside/user /home/user ``` Read more about how the [readiness check works](/alpine/how-to/deploy-process#readiness-checks) in Zerops. ---------------------------------------- # Alpine > How To > Build Process ## Build process overview Zerops starts a temporary build container and performs the following actions: 1. **Installs the build environment** - Sets up base system and runtime 2. **Downloads your application source code** - From [GitHub ↗](https://www.github.com), [GitLab ↗](https://www.gitlab.com) or via [Zerops CLI](/references/cli) 3. **Optionally customizes the build environment** - Runs prepare commands if configured 4. **Runs the build commands** - Executes your build process 5. **Uploads the application artifact** - Stores build output to internal Zerops storage 6. **Caches selected files** - Preserves specified files for faster future builds The build container is automatically deleted after the build has finished or failed. ## Build configuration Configure your build process in your `zerops.yaml` file according to the pipeline guide. ## Build environment ### Default build environment The default build environment contains: - {data.alpine.default} - [zCLI](/references/cli), Zerops command line tool - ### Customize build environment To install additional packages or tools, add one or more to your `zerops.yaml`. :::info The application code is available in the `/build/source` folder in your build container before the prepare commands are triggered. This allows you to use any file from your application code in your prepare commands (e.g. a configuration file). ::: ### Build hardware resources All runtime services use the same hardware resources for build containers:
HW resource Minimum Maximum
CPU cores 1 5
RAM 8 GB 8 GB
Disk 1 GB 100 GB
Build containers start with minimum resources and scale vertically up to maximum capacity as needed. ### Build time limit The time limit for the whole build pipeline is **1 hour**. After 1 hour, Zerops will terminate the build pipeline and delete the build container. :::info Build container resources are not charged separately. Limited build time is included in your [project core plan](/company/pricing#project-core-plans), with additional build time available if needed. ::: ## Troubleshooting builds :::tip Advanced troubleshooting For complex build issues that require investigation, you can enable [debug mode](/features/debug-mode) to pause the build process at specific points and inspect the build container state interactively. ::: ### Build and prepare command failures If any or fails (returns non-zero exit code), the build is canceled. Check the to troubleshoot the error. ### Build cache issues If you encounter unexpected build behavior or dependency issues, the problem might be related to cached build data. While Zerops maintains the build cache to speed up deployments, sometimes you may need to start fresh. To invalidate the build cache: 1. Go to your service detail in Zerops GUI 2. Choose **Pipelines & CI/CD Settings** from the left menu 3. Click on the **Invalidate build cache** button This will force Zerops to run the next build clean, including all prepare commands. Learn more about [build cache behavior](/features/build-cache). ## More resources For more details about the build and deploy pipeline, including how to cancel builds and manage application versions, see the [general pipeline documentation](/features/pipeline). ## Next steps - Understand the - Learn how to - Explore ---------------------------------------- # Alpine > How To > Controls ---------------------------------------- # Alpine > How To > Create Zerops provides a Alpine runtime service with extensive build support. Alpine runtime is highly scalable and customisable to suit both development and production. ## Create Alpine service using Zerops GUI First, set up a project in Zerops GUI. Then go to the project dashboard page and choose **Add new service** in the left menu in the **Services** block. Then add a new Alpine service: [Video: /vids/services/golang.webm](/vids/services/golang.webm) ### Choose Alpine version Following Alpine versions are currently supported: :::info You can [change](/alpine/how-to/upgrade) the major version at any time later. ::: ### Set a hostname Enter a unique service identifier like "app","cache", "gui" etc. Duplicate services with the same name in the same project are forbidden. #### Limitations: - maximum 25 characters - must contain only lowercase ASCII letters (a-z) or numbers (0-9) :::caution The hostname is fixed after the service is created. It can't be changed later. ::: ### Set secret environment variables Add environment variables with sensitive data, such as password, tokens, salts, certificates etc. These will be securely saved inside Zerops and added to your runtime service upon start. Setting the secret environment variables is optional. You can set them later in Zerops GUI. Read more about [different types of env variables](/alpine/how-to/env-variables#service-env-variables) in Zerops. ## Create Alpine service using zCLI zCLI is the Zerops command-line tool. To create a new Alpine service via the command-line, follow these steps: 1. [Install & setup zCLI](/references/cli) 2. [Create a project description file](/alpine/how-to/create#create-a-project-description-file) 3. [Create a project with a Alpine and PostgreSQL service](#full-example) ### Create a project description file Zerops uses a yaml format to describe the project infrastructure. #### Basic example: Create a directory `my-project`. Create an `description.yaml` file inside the `my-project` directory with following content: ```yaml # basic project data project: # project name name: my-project # array of project services services: - # service name hostname: app # service type and version number in alpine@{version} format type: alpine@3.20 # defines the minimum number of containers for horizontal autoscaling minContainers: 1 # defines the maximum number of containers for horizontal autoscaling. Max value = 6. maxContainers: 6 # optional: create env variables envSecrets: S3_ACCESS_KEY_ID: 'P8cX1vVVb' S3_ACCESS_SECRET: 'ogFthuiLYki8XoL73opSCQ' ``` The yaml file describes your future project infrastructure. The project will contain one Alpine service with default [auto scaling](/alpine/how-to/scaling) configuration. Hostname will be set to "app", the internal port(s) the service listens on will be defined later in the [zerops.yaml](/alpine/how-to/build-pipeline#ports). Following secret env variables will be configured: ```env S3_ACCESS_KEY_ID="P8cX1vVVb" S3_ACCESS_SECRET="ogFthuiLYki8XoL73opSCQ" ``` #### Full example: Create a directory my-project. Create an description.yaml file inside the my-project directory with following content: ```yaml # basic project data project: # project name name: my-project # optional: project description description: A project with a Alpine and PostgreSQL database # optional: project tags tags: - DEMO - ZEROPS # array of project services services: - # service name hostname: app # service type and version number in alpine@{version} format type: alpine@3.20 # optional: vertical auto scaling customization verticalAutoscaling: cpuMode: DEDICATED minCpu: 2 maxCpu: 5 minRam: 2 maxRam: 24 minDisk: 6 maxDisk: 50 startCpuCoreCount: 3 minFreeRamGB: 0.5 minFreeRamPercent: 20 # defines the minimum number of containers for horizontal autoscaling. Max value = 6. minContainers: 2 # defines the maximum number of containers for horizontal autoscaling. Max value = 6. maxContainers: 4 # optional: create secret env variables envSecrets: S3_ACCESS_KEY_ID: 'P8cX1vVVb' S3_ACCESS_SECRET: 'ogFthuiLYki8XoL73opSCQ' - # second service hostname hostname: db # service type and version number in postgresql@{version} format type: postgresql@12 # mode of operation "HA"/"non_HA" mode: NON_HA ``` The yaml file describes your future project infrastructure. The project will contain an Alpine service and a [PostgreSQL](/postgresql/overview) service. Alpine service with "app" hostname, the internal port(s) the service listens on will be defined later in the zerops.yaml. Alpine service will run with a custom vertical and horizontal scaling. Following secret env variables will be configured: ```env S3_ACCESS_KEY_ID="P8cX1vVVb" S3_ACCESS_SECRET="ogFthuiLYki8XoL73opSCQ" ``` The hostname of the PostgreSQL service will be set to "db". The [single container](/features/scaling#single-container-mode)(/features/scaling#deployment-modes-databases-and-shared-storage) mode will be chosen and the default auto [scaling configuration](/postgresql/how-to/scale#configure-scaling) will be set. #### Description of description.yaml parameters The `project:` section is required. Only one project can be defined.
Parameter Description
hostname The unique service identifier. The hostname of the new database will be set to the `hostname` value. Limitations:
  • duplicate services with the same name in the same project are forbidden
  • maximum 25 characters
  • must contain only lowercase ASCII letters (a-z) or numbers (0-9)
type Specifies the service type and version. See what [Alpine service types](/references/import-yaml/type-list#runtime-services) are currently supported.
verticalAutoscaling Optional. Defines [custom vertical auto scaling parameters](/alpine/how-to/create#set-auto-scaling-configuration). All verticalAutoscaling attributes are optional. Not specified attributes will be set to their default values.
- cpuMode Optional. Accepts `SHARED`, `DEDICATED` values. Default is `SHARED`
- minCpu/maxCpu Optional. Set the minCpu or maxCpu in CPU cores (integer).
- minRam/maxRam Optional. Set the minRam or maxRam in GB (float).
- minDisk/maxDisk Optional. Set the minDisk or maxDisk in GB (float).
minContainers Optional. Default = 1. Defines the minimum number of containers for [horizontal autoscaling](/alpine/how-to/create#horizontal-auto-scaling). Limitations: Current maximum value = 10.
maxContainers Defines the maximum number of containers for [horizontal autoscaling](/alpine/how-to/create#horizontal-auto-scaling). Limitations: Current maximum value = 10.
envSecrets Optional. Defines one or more secret env variables as a key value map. See env variable [restrictions](/alpine/how-to/env-variables#env-variable-restrictions).
### Create a project based on the description.yaml When you have your `description.yaml` ready, use the `zcli project project-import` command to create a new project and the service infrastructure. ```sh Usage: zcli project project-import importYamlPath [flags] Flags: -h, --help Help for the project import command. --org-id string If you have access to more than one organization, you must specify the org ID for which the project is to be created. --working-dir string Sets a custom working directory. Default working directory is the current directory. (default "./") ``` Zerops will create a project and one or more services based on the `description.yaml` content. Maximum size of the `description.yaml` file is 100 kB. You don't specify the project name in the `zcli project project-import` command, because the project name is defined in the `description.yaml`. If you have access to more than one client, you must specify the client ID for which the project is to be created. The `clientID` is located in the Zerops GUI under the client name on the project dashboard page. ### Add Alpine service to an existing project #### Example: Create a directory `my-project` if it doesn't exist. Create an `import.yaml` file inside the `my-project` directory with following content: ```yaml # basic project data project: # project name name: my-project # array of project services services: - # service name hostname: app # service type and version number in alpine@{version} format type: alpine@3.20 # defines the minimum number of containers for horizontal autoscaling minContainers: 1 # defines the maximum number of containers for horizontal autoscaling. Max value = 6. maxContainers: 6 # optional: create env variables envSecrets: S3_ACCESS_KEY_ID: 'P8cX1vVVb' S3_ACCESS_SECRET: 'ogFthuiLYki8XoL73opSCQ' ``` The yaml file describes the list of one or more services that you want to add to your existing project. In the example above, one Alpine service version 1 with default [auto scaling](/alpine/how-to/scaling) configuration will be added to your project. Hostname of the new service will be set to `app`. Following secret env variables will be configured: ```env S3_ACCESS_KEY_ID="P8cX1vVVb" S3_ACCESS_SECRET="ogFthuiLYki8XoL73opSCQ" ``` The content of the `services:` section of `import.yaml` is identical to the project description file. The `import.yaml` never contains the `project:` section because the project already exists. When you have your `import.yaml` ready, use the `zcli project service-import` command to add one or more services to your existing Zerops project. ```sh Usage: zcli project service-import importYamlPath [flags] Flags: -h, --help Help for the project service import command. -P, --project-id string If you have access to more than one project, you must specify the project ID for which the command is to be executed. ``` zCLI commands are interactive, when you press enter after `zcli project service-import importYamlPath`, you will be given a list of your projects to choose from. Maximum size of the import.yaml file is 100 kB. ---------------------------------------- # Alpine > How To > Customize Runtime ## Build Custom Runtime Images Zerops allows you to build custom runtime images (CRI) when the default base runtime images don't meet your application's requirements. This is an optional phase in the [build and deploy pipeline](/features/pipeline#runtime-prepare-phase-optional). Alpine is a versatile base for running anything not explicitly offered as a dedicated Zerops runtime. You can install any packages and tools you need, treating it as a clean OS to customize however you want. It is also a great option when you need a specific version of a technology (like Go, Node.js, or PHP) that Zerops doesn't support by default—whether it's an older version for legacy projects or a newer release not yet available. ## Configuration ### Default Runtime Environment The default runtime environment contains: - {data.alpine.default} - [zCLI](/references/cli) - ### When You Need a Custom Runtime Image Since Alpine serves as a general-purpose base, you'll likely want to customize it for your specific use case. Common scenarios include: :::important You should not include your application code in the custom runtime image, as your built/packaged code is deployed automatically into fresh containers. ::: Here are examples of configuring custom runtime images in your `zerops.yml`: ### Basic Setup ### Using Build Files in Runtime Preparation For complete configuration details, see the [runtime prepare phase configuration guide](/features/pipeline#configuration). ## Process and Caching ### How Runtime Prepare Works The runtime prepare process follows the same steps for all runtimes. See [how runtime prepare works](/features/pipeline#how-it-works) for the complete process details. ### Caching Behavior Zerops caches custom runtime images to optimize deployment times. Learn about [custom runtime image caching](/features/pipeline#custom-runtime-image-caching) including when images are cached and reused. ### Build Management For information about managing builds and deployments, see [managing builds and deployments](/features/pipeline#manage-builds-and-deployments). :::warning Shared storage mounts are not available during the runtime prepare phase. ::: ## Troubleshooting If your `prepareCommands` fail, check the for specific error messages. ---------------------------------------- # Alpine > How To > Deploy Process ---------------------------------------- # Alpine > How To > Env Variables ---------------------------------------- # Alpine > How To > Filebrowser ---------------------------------------- # Alpine > How To > Logs ---------------------------------------- # Alpine > How To > Scaling ---------------------------------------- # Alpine > How To > Shared Storage ---------------------------------------- # Alpine > How To > Trigger Pipeline ---------------------------------------- # Alpine > How To > Upgrade ---------------------------------------- # Alpine > Overview [Alpine Linux ↗](https://alpinelinux.org/) is a lightweight, security-oriented Linux distribution based on musl libc and busybox, known for its small footprint and efficiency. Alpine services in Zerops provide a minimal base environment for running applications built with technologies that aren't officially supported by Zerops, or for custom setups requiring full control over the runtime environment while keeping resource usage low. :::tip Do you have any questions? Check the step-by-step tutorial, browse the documentation and join our **[Discord](https://discord.com/invite/WDvCZ54)** community to get help from our team and other members. ::: ## Feature Highlights - [Create Alpine service](/alpine/how-to/create) — Start with creating an Alpine service using GUI or zCLI. - [zerops.yaml](/alpine/how-to/build-pipeline#add-zeropsyaml-to-your-repository) — See a full example of zerops.yaml file to configure your own app. - [Scaling configuration](/alpine/how-to/scaling) — Set up scaling of your Alpine service so that it runs smoothly while using only necessary resources. {" "} - [Customize build environment](/alpine/how-to/build-process#customize-build-environment) - [Customize runtime environment](/alpine/how-to/customize-runtime) ## When in doubt, reach out Don't know how to start or got stuck during the process? You might not be the first one, visit the FAQ section to find out. In case you haven't found an answer (and also if you have), we and our community are looking forward to hearing from you on Discord. Have you built something that others might find useful? Don't hesitate to share your knowledge! - [FAQ](/alpine/faq) — Most common questions in one place. - [Discord](https://discord.com/invite/WDvCZ54) — Join our core team and Zerops community on Discord. Ask questions and share your tips with other members. ## Popular Guides - [zCLI](/references/cli) — Get even more out of Zerops with the zCLI command line tool. - [Zerops VPN](/references/networking/vpn) — Connect to your services easily with Zerops VPN. ---------------------------------------- # Bun > How To > Build Pipeline Zerops provides a customizable build and runtime environment for your Bun application. ## Add zerops.yaml to your repository Start by adding `zerops.yaml` file to the **root of your repository** and modify it to fit your application: ```yaml zerops: # define hostname of your service - setup: app # ==== how to build your application ==== build: # REQUIRED. Set the base technology for the build environment: base: bun@latest # OPTIONAL. Set the operating system for the build environment. # os: ubuntu # OPTIONAL. Customise the build environment by installing additional packages # or tools to the base build environment. # prepareCommands: # - sudo apt-get something # - curl something else # OPTIONAL. Build your application buildCommands: - bun i - bun run build # REQUIRED. Select which files / folders to deploy after # the build has successfully finished deployFiles: - dist - package.json - node_modules # OPTIONAL. Which files / folders you want to cache for the next build. # Next builds will be faster when the cache is used. cache: node_modules # ==== how to run your application ==== run: # OPTIONAL. Sets the base technology for the runtime environment: base: bun@latest # OPTIONAL. Sets the internal port(s) your app listens on: ports: # port number - port: 3000 # OPTIONAL. Customise the runtime Bun environment by installing additional # dependencies to the base Bun runtime environment. # prepareCommands: # - sudo apt-get something # - curl something else # OPTIONAL. Run one or more commands each time a new runtime container # is started or restarted. These commands are triggered before # your Bun application is started. # initCommands: # - rm -rf ./cache # REQUIRED. Your Bun application start command start: bun start ``` The top-level element is always `zerops`. ### Setup The first element `setup` contains the **hostname** of your service. A runtime service with the same hostname must exist in Zerops. Zerops supports the definition of multiple runtime services in a single `zerops.yaml`. This is useful when you use a monorepo. Just add multiple setup elements in your `zerops.yaml`: ```yaml zerops: # definition for app service - setup: app # optional build: ... # optional deploy: ... # required run: ... # definition for api service - setup: api # optional build: ... # optional deploy: ... # required run: ... ``` Each service configuration contains at least the `run` section. Optional `build` and `deploy` sections can be added to further customize your process. ## Build pipeline configuration ### base _REQUIRED._ Sets the base technology for the build environment. Following options are available for Bun builds: - `bun@1.3.9`, `bun@1.3`, `bun@latest` - `bun@1.2.2`, `bun@1.2` - `bun@nightly` - `bun@canary` - `bun@1.1.34`, `bun@1.1(Ubuntu only)` ```yaml zerops: # hostname of your service - setup: app # ==== how to build your application ==== build: # REQUIRED. Sets the base technology for the build environment: base: bun@latest ... ```

The base build environment contains {data.alpine.default}, the selected major version of Bun, [Zerops command line tool](/references/cli), `npm`, `yarn`, `git` and `npx` tools.

:::info You can change the base environment when you need to. Just simply modify the `zerops.yaml` in your repository. ::: If you need to install more technologies to the build environment, set multiple values as a yaml array. For example: ```yaml zerops: # hostname of your service - setup: app # ==== how to build your application ==== build: # REQUIRED. Sets the base technology for the build environment: base: - bun@latest prepareCommands: - zsc add go@latest ... ``` See the full list of supported [build base environments](/zerops-yaml/base-list#runtime-services). To customise your build environment use the [prepareCommands](build-pipeline#preparecommands) attribute. :::note Modifying the base technology will invalidate your build cache. See our [Build Cache Documentation](/features/build-cache) for more details about cache invalidation. ::: ### os _OPTIONAL._ Sets the operating system for the build environment. Following options are available: - `alpine` - `ubuntu` Default value is `alpine`. We are currently using following os version: - {data.alpine.default} - {data.ubuntu.default} :::caution The os version is fixed and cannot be customised. ::: :::note Changing the OS setting will invalidate your build cache. See our [Build Cache Documentation](/features/build-cache) for details about cache behavior. ::: ### prepareCommands _OPTIONAL._ Customises the build environment by installing additional dependencies or tools to the base build environment. The base build environment contains: - {data.alpine.default} - selected version of Bun defined in the [base](build-pipeline#base) attribute - [Zerops command line tool](/references/cli) - `npm`, `yarn`, `git` and `npx` tools To install additional packages or tools add one or more prepare commands: ```yaml zerops: # hostname of your service - setup: app # ==== how to build your application ==== build: # REQUIRED. Set the base technology for the build environment: base: bun@latest # OPTIONAL. Customise the build environment by installing additional packages # or tools to the base build environment. prepareCommands: - sudo apt-get something - curl something else ... ``` When the first build is triggered, Zerops will 1. create a build container 2. download your application code from your repository 3. run the prepare commands in the defined order The application code is available in `/build/source` before the prepare commands are triggered, so you can use any file from your repository in your prepare commands (e.g. a configuration file). The commands themselves run in the `/home/zerops` directory. :::note These commands are skipped when using cached environment. Modifying `prepareCommands` will invalidate your build cache. See our [Build Cache Documentation](/features/build-cache) for details about cache invalidation. ::: #### Command exit code If any command fails, it returns an exit code other than 0 and the build is canceled. Read the [build log](logs#build-log) to troubleshoot the error. If the command ends successfully, it returns the exit code 0 and Zerops triggers the following command. When all prepare commands are finished, your custom build environment is ready for the build phase. #### Single or separated shell instances You can configure your prepare commands to be run in a single shell instance or multiple shell instances. The format is identical to [build commands](#buildcommands). ### buildCommands _OPTIONAL._ Defines build commands. ```yaml zerops: # hostname of your service - setup: app # ==== how to build your application ==== build: # REQUIRED. Set the base technology for the build environment: base: bun@latest # OPTIONAL. Build your application buildCommands: - bun i - bun run build ... ``` Build commands are optional. Zerops triggers each command in the defined order in a dedicated build container, running from the `/build/source` directory. Before the build commands are triggered the build container contains: 1. base environment defined by the [base](build-pipeline#base) attribute 2. optional customisation of the base environment defined in the [prepareCommands](build-pipeline#preparecommands) attribute 3. your application code #### Run build commands as a single shell instance Use following syntax to run all commands in the same environment context. For example, if one command changes the current directory, the next command continues in that directory. When one command creates an environment variable, the next command can access it. ```yaml buildCommands: - | bun i bun run build ``` #### Run build commands as a separate shell instances When the following syntax is used, each command is triggered in a separate environment context. For example, each shell instance starts in the home directory again. When one command creates an environment variable, it won't be available for the next command. ```yaml buildCommands: - bun i - bun run build ``` #### Command exit code If any command fails, it returns an exit code other than 0 and the build is canceled. Read the [build log](logs#build-log) to troubleshoot the error. If the error log doesn't contain any specific error message, try to run your build with the --verbose option. ```yaml buildCommands: - bun i --verbose - bun run build ``` If the command ends successfully, it returns the exit code 0 and Zerops triggers the following command. When all `buildCommands` are finished, the application build is completed and ready for the deploy phase. ### deployFiles _REQUIRED._ Selects which files or folders will be deployed after the build has successfully finished. To filter out specific files or folders, use [`.deployignore`](#deployignore) file. ```yaml # REQUIRED. Select which files / folders to deploy after # the build has successfully finished deployFiles: - dist - package.json - node_modules ``` Determines files or folders produced by your build, which should be deployed to your runtime service containers. The path starts from the **root directory** of your project (the location of `zerops.yaml`). You must enclose the name in quotes if the folder or the file name contains a space. 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`. #### Examples Deploys a folder, and a file from the project root directory: ```yaml deployFiles: - dist - package.json ``` Deploys the whole content of the build container: ```yaml deployFiles: . ``` Deploys a folder, and a file in a defined path: ```yaml deployFiles: - ./path/to/file.txt - ./path/to/dir/ ``` #### How to use a wildcard in the path 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/` ```yaml deployFiles: ./path/~/to/file.txt ``` Deploys all folders that are located in any path that begins with `/path/to/` ```yaml deployFiles: ./path/to/~/ ``` Deploys all folders that are located in any path that begins with `/path/` and ends with `/to/` ```yaml deployFiles: ./path/~/to/ ``` :::note Example 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`](https://git-scm.com/docs/gitignore#_pattern_format). 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: ```yaml title="zerops.yaml" zerops: - setup: app build: deployFiles: ./ ``` ```text title=".deployignore" /src/file.txt ``` The example above ignores `file.txt` only in the root src directory. ```text title=".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`](/references/zcli/commands#deploy) command. ::: ### cache _OPTIONAL._ Defines which files or folders will be cached for the next build. ```yaml # OPTIONAL. Which files / folders you want to cache for the next build. # Next builds will be faster when the cache is used. cache: file.txt ``` The cache attribute helps optimize build times by preserving specified files between builds. The cache attribute supports the [~ wildcard character](#how-to-use-a-wildcard-in-the-path). Learn more about the [build cache system](/features/build-cache) in Zerops. ### envVariables _OPTIONAL._ Defines the environment variables for the build environment. Enter one or more env variables in following format: ```yaml zerops: # define hostname of your service - setup: app # ==== how to build your application ==== build: base: bun@latest … # OPTIONAL. Defines the env variables for the build environment: envVariables: NODE_ENV: production DB_NAME: db DB_HOST: db DB_USER: db DB_PASS: ${db_password} ``` Read more about [environment variables](env-variables) in Zerops. ## Runtime configuration ### base _OPTIONAL._ Sets the base technology for the runtime environment. If you don't specify the `run.base` attribute, Zerops keeps the current Bun version for your runtime. Following options are available for Bun runtimes: - `bun@1.3.9`, `bun@1.3`, `bun@latest` - `bun@1.2.2`, `bun@1.2` - `bun@nightly` - `bun@canary` - `bun@1.1.34`, `bun@1.1(Ubuntu only)` ```yaml zerops: # hostname of your service - setup: app # ==== how to build your application ==== build: # REQUIRED. Sets the base technology for the build environment: base: bun@latest ... # ==== how to run your application ==== run: # OPTIONAL. Sets the base technology for the runtime environment: base: bun@latest ... ```

The base runtime environment contains {data.alpine.default}, the selected major version of Bun, Zerops command line tool, `npm`, `yarn`, `git` and `npx` tools.

:::info You can change the base environment when you need to. Just simply modify the `zerops.yaml` in your repository. ::: If you need to install more technologies to the runtime environment, set multiple values as a yaml array. For example: ```yaml zerops: # hostname of your service - setup: app # ==== how to build your application ==== build: # REQUIRED. Sets the base technology for the build environment: base: bun@latest ... # ==== how to run your application ==== run: # OPTIONAL. Sets the base technology for the runtime environment: base: - bun@latest prepareCommands: - zsc add go@latest ... ``` See the full list of supported [run base environments](/zerops-yaml/base-list). To customise your build environment use the `prepareCommands` attribute. ### os _OPTIONAL._ Sets the operating system for the runtime environment. Following options are available: - `alpine` - `ubuntu` Default value is `alpine`. We are currently using following os version: - {data.alpine.default} - {data.ubuntu.default} :::caution The os version is fixed and cannot be customised. ::: ### ports _OPTIONAL._ Specifies one or more internal ports on which your application will listen. Projects in Zerops represent a group of one or more services. Services can be of different types (runtime services, databases, message brokers, object storage, etc.). All services of the same project share a **dedicated private network**. To connect to a service within the same project, just use the service hostname and its internal port. For example, to connect to a Bun service with hostname = "app" and port = 3000 from another service of the same project, simply use `app:3000`. Read more about [how to access a Bun service](/features/access). Each port has following attributes: | parameter | description | | ----------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | port | Defines the port number. You can set any port number between _10_ and _65435_. Ports outside this interval are reserved for internal Zerops systems. | | protocol | **Optional.** Defines the protocol. Allowed values are `TCP` or `UDP`. Default value is `TCP`. | | httpSupport | **Optional.** `httpSupport = true` is the default setting for TCP protocol. Set `httpSupport = false` if a web server isn't running on the port. Zerops uses this information for the configuration of [public access](/features/access). `httpSupport = true` is available only in combination with the TCP protocol. | | httpSupport | **Optional.** `httpSupport = true` is the default setting for TCP protocol. Set `httpSupport = false` if a web server isn't running on the port. Zerops uses this information for the configuration of [public access](/features/access). `httpSupport = true` is available only in combination with the TCP protocol. | ### prepareCommands _OPTIONAL._ Customises the Bun runtime environment by installing additional dependencies or tools to the runtime base environment.

The base Bun environment contains {data.alpine.default} the selected major version of Bun, [Zerops command line tool](/references/cli) and `npm`, `yarn`, `git` and `npx` tools. To install additional packages or tools add one or more prepare commands:

```yaml zerops: # hostname of your service - setup: app # ==== how to build your application ==== build: ... # ==== how to run your application ==== run: # OPTIONAL. Customise the runtime environment by installing additional packages # or tools to the base Bun runtime environment. prepareCommands: - sudo apt-get something - curl something else ... ``` When the first deploy with a defined prepare attribute is triggered, Zerops will 1. create a prepare runtime container 2. optionally: [copy selected folders or files from your build container](build-pipeline#copy-folders-or-files-from-your-build-container) 3. run the `prepareCommands` commands in the defined order :::note `run.prepareCommands` run in the `/home/zerops` directory. ::: #### Command exit code If any command fails, it returns an exit code other than 0 and the deploy is canceled. Read the [prepare runtime log](logs#prepare-runtime-log) to troubleshoot the error. If the command ends successfully, it returns the exit code 0 and Zerops triggers the following command. When all `prepareCommands` commands are finished, your custom runtime environment is ready for the deploy phase. #### Cache of your custom runtime environment Some packages or tools can take a long time to install. Therefore, Zerops caches your custom runtime environment after the installation of your custom packages or tools is completed. When the second or following deploy is triggered, Zerops will use the custom runtime cache from the previous deploy if following conditions are met: 1. Content of the [build.addToRunPrepare](#copy-folders-or-files-from-your-build-container) and `run.prepareCommands` attributes didn't change from the previous deploy 2. The custom runtime cache wasn't invalidated in the Zerops GUI. To invalidate the custom runtime cache go to `yyy` When the custom runtime cache is used, Zerops doesn't create a prepare runtime container and executes the deployment of your application directly. #### Single or separated shell instances You can configure your prepare commands to be run in a single shell instance or multiple shell instances. The format is identical to [build commands](#buildcommands). ### Copy folders or files from your build container

The prepare runtime container contains {data.alpine.default}, the selected major version of Bun, [Zerops command line tool](/references/cli) and `npm`, `yarn`, `git` and `npx` tools.

The prepare runtime container does not contain your application code nor the built application. If you need to copy some folders or files from the build container to the runtime container (e.g. a configuration file) use the `addToRunPrepare` attribute in the [build section](#build-pipeline-configuration). ```yaml zerops: # hostname of your service - setup: app # ==== how to build your application ==== build: ... addToRunPrepare: ./runtime-config.yaml # ==== how to run your application ==== run: # OPTIONAL. Customise the runtime environment by installing additional packages # or tools to the base Bun runtime environment. prepareCommands: - sudo apt-get something - curl something else ... ``` In the example above Zerops will copy the `runtime-config.yaml` file from your build container **after the build has finished** into the new **prepare runtime** container. The copied files and folders will be available in the `/home/zerops` folder in the new prepare runtime container before the prepare commands are triggered. ### initCommands _OPTIONAL._ Defines one or more commands to be run each time a new runtime container is started or a container is restarted. ```yaml zerops: # hostname of your service - setup: app # ==== how to build your application ==== build: ... # ==== how to run your application ==== run: # OPTIONAL. Run one or more commands each time a new runtime container # is started or restarted. These commands are triggered before # your Bun application is started. initCommands: - rm -rf ./cache ``` These commands are triggered in the runtime container before your Bun application is started via the [start command](build-pipeline#start). :::note `run.initCommands` run in the `/var/www` directory. ::: Use init commands to clean or initialise your application cache or similar operations. :::caution The init commands will delay the start of your application each time a new runtime container is started (including the [horizontal scaling](scaling) or when a runtime container is restarted). Do not use the init commands for customising your runtime environment. Use the [run:prepareCommands](build-pipeline#preparecommands-1) attribute instead. ::: #### Command exit code If any of the `initCommands` fails, it returns an exit code other than 0, but deploy is **not** canceled. After all init commands are finished, regardless of the status code, the application is started. Read the [runtime log](logs#runtime-log) to troubleshoot the error. #### Single or separated shell instances You can configure your `initCommands` to be run in a single shell instance or multiple shell instances. The format is identical to [build commands](#buildcommands). ### envVariables _OPTIONAL._ Defines the environment variables for the runtime environment. Enter one or more env variables in following format: ```yaml zerops: # define hostname of your service - setup: app # ==== how to run your application ==== run: # OPTIONAL. Defines the env variables for the runtime environment: envVariables: NODE_ENV: production DB_NAME: db DB_HOST: db DB_USER: db DB_PASS: ${db_password} ``` Read more about [environment variables](env-variables) in Zerops. ### start _REQUIRED._ Defines the start command for your Bun application. ```yaml zerops: # hostname of your service - setup: app # ==== how to build your application ==== build: ... # ==== how to run your application ==== run: # REQUIRED. Your Bun application start command start: bun start ``` We recommend starting your Bun application using `bun start`. ### health check _OPTIONAL._ Defines a health check. `healthCheck` requires either one `httpGet` object or one `exec` object. #### httpGet Configures the health check to request a local URL using a HTTP GET method. Following attributes are available:
Parameter Description
port Defines the port of the HTTP GET request. The readiness check will trigger a GET request on {'http://127.0.0.1:{port}/{path}'}
path Defines the URL path of the HTTP GET request. The readiness check will trigger a GET request on {'http://127.0.0.1:{port}/{path}'}
host Optional. The readiness check is triggered from inside of your runtime container so it always uses the localhost 127.0.0.1. If you need to add a host to the request header, specify it in the host attribute.
scheme Optional. The readiness check is triggered from inside of your runtime container so no https is required. If your application requires a https request, set scheme: https
**Example:** ```yaml zerops: # hostname of your service - setup: app # ==== how to build your application ==== build: ... # ==== how to run your application ==== run: # REQUIRED. Your Bun application start command start: bun start # OPTIONAL. Define a health check with a HTTP GET request option. # Configures the check on http://127.0.0.1:80/status healthCheck: httpGet: port: 80 path: /status ``` #### exec Configures the health check to run a local command. Following attributes are available: | Parameter | Description | | ----------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | **command** | Defines a local command to be run. The command has access to the same [environment variables](create#set-secret-environment-variables) as your Bun application. A single string is required. If you need to run multiple commands create a shell script or, use a multiline format as in the example below. | **Example:** ```yaml zerops: # hostname of your service - setup: app # ==== how to build your application ==== build: ... # ==== how to run your application ==== run: # REQUIRED. Your Bun application start command start: bun start # OPTIONAL. Define a health check with a shell command. healthCheck: exec: command: | touch grass rm -rf life mv /outside/user /home/user ``` ### crontab _OPTIONAL._ Defines cron jobs. Setup cron jobs in the following format: ```yaml zerops: # define hostname of your service - setup: app # ==== how to run your application ==== run: crontab: # REQUIRED. Sets the command to execute: - command: "" # REQUIRED. Sets the interval time to execute: timing: "0 * * * *" ``` Read more about setting up [cron](/zerops-yaml/cron) in Zerops. ## Deploy configuration ### readiness check _OPTIONAL._ Defines a readiness check. Read more about how the [readiness check works](deploy-process#readiness-checks) in Zerops. `readinessCheck` requires either one `httpGet` object or one `exec` object. #### httpGet Configures the readiness check to request a local URL using a http GET method. Following attributes are available:
Parameter Description
port Defines the port of the HTTP GET request. The readiness check will trigger a GET request on {'http://127.0.0.1:{port}/{path}'}
path Defines the URL path of the HTTP GET request. The readiness check will trigger a GET request on {'http://127.0.0.1:{port}/{path}'}
host Optional. The readiness check is triggered from inside of your runtime container so it always uses the localhost 127.0.0.1. If you need to add a host to the request header, specify it in the host attribute.
scheme Optional. The readiness check is triggered from inside of your runtime container so no https is required. If your application requires a https request, set scheme: https
**Example:** ```yaml zerops: # hostname of your service - setup: app # ==== how to build your application ==== build: ... # ==== how to deploy your application ==== deploy: # OPTIONAL. Define a readiness check with a HTTP GET request option. # Configures the check on http://127.0.0.1:80/status readinessCheck: httpGet: port: 80 path: /status # ==== how to run your application ==== run: ... ``` Read more about how the [readiness check works](deploy-process#readiness-checks) in Zerops. #### exec Configures the readiness check to run a local command. Following attributes are available: | Parameter | Description | | ----------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | **command** | Defines a local command to be run. The command has access to the same [environment variables](create#set-secret-environment-variables) as your Bun application. A single string is required. If you need to run multiple commands create a shell script or, use a multiline format as in the example below. | **Example:** ```yaml zerops: # hostname of your service - setup: app # ==== how to build your application ==== build: ... # ==== how to deploy your application ==== deploy: # OPTIONAL. Define a readiness check with a HTTP GET request option. # Configures the check on http://127.0.0.1:80/status readinessCheck: exec: command: | touch grass rm -rf life mv /outside/user /home/user ``` Read more about how the [readiness check works](deploy-process#readiness-checks) in Zerops. ---------------------------------------- # Bun > How To > Build Process ---------------------------------------- # Bun > How To > Controls ---------------------------------------- # Bun > How To > Create Zerops provides a powerful Bun runtime service with extensive build support. The Bun runtime is highly scalable and customizable to suit your development and production needs. With just a few clicks or commands, you can have a production-ready Bun environment up and running in no time. ## Create a Bun service using Zerops GUI First, set up a project in the Zerops GUI. Then go to the project dashboard page and choose **Add new service** in the left menu under the **Services** section. From there, you can add a new Bun service: [Video: /vids/services/bun.webm](/vids/services/bun.webm) ### Choose a Bun version Zerops supports the following Bun versions: :::info You can easily [upgrade](upgrade) the major version at any time later. ::: ### Set a hostname Enter a unique service identifier like "app", "cache", "gui", etc. Duplicate services with the same name within the same project are not allowed. #### Limitations: - Maximum 25 characters - Must contain only lowercase ASCII letters (a-z) or numbers (0-9) :::caution The hostname is fixed after the service is created and cannot be changed later. ::: ### Set secret environment variables Add environment variables with sensitive data, such as passwords, tokens, salts, certificates, etc. These will be securely saved inside Zerops and added to your runtime service upon start. Setting secret environment variables is optional. You can always set them later in the Zerops GUI. Read more about the [different types of environment variables](env-variables#service-env-variables) in Zerops. ## Create a Bun service using zCLI zCLI is the Zerops command-line tool. To create a new Bun service via the command line, follow these steps: 1. [Install & setup zCLI](/references/cli) 2. [Create a project description file](create#create-a-project-description-file) 3. [Create a project with a Bun and PostgreSQL service](#full-example) ### Create a project description file Zerops uses a YAML format to describe the project infrastructure. #### Basic example: Create a directory called `my-project`. Inside the `my-project` directory, create a `description.yaml` file with the following content: ```yaml # basic project data project: # project name name: my-project # array of project services services: - # service name hostname: app # service type and version number in Bun@{version} format type: bun@latest # defines the minimum number of containers for horizontal autoscaling minContainers: 1 # defines the maximum number of containers for horizontal autoscaling. Max value = 6. maxContainers: 6 # optional: create env variables envSecrets: S3_ACCESS_KEY_ID: 'P8cX1vVVb' S3_ACCESS_SECRET: 'ogFthuiLYki8XoL73opSCQ' ``` The yaml file describes your future project infrastructure. The project will contain one Bun service with default [auto scaling](scaling) configuration. Hostname will be set to "app", the internal port(s) the service listens on will be defined later in the [zerops.yaml](build-pipeline#ports). Following secret env variables will be configured: ```env S3_ACCESS_KEY_ID="P8cX1vVVb" S3_ACCESS_SECRET="ogFthuiLYki8XoL73opSCQ" ``` #### Full example: Create a directory my-project. Create an description.yaml file inside the my-project directory with following content: ```yaml # basic project data project: # project name name: my-project # optional: project description description: A project with a Bun and PostgreSQL database # optional: project tags tags: - DEMO - ZEROPS # array of project services services: - # service name hostname: app # service type and version number in Bun@{version} format type: bun@latest # optional: vertical auto scaling customization verticalAutoscaling: cpuMode: DEDICATED minCpu: 2 maxCpu: 5 minRam: 2 maxRam: 24 minDisk: 6 maxDisk: 50 startCpuCoreCount: 3 minFreeRamGB: 0.5 minFreeRamPercent: 20 # defines the minimum number of containers for horizontal autoscaling. Max value = 6. minContainers: 2 # defines the maximum number of containers for horizontal autoscaling. Max value = 6. maxContainers: 4 # optional: create env variables envSecrets: S3_ACCESS_KEY_ID: 'P8cX1vVVb' S3_ACCESS_SECRET: 'ogFthuiLYki8XoL73opSCQ' - # second service hostname hostname: db # service type and version number in postgresql@{version} format type: postgresql@12 # mode of operation "HA"/"non_HA" mode: NON_HA ``` The yaml file describes your future project infrastructure. The project will contain a Bun service and a [PostgreSQL](/postgresql/overview) service. Bun service with "app" hostname, the internal port(s) the service listens on will be defined later in the [zerops.yaml](build-pipeline#ports). Bun service will run with custom vertical and horizontal scaling. Following secret env variables will be configured: ```env S3_ACCESS_KEY_ID="P8cX1vVVb" S3_ACCESS_SECRET="ogFthuiLYki8XoL73opSCQ" ``` The hostname of the PostgreSQL service will be set to "db". The [single container](/features/scaling#single-container-mode)(/features/scaling#deployment-modes-databases-and-shared-storage) mode will be chosen and the default auto [scaling configuration](/postgresql/how-to/scale#configure-scaling) will be set. #### Description of description.yaml parameters The `project:` section is required. Only one project can be defined. | Parameter | Description | Limitations | | --------------- | ------------------------------------------------------------------------------------------------------------------------------- | ----------------------- | | **name** | The name of the new project. Duplicates are allowed. | | | **description** | **Optional.** Description of the new project. | Maximum 255 characters. | | **tags** | **Optional.** One or more string tags. Tags do not have a functional meaning, they only provide better orientation in projects. | | **tags** | **Optional.** One or more string tags. Tags do not have a functional meaning, they only provide better orientation in projects. | At least one service in `services:` section is required. You can create a project with multiple services. The example above contains Bun and PostgreSQL services but you can create a `description.yaml` with your own combination of [services](/features/infrastructure).
Parameter Description
hostname The unique service identifier.
  • duplicate services with the same name in the same project are forbidden
  • maximum 25 characters
  • must contain only lowercase ASCII letters (a-z) or numbers (0-9)
type Specifies the service type and version. See what [Bun service types](/references/import-yaml/type-list#runtime-services) are currently supported.
verticalAutoscaling Optional. Defines [custom vertical auto scaling parameters](/bun/how-to/scaling#configure-scaling). All verticalAutoscaling attributes are optional. Not specified attributes will be set to their default values.
- cpuMode Optional. Accepts `SHARED`, `DEDICATED` values. Default is `SHARED`
- minCpu/maxCpu Optional. Set the minCpu or maxCpu in CPU cores (integer).
- minRam/maxRam Optional. Set the minRam or maxRam in GB (float).
- minDisk/maxDisk Optional. Set the minDisk or maxDisk in GB (float).
minContainers Optional. Default = 1. Defines the minimum number of containers for [horizontal autoscaling](/bun/how-to/scaling#configure-scaling). Limitations: Current maximum value = 10.
maxContainers Defines the maximum number of containers for [horizontal autoscaling](/bun/how-to/scaling#configure-scaling). Limitations: Current maximum value = 10.
envSecrets Optional. Defines one or more secret env variables as a key value map. See env variable [restrictions](env-variables#env-variable-restrictions).
### Create a project based on the description.yaml When you have your `description.yaml` ready, use the `zcli project project-import` command to create a new project and the service infrastructure. ```sh Usage: zcli project project-import importYamlPath [flags] Flags: -h, --help Help for the project import command. --org-id string If you have access to more than one organization, you must specify the org ID for which the project is to be created. --working-dir string Sets a custom working directory. Default working directory is the current directory. (default "./") ``` Zerops will create a project and one or more services based on the `description.yaml` content. Maximum size of the `description.yaml` file is 100 kB. You don't specify the project name in the `zcli project project-import` command, because the project name is defined in the `description.yaml`. If you have access to more than one client, you must specify the client ID for which the project is to be created. The `clientID` is located in the Zerops GUI under the client name on the project dashboard page. ### Add Bun service to an existing project #### Example: Create a directory `my-project` if it doesn't exist. Create an `import.yaml` file inside the `my-project` directory with following content: ```yaml # basic project data project: # project name name: my-project # array of project services services: - # service name hostname: app # service type and version number in Bun@{version} format type: bun@latest # defines the minimum number of containers for horizontal autoscaling minContainers: 1 # defines the maximum number of containers for horizontal autoscaling. Max value = 6. maxContainers: 6 # optional: create env variables envSecrets: S3_ACCESS_KEY_ID: 'P8cX1vVVb' S3_ACCESS_SECRET: 'ogFthuiLYki8XoL73opSCQ' ``` The yaml file describes the list of one or more services that you want to add to your existing project. In the example above, one Bun service with default [auto scaling](scaling) configuration will be added to your project. Hostname of the new service will be set to `app`. Following secret env variables will be configured: ```env S3_ACCESS_KEY_ID="P8cX1vVVb" S3_ACCESS_SECRET="ogFthuiLYki8XoL73opSCQ" ``` The content of the `services:` section of `import.yaml` is identical to the project description file. The `import.yaml` never contains the `project:` section because the project already exists. When you have your `import.yaml` ready, use the `zcli project service-import` command to add one or more services to your existing Zerops project. ```sh Usage: zcli project service-import importYamlPath [flags] Flags: -h, --help Help for the project service import command. -P, --project-id string If you have access to more than one project, you must specify the project ID for which the command is to be executed. ``` zCLI commands are interactive, when you press enter after `zcli project service-import importYamlPath`, you will be given a list of your projects to choose from. Maximum size of the import.yaml file is 100 kB. ---------------------------------------- # Bun > How To > Customize Runtime ---------------------------------------- # Bun > How To > Deploy Process ---------------------------------------- # Bun > How To > Env Variables ---------------------------------------- # Bun > How To > Filebrowser ---------------------------------------- # Bun > How To > Logs ---------------------------------------- # Bun > How To > Scaling ---------------------------------------- # Bun > How To > Shared Storage ---------------------------------------- # Bun > How To > Trigger Pipeline ---------------------------------------- # Bun > How To > Upgrade ---------------------------------------- # Bun > Overview [Bun ↗](https:/bun.org/en) is an asynchronous event-driven JavaScript runtime, which is designed to build scalable network applications. As said, there is no need for coding yet, we have created a [Github repository ↗](https://github.com/zeropsio/recipe-bun), a **_recipe_**, containing the most simple Bun web application. The repo will be used as a source from which the app will be built. ### 🚀 Feel free to deploy the recipe yourself This is the most bare-bones example of Bun app running in Zerops — as few libraries as possible, just a simple endpoint with connect, read and write to a Zerops PostgreSQL database. [Deploy "bun" recipe on Zerops](https://app.zerops.io/recipe/?lf=bun) 1. Log in/sign up to [Zerops GUI ↗](https://app.zerops.io) 2. In the **Projects** box click on **Import a project** and paste in the following YAML config ([source ↗](https://github.com/zeropsio/recipe-bun/blob/main/zerops-project-import.yaml)): ```yaml project: name: recipe-bun tags: - zerops-recipe services: - hostname: api type: bun@1.1 enableSubdomainAccess: true buildFromGit: https://github.com/zeropsio/recipe-bun - hostname: db type: postgresql@16 mode: NON_HA priority: 1 ``` 3. Click on **Import project** and wait until all pipelines have finished. **That's it, your application is now up and running! :star: Let's check it works:** 1. A _subdomain_ should have been enabled and visible in the project's **IP addressed & Public Routing Overview** box. Its format should look similar to this `https://api-806-3000.prg1.zerops.app`. 2. Click or the `subdomain` URL to open it in a browser and you should see ``` {"message":"This is a simple, basic Bun application running in Zerops.io,\n each request adds an entry to the PostgreSQL database and returns a count.\n See the source repository (https://github.com/zeropsio/recipe-bun) for more information.","newEntry":"dfd1e873-bfc8-4f36-af07-e32561820b93","count":"1"} ``` :::tip Do you have any questions? Check the step-by-step tutorial, browse the documentation and join our **[Discord](https://discord.com/invite/WDvCZ54)** community to get help from our team and other members. ::: ## How to start It doesn't matter whether it's your first curious introduction to Zerops, you have already mastered the basics and are looking for a tiny detail or inspiration. Below, choose a section that fits your needs: - [Care for details?](/bun/how-to/create) — Dive in all Zerops has to offer for your Bun application. - [Bun recipes](https://github.com/zeropsio?q=Bun&type=all&language=&sort=) — Get inspired by already existing repositories, ready to be imported to Zerops. ## Feature Highlights - [Create Bun service](/bun/how-to/create) — Start with creating a Bun service using GUI or zCLI. - [Zerops.yaml](/bun/how-to/build-pipeline#add-zeropsyaml-to-your-repository) — See a full example of zerops.yaml file to create your own app. - [Scaling configuration](/bun/how-to/scaling) — Set up scaling of your Bun application so that it runs smoothly while using only necessary resources. {" "} - [Customize build environment](/bun/how-to/build-process#customize-build-environment) - [Customize runtime environment](/bun/how-to/customize-runtime) ## When in doubt, reach out Don't know how to start or got stuck during the process? You might not be the first one, visit the FAQ section to find out. In case you haven't found an answer (and also if you have), we and our community are looking forward to hearing from you on Discord. Have you build something that others might find useful? Don't hesitate to share your knowledge! - [Discord](https://discord.com/invite/WDvCZ54) — Join our core team and Zerops community on Discord. Ask questions and share your tips with other members. ## Popular Guides - [zCLI](/references/cli) — Get even more out of Zerops with the zCLI command line tool. - [Zerops VPN](/references/networking/vpn) — Connect to your services easily with Zerops VPN. ---------------------------------------- # Clickhouse > Overview Zerops provides a fully managed [ClickHouse](https://clickhouse.com/) columnar database optimized for blazing-fast analytical queries on massive datasets, making it ideal for data warehousing and real-time analytics applications. ## Supported Versions Currently supported ClickHouse version: Import configuration version: - `clickhouse@25.3` ## Service Configuration Our ClickHouse implementation features optimized default settings designed for analytical workloads and data warehousing use cases. ### Resource Allocation Zerops automatically allocates resources to your ClickHouse service based on demand within the limits defined in your [automatic scaling configuration](/features/scaling). ## High Availability and Deployment Modes :::important Deployment mode is selected during service creation and cannot be changed later. ::: ### High-Availability (HA) Setup The recommended solution for production workloads and mission-critical analytics: * **3 data nodes** with automatic monitoring, repairs, and replication factor of 3 * **Default cluster name:** `zerops` (currently 1 shard with 3 replicas) #### Replication Configuration The `Replicated` database engine handles replication automatically, but there are specific requirements you need to follow: **For Database Operations** Use this configuration when creating/managing databases: ```sql CREATE DATABASE uk ON CLUSTER '{cluster}' ENGINE = Replicated('/clickhouse/databases/{uuid}', '{shard}', '{replica}'); ``` **For Table Operations** Use `ENGINE = ReplicatedMergeTree` when creating tables (without the `ON CLUSTER '{cluster}'` clause): ```sql CREATE TABLE uk.uk_price_paid ( price UInt32, date Date, postcode1 LowCardinality(String), postcode2 LowCardinality(String), type Enum8('terraced' = 1, 'semi-detached' = 2, 'detached' = 3, 'flat' = 4, 'other' = 0), is_new UInt8, duration Enum8('freehold' = 1, 'leasehold' = 2, 'unknown' = 0), addr1 String, addr2 String, street LowCardinality(String), locality LowCardinality(String), town LowCardinality(String), district LowCardinality(String), county LowCardinality(String) ) ENGINE = ReplicatedMergeTree ORDER BY (postcode1, postcode2, addr1, addr2); ``` For more details see: - https://clickhouse.com/docs/engines/database-engines/replicated - https://clickhouse.com/docs/engines/table-engines/mergetree-family/replication - https://clickhouse.com/docs/sql-reference/distributed-ddl You can use other `Replicated*` engines from the MergeTree family. Replication is only supported for tables in the MergeTree family: * `ReplicatedMergeTree` * `ReplicatedSummingMergeTree` * `ReplicatedReplacingMergeTree` * `ReplicatedAggregatingMergeTree` * `ReplicatedCollapsingMergeTree` * `ReplicatedVersionedCollapsingMergeTree` * `ReplicatedGraphiteMergeTree` User management (users, grants, etc.) is replicated by Keeper by default. The `ON CLUSTER '{cluster}'` clause is not needed when creating/deleting users or changing grants. The default `` database follows these practices. If you don't follow these recommendations, it is possible you will face issues in case of fail and repair scenario. ### Single Container Installation Suitable for development and testing environments: * Consists of 1 ClickHouse node * Lower resource requirements * No automatic replication :::warning Use for development purposes or non-critical data only. **Make sure to have backups enabled** if using in production, as you can lose your data due to container volatility. ::: ## Network Access & Protocols Zerops automatically configures secure authentication for your ClickHouse service. ### Default Database Zerops creates a default database with the same name as your service hostname (``) during service creation. ### Default Users #### `zerops` User * Created automatically upon service creation * Has privileges for the default database * Password available as environment variable `password` #### `super` User * Administrative user for cluster management * Can create new databases, users, and manage permissions * Password available as environment variable `superUserPassword` ### Access Methods Services within the same project can access ClickHouse directly using: ``` : ``` For HA cluster setups, you can also access specific data nodes: ``` node-stable-<1..3>.db..zerops: ``` For external access, use `zcli` VPN to connect using the same connection strings. ClickHouse offers multiple interfaces for different use cases: #### Native TCP Protocol **Port:** `9000` (Environment variable: `port` or `portNative`) Optimal for high-performance applications and ClickHouse-native clients. More about it in [official ClickHouse docs](https://clickhouse.com/docs/interfaces/tcp). #### HTTP/HTTPS Interface **Port:** `8123` (Environment variable: `portHttp`) Ideal for web applications and REST API integrations. It is also possible to setup HTTPS domain access or enable subdomain for access from outside the project. Then you can access the database using following URL: - `https://clickhouse.my-awesome-domain.tld` - JDBC connection string example (use `ssl=true&sslmode=NONE` options): `jdbc:clickhouse:https://clickhouse.my-awesome-domain.tld:443/?ssl=true&sslmode=NONE` More about it in [official ClickHouse docs](https://clickhouse.com/docs/interfaces/http). #### MySQL Protocol **Port:** `9004` (Environment variable: `portMysql`) Enables connectivity from MySQL-compatible tools and applications. More about it in [official ClickHouse docs](https://clickhouse.com/docs/interfaces/mysql). #### PostgreSQL Protocol **Port:** `9005` (Environment variable: `portPostgresql`) Allows integration with PostgreSQL-compatible clients and ORMs. More about it in [official ClickHouse docs](https://clickhouse.com/docs/interfaces/postgresql). ## Backup and Recovery Zerops provides comprehensive backup functionality using ClickHouse's native backup capabilities. ### Backup Process * Backups are performed using ClickHouse SQL command `BACKUP ALL ...` with `super` user permissions * All databases are backed up (excluding system databases) * Backup files are stored as `tar.gz` archives * Contains the complete folder structure produced by the SQL backup command ### Restore Options #### Option 1: Custom S3 Bucket Restore 1. Download backup from Zerops GUI or via API 2. Extract the tar.gz archive and upload to your S3 bucket 3. Restore using ClickHouse SQL commands: ```sql -- Restore specific table RESTORE TABLE mydb.mytable AS mydb.mytable2 FROM S3('https://storage-prg1.zerops.io/mybucket/path/to/dir/with/untarred/backup', 'my-access-key-id', 'my-secret-key'); -- Restore all data RESTORE ALL FROM S3('https://storage-prg1.zerops.io/mybucket/path/to/backup', 'my-access-key-id', 'my-secret-key'); -- see https://clickhouse.com/docs/operations/backup#configuring-backuprestore-to-use-an-s3-endpoint ``` #### Option 2: Support-Assisted Restore Contact Zerops support on Discord, and we'll place the backup on the container's filesystem for restoration using the `File` driver (see [ClickHouse documentation](https://clickhouse.com/docs/operations/backup) for further info). :::note A simple GUI/API action for backup restoration is on our roadmap for future releases. ::: ## Troubleshooting ### Common Issues #### Connection Problems * Verify you're using the correct port for your chosen protocol * Check that your service is running and healthy in the Zerops dashboard * For HA clusters, try connecting to specific nodes if the main endpoint fails * Ensure authentication credentials are correct #### Replication Issues * Verify you're using `ON CLUSTER '{cluster}'` for database operations * Confirm tables use `ReplicatedMergeTree` engines ## Learn More - [Official ClickHouse Documentation](https://clickhouse.com/docs) - Comprehensive guide to ClickHouse features and SQL syntax - [ClickHouse Replication Guide](https://clickhouse.com/docs/engines/table-engines/mergetree-family/replication) - Detailed replication concepts - [Distributed DDL Reference](https://clickhouse.com/docs/sql-reference/distributed-ddl) - Cluster operations documentation ## Support For advanced configurations or custom requirements: - Join our [Discord community](https://discord.gg/zerops) - Contact support via [email](mailto:support@zerops.io) ---------------------------------------- # Company > About ## Our Story Zerops, originally founded in 2018, began as an internal project at [vshosting.eu](https://vshosting.eu), one of the largest providers of managed hosting solutions in Central Europe. In June 2024, after a period when the project had been shut down following corporate restructuring, Zerops was re-launched as an independent startup. Now headed by the original development team and backed by strong partners, Zerops continues its mission with renewed focus and independence. ## Technology & Infrastructure Zerops runs on bare metal, with the platform built from the ground up using Golang and [Incus](https://linuxcontainers.org/incus/) containerization. Our servers are currently located in Prague, Czech Republic, leveraging vshosting's state-of-the-art datacenter facilities. ## Financial Backing & Partners Zerops is financially backed by established venture capital firms: - [Presto Ventures](https://www.prestoventures.com/) - A leading Central European venture capital firm - [Gi21 Capital](https://gi21capital.com/) - A technology-focused investment firm Our primary infrastructure partner is [vshosting.eu](https://vshosting.eu), which itself is part of [Contabo](https://contabo.com/en/), owned by global investment firm [KKR](https://www.kkr.com/). This strategic partnership provides Zerops with enterprise-grade infrastructure stability. ## Looking Ahead We're committed to continually improving the Zerops platform with a focus on: - **Multiregional Deployment**: Beginning with built-in CDN capabilities, followed by the ability to run entire projects in different regions - **Enhanced Performance**: Ongoing optimization of our container orchestration and resource management - **Developer Experience**: Continuous improvement of our UI, CLI, and API interfaces ## Connect With Us - [Discord](https://discord.com/invite/WDvCZ54) - [X.com](https://x.com/zeropsio) - [LinkedIn](https://www.linkedin.com/company/zerops) - [Contact Us](mailto:team@zerops.io) ---------------------------------------- # Company > Branding # Zerops Brand Assets Here you can find and download our official logos and badges in various formats. Please follow our brand guidelines when using these assets. ## Download Assets Below you'll find our official assets available in various formats. Click the download buttons to get the assets in your preferred format. ## Brand Guidelines When using Zerops brand assets, please: - Don't modify the logos or badges in any way - Maintain adequate spacing around the assets - Use the provided color versions (light/dark) as appropriate - Don't use the Zerops logo or badges in a way that suggests partnership or endorsement without permission - Don't use the assets as your own branding or as part of your logo ---------------------------------------- # Company > Payment Zerops provides a transparent credit-based payment system that makes managing your account finances straightforward. You can easily add funds to your account through manual or automatic top-ups, track all your transactions, and download invoices for your records. This page explains how to manage your account balance, set up payment preferences, and access your complete billing history to help you maintain uninterrupted service while keeping your finances organized. ## Manual Top-up Manual top-ups give you direct control over your account funding. To add credits to your account immediately: 1. Navigate to **Credit & Spend Overview** in the Organization section of the main menu 2. Click on **Top up credit** and fill in the [billing information](#billing-information) 3. Enter your desired top-up amount (minimum $10 VAT excl.) 3. Complete payment using your saved or new payment method ## Automatic Top-ups Automatic top-up ensures your projects continue running without interruption by replenishing your credits when they run low. :::note Prerequisites Automatic top-ups are available once you have made at least one manual top-up, saved a payment method, and provided your [billing information](#billing-information). The saved card is charged off-session, so a valid payment method must stay on file. ::: To turn them on, navigate to **Credit & Spend Overview** in the Organization section of the main menu, open the automatic top-up settings, and configure the three values described below. ### How Automatic Top-ups Work When enabled, Zerops periodically checks your balance and tops it up by a fixed amount whenever your credit drops below a threshold you choose, up to a limit you set for each calendar month. Zerops initiates an automatic payment when: - Your combined balance (credit + promo credit) drops **below your threshold** - You have automatic top-ups enabled - The top-up wouldn't exceed your **calendar-month limit** :::note Important notes - Each top-up charges the **fixed amount** you configured, regardless of how fast you're spending - Your balance is checked periodically (every few minutes), so a top-up can take a few minutes to appear after you drop below the threshold - The final automatic top-up of the month is reduced so the month's total lands exactly on your calendar-month limit; after the limit is reached, automatic top-ups pause until the next calendar month - To avoid repeatedly hitting your payment method (which can get a card flagged or blocked by the payment processor), top-ups are spaced out: after a **successful** top-up Zerops waits **1 hour** before the next one, and after a **failed** top-up it waits **1 day** before trying again - If a charge fails, Zerops notifies you so you can check the validity and available funds of your saved card. After **3 failed attempts in a row**, automatic top-up is turned off and you're notified by email; re-enable it once your payment method is working again - Auto top-up limits don't affect manual payments — add any amount manually regardless of automatic settings ::: ### Configuration Options #### Threshold When your combined balance (credit + promo credit) drops below this value, an automatic top-up is triggered. #### Top-up Amount The fixed amount charged to your saved card on each automatic top-up. - Minimum: $10 (matches the minimum manual payment) - Maximum: $10,000 per top-up #### Calendar-Month Limit The maximum total that can be automatically charged within a single calendar month (UTC). This safeguards against unexpected costs: once the limit is reached, automatic top-ups pause until the next calendar month. - Must be at least the top-up amount (so at least one top-up can go through each month) #### Real-World Example **Scenario:** Application with ~$50 weekly operating costs and an initial manual top-up of $100 **Your Settings:** - Threshold = $50 - Top-up amount = $200 - Calendar-month limit = $500 **Expected behavior:** - When your balance falls below $50, Zerops charges $200 to bring it back up - Each top-up is exactly $200, no matter how fast you're spending, until you approach the calendar-month limit - After two top-ups ($400), a full $200 would exceed the $500 limit, so the next top-up is reduced to $100, bringing the month's total to exactly $500 - Automatic top-ups then pause until the limit resets at the start of the next calendar month (UTC) ## Billing Information You are required to enter billing details for all transactions (manual and automatic top-ups), with one exception: - EU-based users who are not VAT payers with transactions under $350 You can save your billing details by navigating to **Invoices & Billing Settings** in the Organization section of the main menu. ## Invoices Zerops provides easy access to all invoices generated for manual and automatic top-ups within your organization. To view and manage your invoices navigate to **Invoices & Billing Settings** in the Organization section of the main menu. ## Export Credit Consumption Records Zerops allows you to download monthly reports of your credit consumption history for analysis and record-keeping. 1. Navigate to **Credit & Spend Overview** in the Organization section 2. Find the **Export Credit Consumption Records** section 3. Click on any month button to download that period's report Reports are available for the past 12 months in TXT format and include: - Client information and reporting period - Starting and ending balances - Itemized resource charges by project and service - Credit transactions (top-ups, refunds, promotional credits) - Clear distinction between common (paid) and promotional credits ---------------------------------------- # Company > Pricing Zerops provides a straightforward pricing structure based on your project type and resource usage. The total cost of deploying an application includes your project's **core package cost** + the **cost of the resources** of the services inside a project. Additional charges may apply for optional features such as dedicated IPv4, extra egress, object storage, extra backup space and extra build time. :::note Fair Billing Model Resources are allocated per service and billed by the minute, though credit is deducted hourly based on actual usage. You're only charged for what you use, calculated down to the minute. ::: Need to add credits to your account? Visit our [Top-up & Billing page](/company/payment) for instructions. ## Project Core Plans Zerops offers two core types to match different needs and budgets. For detailed information on both core types, visit our [Project & Services Structure](/features/infrastructure) page. ### Lightweight Core - Free Best for development, testing, and smaller workloads with limited redundancy. **Included resources:** - **Build Time**: 15 hours per month - **Backup Storage**: 5 GB - **Egress Traffic**: 100 GB per month ### Serious Core - $10 / 30 days Optimized for production workloads with high availability and comprehensive failover protection. **Included resources:** - **Build Time**: 150 hours per month - **Backup Storage**: 25 GB - **Egress Traffic**: 3 TB per month :::note Storage Limits All projects have a technical maximum backup storage limit of **1 TiB**. Usage beyond the free tier allocation (5GB or 25GB) is billed according to the [overage costs](#overage-costs) below. ::: ## Resource Pricing Services in Zerops require computing resources that are billed separately from your project core. These resources are allocated per service and billed by the minute based on actual usage, with credits deducted hourly.
Resource Price Description
Shared CPU $0.60 per CPU / 30 days Economical option for most workloads with good performance
Dedicated CPU $6.00 per CPU / 30 days Reserved CPU cores for predictable performance
RAM $0.75 per 0.25 GB / 30 days Memory allocated to your services
Disk Space $0.05 per 0.5 GB / 30 days Storage space for your applications and data
:::note Daily Spending Control You can set a daily spending limit in the GUI for your project to keep an eye on costs and avoid unexpected charges. This provides an alternative to configuring automatic resource scaling ranges while keeping your services running optimally. Reaching the limit does not stop your project - your services keep running. When a project reaches its daily spending limit, Zerops sends you a warning notification (e-mail) so you can decide whether to raise the limit. The limit resets at midnight (UTC). ::: ## Additional Services Enhance your deployment with these optional services to meet specific requirements for networking, storage, and data transfer.
Service Price Description
Dedicated IPv4 $3.00 per 30 days Exclusive IPv4 address for your project (instead of shared)
Object Storage $0.01 per GB / 30 days Scalable storage for files, backups, and static assets
## Overage Costs When you exceed the resources included in your project core plan, the following charges apply:
Item Price Description
Extra Egress $0.02 per GB Data transfer out of your project beyond plan limits
Extra Backup Space $0.50 per 5 GB Additional storage for automatic, encrypted backups
Extra Build Time $0.50 per 15 hours Additional time for building and deploying applications
## Pricing Calculator Use our pricing calculator to estimate your monthly costs based on your specific needs: ---------------------------------------- # Deno > How To > Build Pipeline Zerops provides a customizable build and runtime environment for your Deno application. ## Add zerops.yaml to your repository Start by adding `zerops.yaml` file to the **root of your repository** and modify it to fit your application: ```yaml zerops: # define hostname of your service - setup: app # ==== how to build your application ==== build: # REQUIRED. Set the base technology for the build environment: base: deno@latest # OPTIONAL. Set the operating system for the build environment. # os: ubuntu # OPTIONAL. Customise the build environment by installing additional packages # or tools to the base build environment. # prepareCommands: # - sudo apt-get something # - curl something else # OPTIONAL. Build your application buildCommands: - deno task build # REQUIRED. Select which files / folders to deploy after # the build has successfully finished deployFiles: - dist - deno.jsonc # OPTIONAL. Which files / folders you want to cache for the next build. # Next builds will be faster when the cache is used. # cache: directory # ==== how to run your application ==== run: # OPTIONAL. Sets the base technology for the runtime environment: base: deno@latest # OPTIONAL. Sets the internal port(s) your app listens on: ports: # port number - port: 3000 # OPTIONAL. Customise the runtime Deno environment by installing additional # dependencies to the base Deno runtime environment. # prepareCommands: # - sudo apt-get something # - curl something else # OPTIONAL. Run one or more commands each time a new runtime container # is started or restarted. These commands are triggered before # your Deno application is started. # initCommands: # - rm -rf ./cache # REQUIRED. Your Deno application start command start: deno task start ``` The top-level element is always `zerops`. ### Setup The first element `setup` contains the **hostname** of your service. A runtime service with the same hostname must exist in Zerops. Zerops supports the definition of multiple runtime services in a single `zerops.yaml`. This is useful when you use a monorepo. Just add multiple setup elements in your `zerops.yaml`: ```yaml zerops: # definition for app service - setup: app # optional build: ... # optional deploy: ... # required run: ... # definition for api service - setup: api # optional build: ... # optional deploy: ... # required run: ... ``` Each service configuration contains at least the `run` section. Optional `build` and `deploy` sections can be added to further customize your process. ## Build pipeline configuration ### base _REQUIRED._ Sets the base technology for the build environment. Following options are available for Deno builds: - `deno@2.0.0`, `deno@2`, `deno@latest` - `deno@1.45.5`, `deno@1` ```yaml zerops: # hostname of your service - setup: app # ==== how to build your application ==== build: # REQUIRED. Sets the base technology for the build environment: base: deno@latest ... ```

The base build environment contains {data.alpine.default}, the selected major version of Deno, [Zerops command line tool](/references/cli), `npm`, `yarn`, `git` and `npx` tools.

:::info You can change the base environment when you need to. Just simply modify the `zerops.yaml` in your repository. ::: If you need to install more technologies to the build environment, set multiple values as a yaml array. For example: ```yaml zerops: # hostname of your service - setup: app # ==== how to build your application ==== build: # REQUIRED. Sets the base technology for the build environment: base: - deno@latest prepareCommands: - zsc add go@latest ... ``` See the full list of supported [build base environments](/zerops-yaml/base-list#runtime-services). To customise your build environment use the [prepareCommands](#preparecommands) attribute. :::note Modifying the base technology will invalidate your build cache. See our [Build Cache Documentation](/features/build-cache) for more details about cache invalidation. ::: ### os _OPTIONAL._ Sets the operating system for the build environment. Following options are available: - `alpine` - `ubuntu` Default value is `alpine`. We are currently using following os version: - {data.alpine.default} - {data.ubuntu.default} :::caution The os version is fixed and cannot be customised. ::: :::note Changing the OS setting will invalidate your build cache. See our [Build Cache Documentation](/features/build-cache) for details about cache behavior. ::: ### prepareCommands _OPTIONAL._ Customises the build environment by installing additional dependencies or tools to the base build environment. The base build environment contains: - {data.alpine.default} - selected version of Deno defined in the [base](#base) attribute - [Zerops command line tool](/references/cli) - `npm`, `yarn`, `git` and `npx` tools To install additional packages or tools add one or more prepare commands: ```yaml zerops: # hostname of your service - setup: app # ==== how to build your application ==== build: # REQUIRED. Set the base technology for the build environment: base: deno@latest # OPTIONAL. Customise the build environment by installing additional packages # or tools to the base build environment. prepareCommands: - sudo apt-get something - curl something else ... ``` When the first build is triggered, Zerops will 1. create a build container 2. download your application code from your repository 3. run the prepare commands in the defined order The application code is available in `/build/source` before the prepare commands are triggered, so you can use any file from your repository in your prepare commands (e.g. a configuration file). The commands themselves run in the `/home/zerops` directory. :::note These commands are skipped when using cached environment. Modifying `prepareCommands` will invalidate your build cache. See our [Build Cache Documentation](/features/build-cache) for details about cache invalidation. ::: #### Command exit code If any command fails, it returns an exit code other than 0 and the build is canceled. Read the [build log](/deno/how-to/logs#build-log) to troubleshoot the error. If the command ends successfully, it returns the exit code 0 and Zerops triggers the following command. When all prepare commands are finished, your custom build environment is ready for the build phase. #### Single or separated shell instances You can configure your prepare commands to be run in a single shell instance or multiple shell instances. The format is identical to [build commands](#buildcommands). ### buildCommands _OPTIONAL._ Defines build commands. ```yaml zerops: # hostname of your service - setup: app # ==== how to build your application ==== build: # REQUIRED. Set the base technology for the build environment: base: deno@latest # OPTIONAL. Build your application buildCommands: - deno task build ... ``` Build commands are optional. Zerops triggers each command in the defined order in a dedicated build container, running from the `/build/source` directory. Before the build commands are triggered the build container contains: 1. base environment defined by the [base](#base) attribute 2. optional customisation of the base environment defined in the [prepareCommands](#preparecommands) attribute 3. your application code #### Run build commands as a single shell instance Use following syntax to run all commands in the same environment context. For example, if one command changes the current directory, the next command continues in that directory. When one command creates an environment variable, the next command can access it. ```yaml buildCommands: - | deno test deno task build ``` #### Run build commands as a separate shell instances When the following syntax is used, each command is triggered in a separate environment context. For example, each shell instance starts in the home directory again. When one command creates an environment variable, it won't be available for the next command. ```yaml buildCommands: - deno task build ``` #### Command exit code If any command fails, it returns an exit code other than 0 and the build is canceled. Read the [build log](/deno/how-to/logs#build-log) to troubleshoot the error. If the error log doesn't contain any specific error message, try to run your build with the --verbose option. ```yaml buildCommands: - npm i --verbose - npm run build ``` If the command ends successfully, it returns the exit code 0 and Zerops triggers the following command. When all `buildCommands` are finished, the application build is completed and ready for the deploy phase. ### deployFiles _REQUIRED._ Selects which files or folders will be deployed after the build has successfully finished. To filter out specific files or folders, use [`.deployignore`](#deployignore) file. ```yaml # REQUIRED. Select which files / folders to deploy after # the build has successfully finished deployFiles: - dist - package.json - node_modules ``` Determines files or folders produced by your build, which should be deployed to your runtime service containers. The path starts from the **root directory** of your project (the location of `zerops.yaml`). You must enclose the name in quotes if the folder or the file name contains a space. 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`. #### Examples Deploys a folder, and a file from the project root directory: ```yaml deployFiles: - dist - package.json ``` Deploys the whole content of the build container: ```yaml deployFiles: . ``` Deploys a folder, and a file in a defined path: ```yaml deployFiles: - ./path/to/file.txt - ./path/to/dir/ ``` #### How to use a wildcard in the path 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/` ```yaml deployFiles: ./path/~/to/file.txt ``` Deploys all folders that are located in any path that begins with `/path/to/` ```yaml deployFiles: ./path/to/~/ ``` Deploys all folders that are located in any path that begins with `/path/` and ends with `/to/` ```yaml deployFiles: ./path/~/to/ ``` :::note Example 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`](https://git-scm.com/docs/gitignore#_pattern_format). 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: ```yaml title="zerops.yaml" zerops: - setup: app build: deployFiles: ./ ``` ```text title=".deployignore" /src/file.txt ``` The example above ignores `file.txt` only in the root src directory. ```text title=".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`](/references/zcli/commands#deploy) command. ::: ### cache _OPTIONAL._ Defines which files or folders will be cached for the next build. ```yaml # OPTIONAL. Which files / folders you want to cache for the next build. # Next builds will be faster when the cache is used. cache: file.txt ``` The cache attribute helps optimize build times by preserving specified files between builds. The cache attribute supports the [~ wildcard character](#how-to-use-a-wildcard-in-the-path). Learn more about the [build cache system](/features/build-cache) in Zerops. ### envVariables _OPTIONAL._ Defines the environment variables for the build environment. Enter one or more env variables in following format: ```yaml zerops: # define hostname of your service - setup: app # ==== how to build your application ==== build: base: deno@latest … # OPTIONAL. Defines the env variables for the build environment: envVariables: NODE_ENV: production DB_NAME: db DB_HOST: db DB_USER: db DB_PASS: ${db_password} ``` Read more about [environment variables](/deno/how-to/env-variables) in Zerops. ## Runtime configuration ### base _OPTIONAL._ Sets the base technology for the runtime environment. If you don't specify the `run.base` attribute, Zerops keeps the current Deno version for your runtime. Following options are available for Deno builds: - `2.0` - `1.45` ```yaml zerops: # hostname of your service - setup: app # ==== how to build your application ==== build: # REQUIRED. Sets the base technology for the build environment: base: deno@latest ... # ==== how to run your application ==== run: # OPTIONAL. Sets the base technology for the runtime environment: base: deno@latest ... ```

The base runtime environment contains {data.alpine.default}, the selected major version of Deno, Zerops command line tool, `npm`, `yarn`, `git` and `npx` tools.

:::info You can change the base environment when you need to. Just simply modify the `zerops.yaml` in your repository. ::: If you need to install more technologies to the runtime environment, set multiple values as a yaml array. For example: ```yaml zerops: # hostname of your service - setup: app # ==== how to build your application ==== build: # REQUIRED. Sets the base technology for the build environment: base: deno@latest ... # ==== how to run your application ==== run: # OPTIONAL. Sets the base technology for the runtime environment: base: - deno@latest prepareCommands: - zsc add go@latest ... ``` See the full list of supported [run base environments](/zerops-yaml/base-list). To customise your build environment use the `prepareCommands` attribute. ### os _OPTIONAL._ Sets the operating system for the runtime environment. Following options are available: - `alpine` - `ubuntu` Default value is `alpine`. We are currently using following os version: - {data.alpine.default} - {data.ubuntu.default} :::caution The os version is fixed and cannot be customised. ::: ### ports _OPTIONAL._ Specifies one or more internal ports on which your application will listen. Projects in Zerops represent a group of one or more services. Services can be of different types (runtime services, databases, message brokers, object storage, etc.). All services of the same project share a **dedicated private network**. To connect to a service within the same project, just use the service hostname and its internal port. For example, to connect to a Deno service with hostname = "app" and port = 3000 from another service of the same project, simply use `app:3000`. Read more about [how to access a Deno service](/references/networking/internal-access#basic-service-communication). Each port has following attributes: | parameter | description | | ----------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | port | Defines the port number. You can set any port number between _10_ and _65435_. Ports outside this interval are reserved for internal Zerops systems. | | protocol | **Optional.** Defines the protocol. Allowed values are `TCP` or `UDP`. Default value is `TCP`. | | httpSupport | **Optional.** `httpSupport = true` is the default setting for TCP protocol. Set `httpSupport = false` if a web server isn't running on the port. Zerops uses this information for the configuration of [public access](/features/access). `httpSupport = true` is available only in combination with the TCP protocol. | | httpSupport | **Optional.** `httpSupport = true` is the default setting for TCP protocol. Set `httpSupport = false` if a web server isn't running on the port. Zerops uses this information for the configuration of [public access](/features/access). `httpSupport = true` is available only in combination with the TCP protocol. | ### prepareCommands _OPTIONAL._ Customises the Deno runtime environment by installing additional dependencies or tools to the runtime base environment.

The base Deno environment contains {data.alpine.default} the selected major version of Deno, [Zerops command line tool](/references/cli) and `npm`, `yarn`, `git` and `npx` tools. To install additional packages or tools add one or more prepare commands:

```yaml zerops: # hostname of your service - setup: app # ==== how to build your application ==== build: ... # ==== how to run your application ==== run: # OPTIONAL. Customise the runtime environment by installing additional packages # or tools to the base Deno runtime environment. prepareCommands: - sudo apt-get something - curl something else ... ``` When the first deploy with a defined prepare attribute is triggered, Zerops will 1. create a prepare runtime container 2. optionally: [copy selected folders or files from your build container](#copy-folders-or-files-from-your-build-container) 3. run the `prepareCommands` commands in the defined order :::note `run.prepareCommands` run in the `/home/zerops` directory. ::: #### Command exit code If any command fails, it returns an exit code other than 0 and the deploy is canceled. Read the [prepare runtime log](/deno/how-to/logs#prepare-runtime-log) to troubleshoot the error. If the command ends successfully, it returns the exit code 0 and Zerops triggers the following command. When all `prepareCommands` commands are finished, your custom runtime environment is ready for the deploy phase. #### Cache of your custom runtime environment Some packages or tools can take a long time to install. Therefore, Zerops caches your custom runtime environment after the installation of your custom packages or tools is completed. When the second or following deploy is triggered, Zerops will use the custom runtime cache from the previous deploy if following conditions are met: 1. Content of the [build.addToRunPrepare](#copy-folders-or-files-from-your-build-container) and `run.prepareCommands` attributes didn't change from the previous deploy 2. The custom runtime cache wasn't invalidated in the Zerops GUI. To invalidate the custom runtime cache go to `yyy` When the custom runtime cache is used, Zerops doesn't create a prepare runtime container and executes the deployment of your application directly. #### Single or separated shell instances You can configure your prepare commands to be run in a single shell instance or multiple shell instances. The format is identical to [build commands](#buildcommands). ### Copy folders or files from your build container

The prepare runtime container contains {data.alpine.default}, the selected major version of Deno, [Zerops command line tool](/references/cli) and `npm`, `yarn`, `git` and `npx` tools.

The prepare runtime container does not contain your application code nor the built application. If you need to copy some folders or files from the build container to the runtime container (e.g. a configuration file) use the `addToRunPrepare` attribute in the [build section](#build-pipeline-configuration). ```yaml zerops: # hostname of your service - setup: app # ==== how to build your application ==== build: ... addToRunPrepare: ./runtime-config.yaml # ==== how to run your application ==== run: # OPTIONAL. Customise the runtime environment by installing additional packages # or tools to the base Deno runtime environment. prepareCommands: - sudo apt-get something - curl something else ... ``` In the example above Zerops will copy the `runtime-config.yaml` file from your build container **after the build has finished** into the new **prepare runtime** container. The copied files and folders will be available in the `/home/zerops` folder in the new prepare runtime container before the prepare commands are triggered. ### initCommands _OPTIONAL._ Defines one or more commands to be run each time a new runtime container is started or a container is restarted. ```yaml zerops: # hostname of your service - setup: app # ==== how to build your application ==== build: ... # ==== how to run your application ==== run: # OPTIONAL. Run one or more commands each time a new runtime container # is started or restarted. These commands are triggered before # your Deno application is started. initCommands: - rm -rf ./cache ``` These commands are triggered in the runtime container before your Deno application is started via the [start command](#start). :::note `run.initCommands` run in the `/var/www` directory. ::: Use init commands to clean or initialise your application cache or similar operations. :::caution The init commands will delay the start of your application each time a new runtime container is started (including the horizontal [scaling](/deno/how-to/scaling) or when a runtime container is restarted). Do not use the init commands for customising your runtime environment. Use the [run:prepareCommands](#preparecommands-1) attribute instead. ::: #### Command exit code If any of the `initCommands` fails, it returns an exit code other than 0, but deploy is **not** canceled. After all init commands are finished, regardless of the status code, the application is started. Read the [runtime log](/deno/how-to/logs#runtime-log) to troubleshoot the error. #### Single or separated shell instances You can configure your `initCommands` to be run in a single shell instance or multiple shell instances. The format is identical to [build commands](#buildcommands). ### envVariables _OPTIONAL._ Defines the environment variables for the runtime environment. Enter one or more env variables in following format: ```yaml zerops: # define hostname of your service - setup: app # ==== how to run your application ==== run: # OPTIONAL. Defines the env variables for the runtime environment: envVariables: NODE_ENV: production DB_NAME: db DB_HOST: db DB_USER: db DB_PASS: ${db_password} ``` Read more about [environment variables](/deno/how-to/env-variables) in Zerops. ### start _REQUIRED._ Defines the start command for your Deno application. ```yaml zerops: # hostname of your service - setup: app # ==== how to build your application ==== build: ... # ==== how to run your application ==== run: # REQUIRED. Your Deno application start command start: deno task start ``` We recommend starting your Deno application using `deno task start`. ### health check _OPTIONAL._ Defines a health check. `healthCheck` requires either one `httpGet` object or one `exec` object. #### httpGet Configures the health check to request a local URL using a HTTP GET method. Following attributes are available:
Parameter Description
port Defines the port of the HTTP GET request. The readiness check will trigger a GET request on {'http://127.0.0.1:{port}/{path}'}
path Defines the URL path of the HTTP GET request. The readiness check will trigger a GET request on {'http://127.0.0.1:{port}/{path}'}
host Optional. The readiness check is triggered from inside of your runtime container so it always uses the localhost 127.0.0.1. If you need to add a host to the request header, specify it in the host attribute.
scheme Optional. The readiness check is triggered from inside of your runtime container so no https is required. If your application requires a https request, set scheme: https
**Example:** ```yaml zerops: # hostname of your service - setup: app # ==== how to build your application ==== build: ... # ==== how to run your application ==== run: # REQUIRED. Your Deno application start command start: deno task start # OPTIONAL. Define a health check with a HTTP GET request option. # Configures the check on http://127.0.0.1:80/status healthCheck: httpGet: port: 80 path: /status ``` #### exec Configures the health check to run a local command. Following attributes are available: | Parameter | Description | | ----------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | **command** | Defines a local command to be run. The command has access to the same [environment variables](/deno/how-to/create#set-secret-environment-variables) as your Deno application. A single string is required. If you need to run multiple commands create a shell script or, use a multiline format as in the example below. | **Example:** ```yaml zerops: # hostname of your service - setup: app # ==== how to build your application ==== build: ... # ==== how to run your application ==== run: # REQUIRED. Your Deno application start command start: deno task start # OPTIONAL. Define a health check with a shell command. healthCheck: exec: command: | touch grass rm -rf life mv /outside/user /home/user ``` ### crontab _OPTIONAL._ Defines cron jobs. Setup cron jobs in the following format: ```yaml zerops: # define hostname of your service - setup: app # ==== how to run your application ==== run: crontab: # REQUIRED. Sets the command to execute: - command: "" # REQUIRED. Sets the interval time to execute: timing: "0 * * * *" ``` Read more about setting up [cron](/zerops-yaml/cron) in Zerops. ## Deploy configuration ### readiness check _OPTIONAL._ Defines a readiness check. Read more about how the [readiness check works](/deno/how-to/deploy-process#readiness-checks) in Zerops. `readinessCheck` requires either one `httpGet` object or one `exec` object. #### httpGet Configures the readiness check to request a local URL using a http GET method. Following attributes are available:
Parameter Description
port Defines the port of the HTTP GET request. The readiness check will trigger a GET request on {'http://127.0.0.1:{port}/{path}'}
path Defines the URL path of the HTTP GET request. The readiness check will trigger a GET request on {'http://127.0.0.1:{port}/{path}'}
host Optional. The readiness check is triggered from inside of your runtime container so it always uses the localhost 127.0.0.1. If you need to add a host to the request header, specify it in the host attribute.
scheme Optional. The readiness check is triggered from inside of your runtime container so no https is required. If your application requires a https request, set scheme: https
**Example:** ```yaml zerops: # hostname of your service - setup: app # ==== how to build your application ==== build: ... # ==== how to deploy your application ==== deploy: # OPTIONAL. Define a readiness check with a HTTP GET request option. # Configures the check on http://127.0.0.1:80/status readinessCheck: httpGet: port: 80 path: /status # ==== how to run your application ==== run: ... ``` Read more about how the [readiness check works](/deno/how-to/deploy-process#readiness-checks) in Zerops. #### exec Configures the readiness check to run a local command. Following attributes are available: | Parameter | Description | | ----------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | **command** | Defines a local command to be run. The command has access to the same [environment variables](/deno/how-to/create#set-secret-environment-variables) as your Deno application. A single string is required. If you need to run multiple commands create a shell script or, use a multiline format as in the example below. | **Example:** ```yaml zerops: # hostname of your service - setup: app # ==== how to build your application ==== build: ... # ==== how to deploy your application ==== deploy: # OPTIONAL. Define a readiness check with a HTTP GET request option. # Configures the check on http://127.0.0.1:80/status readinessCheck: exec: command: | touch grass rm -rf life mv /outside/user /home/user ``` Read more about how the [readiness check works](/deno/how-to/deploy-process#readiness-checks) in Zerops. ---------------------------------------- # Deno > How To > Build Process ## Build process overview Zerops starts a temporary build container and performs the following actions: 1. **Installs the build environment** - Sets up base system and Deno runtime 2. **Downloads your application source code** - From [GitHub ↗](https://www.github.com), [GitLab ↗](https://www.gitlab.com) or via [Zerops CLI](/references/cli) 3. **Optionally customizes the build environment** - Runs prepare commands if configured 4. **Runs the build commands** - Executes your build process 5. **Uploads the application artifact** - Stores build output to internal Zerops storage 6. **Caches selected files** - Preserves specified files for faster future builds The build container is automatically deleted after the build has finished or failed. ## Build configuration Configure your Deno build process in your `zerops.yaml` file according to the [full build & deploy Deno pipeline guide](/deno/how-to/build-pipeline). ## Build environment ### Default Deno build environment The default Deno build environment contains: - {data.ubuntu.default} - Selected version of Deno defined in `zerops.yaml` [build.base](/deno/how-to/build-pipeline#base) parameter - [zCLI](/references/cli), Zerops command line tool - Deno and Git ### Customize build environment To install additional packages or tools, add one or more [build.prepareCommands](/deno/how-to/build-pipeline#preparecommands) to your `zerops.yaml`. :::info The application code is available in the `/build/source` folder in your build container before the prepare commands are triggered. This allows you to use any file from your application code in your prepare commands (e.g. a configuration file). ::: ### Build hardware resources All runtime services use the same hardware resources for build containers:
HW resource Minimum Maximum
CPU cores 1 5
RAM 8 GB 8 GB
Disk 1 GB 100 GB
Build containers start with minimum resources and scale vertically up to maximum capacity as needed. :::info Build container resources are not charged separately. Limited build time is included in your [project core plan](/company/pricing#project-core-plans), with additional build time available if needed. ::: ### Build time limit The time limit for the whole build pipeline is **1 hour**. After 1 hour, Zerops will terminate the build pipeline and delete the build container. ## Troubleshooting Deno builds ### Build command failures If any [build command](/deno/how-to/build-pipeline#buildcommands) fails (returns non-zero exit code), the build is canceled. Check the [build log](/deno/how-to/logs#build-log) to troubleshoot the error. For Deno, if the error log doesn't contain specific error messages, try running your build with verbose output: ```yaml buildCommands: - deno cache main.ts - deno compile --allow-net --allow-read main.ts ``` ### Prepare command failures If any [prepare command](/deno/how-to/build-pipeline#preparecommands) fails, check the [build log](/deno/how-to/logs#build-log) for specific error messages. Common issues include: - Missing permissions in Deno commands (add --allow-net, --allow-read, etc.) - Ubuntu package installation failures (use sudo apt-get update first) - Deno cache directory permissions ### Build cache issues If you encounter unexpected build behavior or dependency issues, the problem might be related to [cached build data](/features/build-cache). While Zerops maintains the build cache to speed up deployments, sometimes you may need to start fresh. To invalidate the build cache: 1. Go to your service detail in Zerops GUI 2. Choose **Pipelines & CI/CD Settings** from the left menu 3. Click on the **Invalidate build cache** button This will force Zerops to run the next build clean, including all prepare commands. Learn more about [build cache behavior](/features/build-cache). :::tip Advanced troubleshooting For complex build issues that require investigation, you can enable [debug mode](/features/debug-mode) to pause the build process at specific points and inspect the build container state interactively. ::: ## More resources For more details about the build and deploy pipeline, including how to cancel builds and manage application versions, see the [general pipeline documentation](/features/pipeline). ## Next steps - Understand the [deployment process](/deno/how-to/deploy-process) - Learn how to [customize the runtime environment](/deno/how-to/customize-runtime) - Explore [build and runtime logs](/deno/how-to/logs) ---------------------------------------- # Deno > How To > Controls ---------------------------------------- # Deno > How To > Create Zerops provides a powerful Deno runtime service with extensive build support. The Deno runtime is highly scalable and customizable to suit your development and production needs. With just a few clicks or commands, you can have a production-ready Deno environment up and running in no time. ## Create a Deno service using Zerops GUI First, set up a project in the Zerops GUI. Then go to the project dashboard page and choose **Add new service** in the left menu under the **Services** section. From there, you can add a new Deno service: [Video: /vids/services/deno.webm](/vids/services/deno.webm) ### Choose a Deno version Zerops supports the following Deno versions: :::info You can easily [upgrade](/deno/how-to/upgrade) the major version at any time later. ::: ### Set a hostname Enter a unique service identifier like "app", "cache", "gui", etc. Duplicate services with the same name within the same project are not allowed. #### Limitations: - Maximum 25 characters - Must contain only lowercase ASCII letters (a-z) or numbers (0-9) :::caution The hostname is fixed after the service is created and cannot be changed later. ::: ### Set secret environment variables Add environment variables with sensitive data, such as passwords, tokens, salts, certificates, etc. These will be securely saved inside Zerops and added to your runtime service upon start. Setting secret environment variables is optional. You can always set them later in the Zerops GUI. Read more about the [different types of environment variables](/deno/how-to/env-variables#service-env-variables) in Zerops. ## Create a Deno service using zCLI zCLI is the Zerops command-line tool. To create a new Deno service via the command line, follow these steps: 1. [Install & setup zCLI](/references/cli) 2. [Create a project description file](/deno/how-to/create#create-a-project-description-file) 3. [Create a project with a Deno and PostgreSQL service](#full-example) ### Create a project description file Zerops uses a YAML format to describe the project infrastructure. #### Basic example: Create a directory called `my-project`. Inside the `my-project` directory, create a `description.yaml` file with the following content: ```yaml # basic project data project: # project name name: my-project # array of project services services: - # service name hostname: app # service type and version number in deno@{version} format type: deno@latest # defines the minimum number of containers for horizontal autoscaling minContainers: 1 # defines the maximum number of containers for horizontal autoscaling. Max value = 6. maxContainers: 6 # optional: create env variables envSecrets: S3_ACCESS_KEY_ID: 'P8cX1vVVb' S3_ACCESS_SECRET: 'ogFthuiLYki8XoL73opSCQ' ``` The yaml file describes your future project infrastructure. The project will contain one Deno version 20 service with default [auto scaling](/deno/how-to/scaling) configuration. Hostname will be set to "app", the internal port(s) the service listens on will be defined later in the [zerops.yaml](/deno/how-to/build-pipeline#ports). Following secret env variables will be configured: ```env S3_ACCESS_KEY_ID="P8cX1vVVb" S3_ACCESS_SECRET="ogFthuiLYki8XoL73opSCQ" ``` #### Full example: Create a directory my-project. Create an description.yaml file inside the my-project directory with following content: ```yaml # basic project data project: # project name name: my-project # optional: project description description: A project with a Deno and PostgreSQL database # optional: project tags tags: - DEMO - ZEROPS # array of project services services: - # service name hostname: app # service type and version number in deno@{version} format type: deno@latest # optional: vertical auto scaling customization verticalAutoscaling: cpuMode: DEDICATED minCpu: 2 maxCpu: 5 minRam: 2 maxRam: 24 minDisk: 6 maxDisk: 50 startCpuCoreCount: 3 minFreeRamGB: 0.5 minFreeRamPercent: 20 # defines the minimum number of containers for horizontal autoscaling. Max value = 6. minContainers: 2 # defines the maximum number of containers for horizontal autoscaling. Max value = 6. maxContainers: 4 # optional: create env variables envSecrets: S3_ACCESS_KEY_ID: 'P8cX1vVVb' S3_ACCESS_SECRET: 'ogFthuiLYki8XoL73opSCQ' - # second service hostname hostname: db # service type and version number in postgresql@{version} format type: postgresql@12 # mode of operation "HA"/"non_HA" mode: NON_HA ``` The yaml file describes your future project infrastructure. The project will contain a Deno service and a [PostgreSQL](/postgresql/overview) service. Deno service with "app" hostname, the internal port(s) the service listens on will be defined later in the [zerops.yaml](/deno/how-to/build-pipeline#ports). Deno service will run on version 20 with a custom vertical and horizontal scaling. Following secret env variables will be configured: ```env S3_ACCESS_KEY_ID="P8cX1vVVb" S3_ACCESS_SECRET="ogFthuiLYki8XoL73opSCQ" ``` The hostname of the PostgreSQL service will be set to "db". The [single container](/features/scaling#single-container-mode)(/features/scaling#deployment-modes-databases-and-shared-storage) mode will be chosen and the default auto [scaling configuration](/postgresql/how-to/scale#configure-scaling) will be set. #### Description of description.yaml parameters The `project:` section is required. Only one project can be defined. | Parameter | Description | Limitations | | --------------- | ------------------------------------------------------------------------------------------------------------------------------- | ----------------------- | | **name** | The name of the new project. Duplicates are allowed. | | | **description** | **Optional.** Description of the new project. | Maximum 255 characters. | | **tags** | **Optional.** One or more string tags. Tags do not have a functional meaning, they only provide better orientation in projects. | | **tags** | **Optional.** One or more string tags. Tags do not have a functional meaning, they only provide better orientation in projects. | At least one service in `services:` section is required. You can create a project with multiple services. The example above contains Deno and PostgreSQL services but you can create a `description.yaml` with your own combination of [services](/features/infrastructure).
Parameter Description
hostname The unique service identifier.
  • duplicate services with the same name in the same project are forbidden
  • maximum 25 characters
  • must contain only lowercase ASCII letters (a-z) or numbers (0-9)
type Specifies the service type and version. See what [Deno service types](/references/import-yaml/type-list#runtime-services) are currently supported.
verticalAutoscaling Optional. Defines [custom vertical auto scaling parameters](/deno/how-to/create#set-auto-scaling-configuration). All verticalAutoscaling attributes are optional. Not specified attributes will be set to their default values.
- cpuMode Optional. Accepts `SHARED`, `DEDICATED` values. Default is `SHARED`
- minCpu/maxCpu Optional. Set the minCpu or maxCpu in CPU cores (integer).
- minRam/maxRam Optional. Set the minRam or maxRam in GB (float).
- minDisk/maxDisk Optional. Set the minDisk or maxDisk in GB (float).
minContainers Optional. Default = 1. Defines the minimum number of containers for [horizontal autoscaling](/deno/how-to/create#horizontal-auto-scaling). Limitations: Current maximum value = 10.
maxContainers Defines the maximum number of containers for [horizontal autoscaling](/deno/how-to/create#horizontal-auto-scaling). Limitations: Current maximum value = 10.
envSecrets Optional. Defines one or more secret env variables as a key value map. See env variable [restrictions](/deno/how-to/env-variables#env-variable-restrictions).
### Create a project based on the description.yaml When you have your `description.yaml` ready, use the `zcli project project-import` command to create a new project and the service infrastructure. ```sh Usage: zcli project project-import importYamlPath [flags] Flags: -h, --help Help for the project import command. --org-id string If you have access to more than one organization, you must specify the org ID for which the project is to be created. --working-dir string Sets a custom working directory. Default working directory is the current directory. (default "./") ``` Zerops will create a project and one or more services based on the `description.yaml` content. Maximum size of the `description.yaml` file is 100 kB. You don't specify the project name in the `zcli project project-import` command, because the project name is defined in the `description.yaml`. If you have access to more than one client, you must specify the client ID for which the project is to be created. The `clientID` is located in the Zerops GUI under the client name on the project dashboard page. ### Add Deno service to an existing project #### Example: Create a directory `my-project` if it doesn't exist. Create an `import.yaml` file inside the `my-project` directory with following content: ```yaml # basic project data project: # project name name: my-project # array of project services services: - # service name hostname: app # service type and version number in deno@{version} format type: deno@latest # defines the minimum number of containers for horizontal autoscaling minContainers: 1 # defines the maximum number of containers for horizontal autoscaling. Max value = 6. maxContainers: 6 # optional: create env variables envSecrets: S3_ACCESS_KEY_ID: 'P8cX1vVVb' S3_ACCESS_SECRET: 'ogFthuiLYki8XoL73opSCQ' ``` The yaml file describes the list of one or more services that you want to add to your existing project. In the example above, one Deno service version 20 with default [auto scaling](/deno/how-to/scaling) configuration will be added to your project. Hostname of the new service will be set to `app`. Following secret env variables will be configured: ```env S3_ACCESS_KEY_ID="P8cX1vVVb" S3_ACCESS_SECRET="ogFthuiLYki8XoL73opSCQ" ``` The content of the `services:` section of `import.yaml` is identical to the project description file. The `import.yaml` never contains the `project:` section because the project already exists. When you have your `import.yaml` ready, use the `zcli project service-import` command to add one or more services to your existing Zerops project. ```sh Usage: zcli project service-import importYamlPath [flags] Flags: -h, --help Help for the project service import command. -P, --project-id string If you have access to more than one project, you must specify the project ID for which the command is to be executed. ``` zCLI commands are interactive, when you press enter after `zcli project service-import importYamlPath`, you will be given a list of your projects to choose from. Maximum size of the import.yaml file is 100 kB. ---------------------------------------- # Deno > How To > Customize Runtime ## Build Custom Runtime Images Zerops allows you to build custom runtime images (CRI) when the default base runtime images don't meet your Deno application's requirements. This is an optional phase in the [build and deploy pipeline](/features/pipeline#runtime-prepare-phase-optional). :::important You should not include your application code in the custom runtime image, as your built/packaged code is deployed automatically into fresh containers. ::: ## Configuration ### Default Deno Runtime Environment The default Deno runtime environment contains: - {data.ubuntu.default} - Selected version of Deno when the runtime service was created - [zCLI](/references/cli) - Deno and Git ### When You Need a Custom Runtime Image If your Deno application needs more than what's included in the default environment, you'll need to build a custom runtime image. Common scenarios include: - **System packages for processing**: When your app processes images, videos, or files (requiring packages like `sudo apt-get install -y imagemagick`) - **Global Deno tools**: When you need CLI tools or utilities available system-wide - **Native dependencies**: When your Deno modules require system libraries that aren't in the default environment Here are Deno-specific examples of configuring custom runtime images in your `zerops.yml`: ### Basic Deno Setup ### Using Build Files in Runtime Preparation ```yaml build: addToRunPrepare: - deno.json - import_map.json run: prepareCommands: - sudo apt-get update - sudo apt-get install -y imagemagick - deno cache deps.ts ``` For complete configuration details, see the [runtime prepare phase configuration guide](/features/pipeline#configuration). ## Process and Caching ### How Runtime Prepare Works The runtime prepare process follows the same steps for all runtimes. See [how runtime prepare works](/features/pipeline#how-it-works) for the complete process details. ### Caching Behavior Zerops caches custom runtime images to optimize deployment times. Learn about [custom runtime image caching](/features/pipeline#custom-runtime-image-caching) including when images are cached and reused. ### Build Management For information about managing builds and deployments, see [managing builds and deployments](/features/pipeline#manage-builds-and-deployments). :::warning Shared storage mounts are not available during the runtime prepare phase. ::: ## Troubleshooting If your `prepareCommands` fail, check the [prepare runtime log](/deno/how-to/logs#prepare-runtime-log) for specific error messages. ---------------------------------------- # Deno > How To > Deploy Process ---------------------------------------- # Deno > How To > Env Variables ---------------------------------------- # Deno > How To > Filebrowser ---------------------------------------- # Deno > How To > Logs ---------------------------------------- # Deno > How To > Scaling ---------------------------------------- # Deno > How To > Shared Storage ---------------------------------------- # Deno > How To > Trigger Pipeline ---------------------------------------- # Deno > How To > Upgrade ---------------------------------------- # Deno > Overview [Deno ↗](https://deno.org/en) is an asynchronous event-driven JavaScript runtime, which is designed to build scalable network applications. :::tip Have you got any additional question? Join our **[Discord](https://discord.com/invite/WDvCZ54)** community to get help from our team and other members. ::: As said, there is no need for coding yet, we have created a [Github repository ↗](https://github.com/zeropsio/recipe-deno), a **_recipe_**, containing the most simple Deno web application. The repo will be used as a source from which the app will be built. ### 🚀 No Fuss, Just Deploy with Speed! This is the most bare-bones example of Deno app running in Zerops — as few libraries as possible, just a simple endpoint with connect, read and write to a Zerops PostgreSQL database. [Deploy "deno" recipe on Zerops](https://app.zerops.io/recipe/?lf=deno) 1. Log in/sign up to [Zerops GUI ↗](https://app.zerops.io) 2. In the **Projects** box click on **Import a project** and paste in the following YAML config ([source ↗](https://github.com/zeropsio/recipe-deno/blob/main/zerops-project-import.yaml)): ```yaml project: name: recipe-deno tags: - zerops-recipe services: - hostname: api type: deno@1 buildFromGit: https://github.com/zeropsio/recipe-deno enableSubdomainAccess: true - hostname: db type: postgresql@16 mode: NON_HA priority: 1 ``` 3. Click on **Import project** and wait until all pipelines have finished. **That's it, your application is now up and running! :star: Let's check it works:** 1. A _subdomain_ should have been enabled and visible in the project's **IP addressed & Public Routing Overview** box. Its format should look similar to this `https://api-7f6-8000.prg1.zerops.app`. 2. Click or the `subdomain` URL to open it in a browser and you should see ``` {"message":"This is a simple, basic Deno / Oak application running in Zerops.io,\n each request adds an entry to the PostgreSQL database and returns a count.\n See the source repository (https://github.com/zeropsio/recipe-deno) for more information.","newEntry":"274b0cc1-5b6d-4351-b8ec-53cf82bd9d0f","count":1} ``` :::tip Do you have any questions? Check the step-by-step tutorial, browse the documentation and join our **[Discord](https://discord.com/invite/WDvCZ54)** community to get help from our team and other members. ::: ## How to start It doesn't matter whether it's your first curious introduction to Zerops, you have already mastered the basics and are looking for a tiny detail or inspiration. Below, choose a section that fits your needs: - [Care for details?](/deno/how-to/create) — Dive in all Zerops has to offer for your Deno application. - [Deno recipes](https://github.com/zeropsio?q=deno&type=all&language=&sort=) — Get inspired by already existing repositories, ready to be imported to Zerops. ## Feature Highlights - [Create Deno service](/deno/how-to/create) — Start with creating a Deno service using GUI or zCLI. - [Zerops.yaml](/deno/how-to/build-pipeline#add-zeropsyaml-to-your-repository) — See a full example of zerops.yaml file to create your own app. - [Scaling configuration](/deno/how-to/scaling) — Set up scaling of your Deno application so that it runs smoothly while using only necessary resources. {" "} - [Customize build environment](/deno/how-to/build-process#customize-build-environment) - [Customize runtime environment](/deno/how-to/customize-runtime) ## When in doubt, reach out Don't know how to start or got stuck during the process? You might not be the first one, visit the FAQ section to find out. In case you haven't found an answer (and also if you have), we and our community are looking forward to hearing from you on Discord. Have you build something that others might find useful? Don't hesitate to share your knowledge! - [Discord](https://discord.com/invite/WDvCZ54) — Join our core team and Zerops community on Discord. Ask questions and share your tips with other members. ## Popular Guides - [zCLI](/references/cli) — Get even more out of Zerops with the zCLI command line tool. - [Zerops VPN](/references/networking/vpn) — Connect to your services easily with Zerops VPN. ---------------------------------------- # Docker > Overview Zerops provides Docker support through dedicated Virtual Machine (VM) environments, ensuring maximum compatibility and isolation while maintaining integration with the broader Zerops ecosystem. This guide explains how to effectively use Docker services in Zerops, including best practices and important considerations. ## Why VMs While Zerops primarily uses native Linux containers for optimal performance, this VM-based approach allows you to run virtually any Docker container while maintaining Zerops' robust infrastructure management. You can learn more about [differences](/features/container-vs-vm) between Containers and Virtual Machines in Zerops. Before using Docker services, consider these important aspects: ### Virtual Machine Environment Docker services in Zerops operate in a full VM environment, which has several implications: - **Slower Boot Times**: VMs require more time to initialize due to full kernel boot - **Higher Resource Usage**: VMs include additional system overhead compared to native containers - **Scaling Limitations**: - Vertical scaling requires VM restart - Resources must be set as fixed values (no min-max ranges) - Zerops automatically restarts the VM when resource values are changed in UI - **Storage Management**: Disk space can only be increased, not decreased without recreation - **Build Phase Limitations**: Build phase runs in containers, not in the VM environment ### Advantages Despite these limitations, Docker services offer some benefits: - **Broad Compatibility**: Run almost any Docker container with minimal modification - **Familiar Environment**: Standard Docker runtime environment ## Configuration Guide ### Supported Version Currently supported Docker versions: ### Basic Structure Docker services in Zerops are configured through the `zerops.yaml` file. Here's a typical configuration pattern: ```yaml title="zerops.yaml" zerops: - setup: app run: base: docker@latest prepareCommands: - docker image pull : # Always use specific version tags start: docker run --network=host : ports: - port: httpSupport: true ``` :::important Always use specific version tags (like `1.0.0`) instead of `:latest`. Zerops caches the `prepareCommands` output, which means a new `:latest` image won't be automatically pulled on subsequent deployments unless the cache is manually cleared or the commands change. ::: Refer to the [Docker recipe repository](https://github.com/zeropsio/recipe-docker) for an example configuration. :::note We are actively working on improving the speed of image caching after `run.prepareCommands` and reducing the startup time of runtime VMs. These improvements will be released in future updates. ::: ### Network Configuration Docker services require the `--network=host` flag for proper integration with Zerops: - **Direct Port Management**: Ports are managed through `zerops.yaml` - **Simplified Configuration**: Avoids double port exposure in Docker and Zerops - **Native Performance**: Direct access to host networking ### Docker Compose Support For projects using Docker Compose, additional configuration is required: 1. **File Deployment**: ```yaml title="zerops.yaml" build: # base cannot be docker — build phase runs in containers, not VMs deployFiles: ./docker-compose.yaml addToRunPrepare: ./docker-compose.yaml ``` 2. **Network Mode**: ```yaml title="docker-compose.yaml" services: your-service: image: your-image:1.0.0 network_mode: host ``` 3. **Start Command**: ```yaml title="zerops.yaml" run: start: docker compose up --force-recreate ``` ### Environment Variables When using Docker services, there's an additional layer to consider since environment variables defined in Zerops must be explicitly passed to your Docker containers. #### 1. Defining Variables in Zerops Define your environment variables in the `run.envVariables` section of your `zerops.yaml` (example uses [referenced](/features/env-variables#referencing-variables) variables): ```yaml title="zerops.yaml" zerops: - setup: app run: base: docker@latest envVariables: DB_HOST: ${db_hostname} DB_PORT: ${db_port} ``` #### 2. Passing Variables to Docker Containers For single containers, pass variables using the `-e` flag: ```yaml title="zerops.yaml" run: base: docker@latest prepareCommands: - docker image pull my-application:1.0.0 # Use specific version tags, not :latest start: docker run -e DB_HOST -e DB_PORT --network=host my-application:1.0.0 ``` :::important Always use specific version tags (like `1.0.0`) instead of `:latest`. Zerops caches the `prepareCommands` output, which means a new `:latest` image won't be automatically pulled on subsequent deployments unless the cache is manually cleared or the commands change. ::: For Docker Compose setups, pass environment variables in your `docker-compose.yaml`: ```yaml title="docker-compose.yaml" services: api: image: my-application:1.0.0 network_mode: host environment: - DB_HOST - DB_PORT ``` ## Implementation Examples ### Single Container ```yaml title="zerops.yaml" zerops: - setup: app run: base: docker@latest prepareCommands: - docker image pull crccheck/hello-world:1.0.0 # Always use specific version tags start: docker run --network=host crccheck/hello-world:1.0.0 ports: - port: 8000 httpSupport: true ``` :::important Always use specific version tags (like `1.0.0`) instead of `:latest`. Zerops caches the `prepareCommands` output, which means a new `:latest` image won't be automatically pulled on subsequent deployments unless the cache is manually cleared or the commands change. ::: ### Single Service with Docker Compose ```yaml title="zerops.yaml" zerops: - setup: api build: # base cannot be docker — build phase runs in containers, not VMs deployFiles: ./docker-compose.yaml addToRunPrepare: ./docker-compose.yaml run: base: docker@latest prepareCommands: - docker compose pull api start: docker compose up api --force-recreate ports: - port: 8000 httpSupport: true ``` ```yaml title="docker-compose.yaml (excerpt)" services: api: image: your-image:1.0.0 network_mode: host # other configuration... ``` ### Multiple Services with Docker Compose ```yaml title="zerops.yaml" zerops: - setup: apps build: # base cannot be docker — build phase runs in containers, not VMs deployFiles: ./docker-compose.yaml addToRunPrepare: ./docker-compose.yaml run: base: docker@latest prepareCommands: - docker compose pull start: docker compose up --force-recreate ports: - port: 8000 httpSupport: true ``` ```yaml title="docker-compose.yaml (excerpt)" services: web: image: web-image:1.0.0 network_mode: host # other configuration... api: image: api-image:1.0.0 network_mode: host # other configuration... ``` ## Best Practices #### Image Management - **Always use specific version tags** instead of `:latest` - This prevents caching issues as Zerops caches `prepareCommands` output #### Resource Planning - Account for VM overhead in resource allocation - Plan for longer initialization times - Consider the impact on scaling operations #### Migration Consideration - Evaluate if your workload could run on native containers - Consider gradual migration for complex applications - Balance development effort against operational benefits ## Limitations and Workarounds ### Build Phase Since the build phase runs in containers rather than VMs: - Use `run.prepareCommands` for Docker-specific build steps - Consider external CI/CD for complex Docker builds - Leverage pre-built images when possible ### Scaling Operations Docker services in Zerops have specific scaling characteristics that differ from native containers: #### Vertical Scaling - Resources must be defined with **fixed** values instead of min-max ranges - CPU, RAM, and disk are specified as single values: ```yaml verticalAutoscaling: cpu: 3 ram: 2 disk: 20 ``` - Any change to these values through the UI triggers an automatic VM restart - Plan your resource allocation carefully to minimize scaling operations #### Horizontal Scaling - Still supports multiple containers through `minContainers` and `maxContainers` - Consider breaking large services into smaller components - Implement proper health checks for reliable scaling - Use horizontal scaling when possible to avoid VM restarts ---------------------------------------- # Dotnet > How To > Build Pipeline Zerops provides a customizable build and runtime environment for your .NET application. ## Add zerops.yaml to your repository Start by adding `zerops.yaml` file to the **root of your repository** and modify it to fit your application: ```yaml zerops: # define hostname of your service - setup: app # ==== how to build your application ==== build: # REQUIRED. Set the base technology for the build environment: base: dotnet@6 # OPTIONAL. Set the operating system for the build environment. # os: ubuntu # OPTIONAL. Customize the build environment by installing additional packages # or tools to the base build environment. # prepareCommands: # - sudo apt-get something # - curl something else # OPTIONAL. Build your application buildCommands: - npm i - npm run build # REQUIRED. Select which files / folders to deploy after # the build has successfully finished deployFiles: - dist - package.json - node_modules # OPTIONAL. Which files / folders you want to cache for the next build. # Next builds will be faster when the cache is used. cache: node_modules # ==== how to run your application ==== run: # OPTIONAL. Sets the base technology for the runtime environment: base: dotnet@latest # OPTIONAL. Sets the internal port(s) your app listens on: ports: # port number - port: 5000 # OPTIONAL. Customize the runtime .NET environment by installing additional # dependencies to the base .NET runtime environment. # prepareCommands: # - sudo apt-get something # - curl something else # OPTIONAL. Run one or more commands each time a new runtime container # is started or restarted. These commands are triggered before # your .NET application is started. # initCommands: # - rm -rf ./cache # REQUIRED. Your .NET application start command start: npm start ``` The top-level element is always `zerops`. ### Setup The first element `setup` contains the **hostname** of your service. A runtime service with the same hostname must exist in Zerops. Zerops supports the definition of multiple runtime services in a single `zerops.yaml`. This is useful when you use a monorepo. Just add multiple setup elements in your `zerops.yaml`: ```yaml zerops: # definition for app service - setup: app # optional build: ... # optional deploy: ... # required run: ... # definition for api service - setup: api # optional build: ... # optional deploy: ... # required run: ... ``` Each service configuration contains at least the `run` section. Optional `build` and `deploy` sections can be added to further customize your process. ## Build pipeline configuration ### base _REQUIRED._ Sets the base technology for the build environment. Following options are available for .NET builds: - `dotnet@10`, `dotnet@latest` - `dotnet@9` - `dotnet@8` - `dotnet@7` - `dotnet@6` ```yaml zerops: # hostname of your service - setup: app # ==== how to build your application ==== build: # REQUIRED. Sets the base technology for the build environment: base: dotnet@6 ... ```

The base build environment contains {data.alpine.default}, the selected major version of .NET, [Zerops command line tool](/references/cli), `ASP .NET` and `git`.

:::info You can change the base environment when you need to. Just simply modify the `zerops.yaml` in your repository. ::: If you need to install more technologies to the build environment, set multiple values as a yaml array. For example: ```yaml zerops: # hostname of your service - setup: app # ==== how to build your application ==== build: # REQUIRED. Sets the base technology for the build environment: base: - dotnet@6 prepareCommands: - zsc add go@latest ... ``` See the full list of supported [build base environments](/zerops-yaml/base-list#runtime-services). To customize your build environment use the [prepareCommands](#preparecommands) attribute. :::note Modifying the base technology will invalidate your build cache. See our [Build Cache Documentation](/features/build-cache) for more details about cache invalidation. ::: ### os _OPTIONAL._ Sets the operating system for the build environment. Following options are available: - `alpine` - `ubuntu` Default value is `alpine`. We are currently using following os version: - {data.alpine.default} - {data.ubuntu.default} :::caution The os version is fixed and cannot be customized. ::: :::note Changing the OS setting will invalidate your build cache. See our [Build Cache Documentation](/features/build-cache) for details about cache behavior. ::: ### prepareCommands _OPTIONAL._ Customizes the build environment by installing additional dependencies or tools to the base build environment. The base build environment contains: - {data.alpine.default} - selected version of .NET defined in the [base](#base) attribute - [Zerops command line tool](/references/cli) - `ASP .NET` and `git` To install additional packages or tools add one or more prepare commands: ```yaml zerops: # hostname of your service - setup: app # ==== how to build your application ==== build: # REQUIRED. Set the base technology for the build environment: base: dotnet@6 # OPTIONAL. Customize the build environment by installing additional packages # or tools to the base build environment. prepareCommands: - sudo apt-get something - curl something else ... ``` When the first build is triggered, Zerops will 1. create a build container 2. download your application code from your repository 3. run the prepare commands in the defined order The application code is available in `/build/source` before the prepare commands are triggered, so you can use any file from your repository in your prepare commands (e.g. a configuration file). The commands themselves run in the `/home/zerops` directory. :::note These commands are skipped when using cached environment. Modifying `prepareCommands` will invalidate your build cache. See our [Build Cache Documentation](/features/build-cache) for details about cache invalidation. ::: #### Command exit code If any command fails, it returns an exit code other than 0 and the build is canceled. Read the [build log](/dotnet/how-to/logs#build-log) to troubleshoot the error. If the command ends successfully, it returns the exit code 0 and Zerops triggers the following command. When all prepare commands are finished, your custom build environment is ready for the build phase. #### Single or separated shell instances You can configure your prepare commands to be run in a single shell instance or multiple shell instances. The format is identical to [build commands](#buildcommands). ### buildCommands _OPTIONAL._ Defines build commands. ```yaml zerops: # hostname of your service - setup: app # ==== how to build your application ==== build: # REQUIRED. Set the base technology for the build environment: base: dotnet@6 # OPTIONAL. Build your application buildCommands: - dotnet build -o app ... ``` Build commands are optional. Zerops triggers each command in the defined order in a dedicated build container, running from the `/build/source` directory. Before the build commands are triggered the build container contains: 1. base environment defined by the [base](#base) attribute 2. optional customisation of the base environment defined in the [prepareCommands](#preparecommands) attribute 3. your application code #### Run build commands as a single shell instance Use following syntax to run all commands in the same environment context. For example, if one command changes the current directory, the next command continues in that directory. When one command creates an environment variable, the next command can access it. ```yaml buildCommands: - | sudo apt-get -y install dotnet-runtime-6.0 aspnetcore-runtime-6.0 dotnet-sdk-6.0 # already installed for .NET service dotnet build -o app ``` #### Run build commands as a separate shell instances When the following syntax is used, each command is triggered in a separate environment context. For example, each shell instance starts in the home directory again. When one command creates an environment variable, it won't be available for the next command. ```yaml buildCommands: - sudo apt-get -y install dotnet-runtime-6.0 aspnetcore-runtime-6.0 dotnet-sdk-6.0 # already installed for .NET service - dotnet build -o app ``` #### Command exit code If any command fails, it returns an exit code other than 0 and the build is canceled. Read the [build log](/dotnet/how-to/logs#build-log) to troubleshoot the error. If the error log doesn't contain any specific error message, try to run your build with the `--verbosity ` option. ```yaml buildCommands: - dotnet build --verbosity detailed ``` If the command ends successfully, it returns the exit code 0 and Zerops triggers the following command. When all `buildCommands` are finished, the application build is completed and ready for the deploy phase. ### deployFiles _REQUIRED._ Selects which files or folders will be deployed after the build has successfully finished. To filter out specific files or folders, use [`.deployignore`](#deployignore) file. ```yaml # REQUIRED. Select which files / folders to deploy after # the build has successfully finished deployFiles: - app ``` Determines files or folders produced by your build, which should be deployed to your runtime service containers. The path starts from the **root directory** of your project (the location of `zerops.yaml`). You must enclose the name in quotes if the folder or the file name contains a space. 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`. #### Examples Deploys a folder, and a file from the project root directory: ```yaml deployFiles: - app - file.txt ``` Deploys the whole content of the build container: ```yaml deployFiles: . ``` Deploys a folder, and a file in a defined path: ```yaml deployFiles: - ./path/to/file.txt - ./path/to/dir/ ``` #### How to use a wildcard in the path 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/` ```yaml deployFiles: ./path/~/to/file.txt ``` Deploys all folders that are located in any path that begins with `/path/to/` ```yaml deployFiles: ./path/to/~/ ``` Deploys all folders that are located in any path that begins with `/path/` and ends with `/to/` ```yaml deployFiles: ./path/~/to/ ``` :::note Example 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`](https://git-scm.com/docs/gitignore#_pattern_format). 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: ```yaml title="zerops.yaml" zerops: - setup: app build: deployFiles: ./ ``` ```text title=".deployignore" /src/file.txt ``` The example above ignores `file.txt` only in the root src directory. ```text title=".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`](/references/zcli/commands#deploy) command. ::: ### cache _OPTIONAL._ Defines which files or folders will be cached for the next build. ```yaml # OPTIONAL. Which files / folders you want to cache for the next build. # Next builds will be faster when the cache is used. cache: file.txt ``` The cache attribute helps optimize build times by preserving specified files between builds. The cache attribute supports the [~ wildcard character](#how-to-use-a-wildcard-in-the-path). Learn more about the [build cache system](/features/build-cache) in Zerops. ### envVariables _OPTIONAL._ Defines the environment variables for the build environment. Enter one or more env variables in following format: ```yaml zerops: # define hostname of your service - setup: app # ==== how to build your application ==== build: base: dotnet@6 … # OPTIONAL. Defines the env variables for the build environment: envVariables: DOTNET_ENV: production DB_NAME: db DB_HOST: db DB_USER: db DB_PASS: ${db_password} ``` Read more about [environment variables](/dotnet/how-to/env-variables) in Zerops. ## Runtime configuration ### base _OPTIONAL._ Sets the base technology for the runtime environment. If you don't specify the `run.base` attribute, Zerops keeps the current .NET version for your runtime. Following options are available for .NET builds: - `dotnet@10`, `dotnet@latest` - `dotnet@9` - `dotnet@8` - `dotnet@7` - `dotnet@6` ```yaml zerops: # hostname of your service - setup: app # ==== how to build your application ==== build: # REQUIRED. Sets the base technology for the build environment: base: dotnet@6 ... # ==== how to run your application ==== run: # OPTIONAL. Sets the base technology for the runtime environment: base: dotnet@6 ... ```

The base runtime environment contains {data.alpine.default}, the selected major version of .NET, [Zerops command line tool](/references/cli) and `ASP .NET` and `git`.

:::info You can change the base environment when you need to. Just simply modify the `zerops.yaml` in your repository. ::: If you need to install more technologies to the runtime environment, set multiple values as a yaml array. For example: ```yaml zerops: # hostname of your service - setup: app # ==== how to build your application ==== build: # REQUIRED. Sets the base technology for the build environment: base: dotnet@6 ... # ==== how to run your application ==== run: # OPTIONAL. Sets the base technology for the runtime environment: base: - dotnet@6 prepareCommands: - zsc add go@latest ... ``` See the full list of supported [run base environments](/zerops-yaml/base-list). To customise your build environment use the `prepareCommands` attribute. ### os _OPTIONAL._ Sets the operating system for the runtime environment. Following options are available: - `alpine` - `ubuntu` Default value is `alpine`. We are currently using following os version: - {data.alpine.default} - {data.ubuntu.default} :::caution The os version is fixed and cannot be customised. ::: ### ports _OPTIONAL._ Specifies one or more internal ports on which your application will listen. Projects in Zerops represent a group of one or more services. Services can be of different types (runtime services, databases, message brokers, object storage, etc.). All services of the same project share a **dedicated private network**. To connect to a service within the same project, just use the service hostname and its internal port. For example, to connect to a .NET service with hostname = "app" and port = 5000 from another service of the same project, simply use `app:5000`. Read more about [how to access a .NET service](/references/networking/internal-access#basic-service-communication). Each port has following attributes:
Parameter Description
port Defines the port number. You can set any port number between 10 and 65435. Ports outside this interval are reserved for internal Zerops systems.
protocol Optional. Defines the protocol. Allowed values are TCP or UDP. Default value is TCP.
httpSupport Optional. httpSupport = true is the default setting for TCP protocol. Set httpSupport = false if a web server isn't running on the port. Zerops uses this information for the configuration of [public access](/features/access). httpSupport = true is available only in combination with the TCP protocol.
### prepareCommands _OPTIONAL._ Customises the .NET runtime environment by installing additional dependencies or tools to the runtime base environment.

The base .NET environment contains {data.alpine.default}, the selected major version of .NET, [Zerops command line tool](/references/cli) and `ASP .NET` and `git`. To install additional packages or tools add one or more prepare commands:

```yaml zerops: # hostname of your service - setup: app # ==== how to build your application ==== build: ... # ==== how to run your application ==== run: # OPTIONAL. Customise the runtime environment by installing additional packages # or tools to the base .NET runtime environment. prepareCommands: - sudo apt-get something - curl something else ... ``` When the first deploy with a defined prepare attribute is triggered, Zerops will 1. create a prepare runtime container 2. optionally: [copy selected folders or files from your build container](#copy-folders-or-files-from-your-build-container) 3. run the `prepareCommands` commands in the defined order :::note `run.prepareCommands` run in the `/home/zerops` directory. ::: #### Command exit code If any command fails, it returns an exit code other than 0 and the deploy is canceled. Read the [prepare runtime log](/dotnet/how-to/logs#prepare-runtime-log) to troubleshoot the error. If the command ends successfully, it returns the exit code 0 and Zerops triggers the following command. When all `prepareCommands` commands are finished, your custom runtime environment is ready for the deploy phase. #### Cache of your custom runtime environment Some packages or tools can take a long time to install. Therefore, Zerops caches your custom runtime environment after the installation of your custom packages or tools is completed. When the second or following deploy is triggered, Zerops will use the custom runtime cache from the previous deploy if following conditions are met: 1. Content of the [build.addToRunPrepare](#copy-folders-or-files-from-your-build-container) and `run.prepareCommands` attributes didn't change from the previous deploy 2. The custom runtime cache wasn't invalidated in the Zerops GUI. To invalidate the Zerops runtime cache go to your service detail in Zerops GUI, choose **Service dashboard & runtime containers** from the left menu and click on the **Open pipeline detail** button. Then click on the **Clear runtime prepare cache** button. When the prepare cache is used, Zerops doesn't create a prepare runtime container and executes the deployment of your application directly. #### Single or separated shell instances You can configure your prepare commands to be run in a single shell instance or multiple shell instances. The format is identical to [build commands](#buildcommands). ### Copy folders or files from your build container

The prepare runtime container contains {data.alpine.default}, the selected major version of .NET, [Zerops command line tool](/references/cli) and `ASP .NET` and `git`.

The prepare runtime container does not contain your application code nor the built application. If you need to copy some folders or files from the build container to the runtime container (e.g. a configuration file) use the `addToRunPrepare` attribute in the [build section](#build-pipeline-configuration). ```yaml zerops: # hostname of your service - setup: app # ==== how to build your application ==== build: ... addToRunPrepare: ./runtime-config.yaml # ==== how to run your application ==== run: # OPTIONAL. Customise the runtime environment by installing additional packages # or tools to the base .NET runtime environment. prepareCommands: - sudo apt-get something - curl something else ... ``` In the example above Zerops will copy the `runtime-config.yaml` file from your build container **after the build has finished** into the new **prepare runtime** container. The copied files and folders will be available in the `/home/zerops` folder in the new prepare runtime container before the prepare commands are triggered. ### initCommands _OPTIONAL._ Defines one or more commands to be run each time a new runtime container is started or a container is restarted. ```yaml zerops: # hostname of your service - setup: app # ==== how to build your application ==== build: ... # ==== how to run your application ==== run: # OPTIONAL. Run one or more commands each time a new runtime container # is started or restarted. These commands are triggered before # your .NET application is started. initCommands: - rm -rf ./cache ``` These commands are triggered in the runtime container before your .NET application is started via the [start command](#start). :::note `run.initCommands` run in the `/var/www` directory. ::: Use init commands to clean or initialise your application cache or similar operations. :::caution The init commands will delay the start of your application each time a new runtime container is started (including the horizontal [scaling](/dotnet/how-to/scaling) or when a runtime container is restarted). Do not use the init commands for customising your runtime environment. Use the [run:prepareCommands](#preparecommands-1) attribute instead. ::: #### Command exit code If any of the `initCommands` fails, it returns an exit code other than 0, but deploy is **not** canceled. After all init commands are finished, regardless of the status code, the application is started. Read the [runtime log](/dotnet/how-to/logs#runtime-log) to troubleshoot the error. #### Single or separated shell instances You can configure your `initCommands` to be run in a single shell instance or multiple shell instances. The format is identical to [build commands](#buildcommands). ### envVariables _OPTIONAL._ Defines the environment variables for the runtime environment. Enter one or more env variables in following format: ```yaml zerops: # define hostname of your service - setup: app # ==== how to run your application ==== run: # OPTIONAL. Defines the env variables for the runtime environment: envVariables: DOTNET_ENV: production DB_NAME: db DB_HOST: db DB_USER: db DB_PASS: ${db_password} ``` Read more about [environment variables](/dotnet/how-to/env-variables) in Zerops. ### start _REQUIRED._ Defines the start command for your .NET application. ```yaml zerops: # hostname of your service - setup: app # ==== how to build your application ==== build: ... # ==== how to run your application ==== run: # REQUIRED. Your .NET application start command start: cd app && dotnet dnet.dll ``` ### health check _OPTIONAL._ Defines a health check. `healthCheck` requires either one `httpGet` object or one `exec` object. #### httpGet Configures the health check to request a local URL using a HTTP GET method. Following attributes are available:
Parameter Description
port Defines the port of the HTTP GET request. The readiness check will trigger a GET request on {'http://127.0.0.1:{port}/{path}'}
path Defines the URL path of the HTTP GET request. The readiness check will trigger a GET request on {'http://127.0.0.1:{port}/{path}'}
host Optional. The readiness check is triggered from inside of your runtime container so it always uses the localhost 127.0.0.1. If you need to add a host to the request header, specify it in the host attribute.
scheme Optional. The readiness check is triggered from inside of your runtime container so no https is required. If your application requires a https request, set scheme: https
**Example:** ```yaml zerops: # hostname of your service - setup: app # ==== how to build your application ==== build: ... # ==== how to run your application ==== run: # REQUIRED. Your .NET application start command start: cd app && dotnet dnet.dll # OPTIONAL. Define a health check with a HTTP GET request option. # Configures the check on http://127.0.0.1:80/status healthCheck: httpGet: port: 80 path: /status ``` #### exec Configures the health check to run a local command. Following attributes are available:
Parameter Description
command Defines a local command to be run. The command has access to the same [environment variables](/dotnet/how-to/create#set-secret-environment-variables) as your .NET application. A single string is required. If you need to run multiple commands create a shell script or, use a multiline format as in the example below.
**Example:** ```yaml zerops: # hostname of your service - setup: app # ==== how to build your application ==== build: ... # ==== how to run your application ==== run: # REQUIRED. Your .NET application start command start: cd app && dotnet dnet.dll # OPTIONAL. Define a health check with a shell command. healthCheck: exec: command: | touch grass rm -rf life mv /outside/user /home/user ``` ### crontab _OPTIONAL._ Defines cron jobs. Setup cron jobs in the following format: ```yaml zerops: # define hostname of your service - setup: app # ==== how to run your application ==== run: crontab: # REQUIRED. Sets the command to execute: - command: "" # REQUIRED. Sets the interval time to execute: timing: "0 * * * *" ``` Read more about setting up [cron](/zerops-yaml/cron) in Zerops. ## Deploy configuration ### readiness check _OPTIONAL._ Defines a readiness check. Read more about how the [readiness check works](/dotnet/how-to/deploy-process#readiness-checks) in Zerops. `readinessCheck` requires either one `httpGet` object or one `exec` object. #### httpGet Configures the readiness check to request a local URL using a http GET method. Following attributes are available:
Parameter Description
port Defines the port of the HTTP GET request. The readiness check will trigger a GET request on {'http://127.0.0.1:{port}/{path}'}
path Defines the URL path of the HTTP GET request. The readiness check will trigger a GET request on {'http://127.0.0.1:{port}/{path}'}
host Optional. The readiness check is triggered from inside of your runtime container so it always uses the localhost 127.0.0.1. If you need to add a host to the request header, specify it in the host attribute.
scheme Optional. The readiness check is triggered from inside of your runtime container so no https is required. If your application requires a https request, set scheme: https
**Example:** ```yaml zerops: # hostname of your service - setup: app # ==== how to build your application ==== build: ... # ==== how to deploy your application ==== deploy: # OPTIONAL. Define a readiness check with a HTTP GET request option. # Configures the check on http://127.0.0.1:80/status readinessCheck: httpGet: port: 80 path: /status # ==== how to run your application ==== run: ... ``` Read more about how the [readiness check works](/dotnet/how-to/deploy-process#readiness-checks) in Zerops. #### exec Configures the readiness check to run a local command. Following attributes are available:
Parameter Description
command Defines a local command to be run. The command has access to the same [environment variables](/dotnet/how-to/create#set-secret-environment-variables) as your .NET application. A single string is required. If you need to run multiple commands create a shell script or, use a multiline format as in the example below.
**Example:** ```yaml zerops: # hostname of your service - setup: app # ==== how to build your application ==== build: ... # ==== how to deploy your application ==== deploy: # OPTIONAL. Define a readiness check with a HTTP GET request option. # Configures the check on http://127.0.0.1:80/status readinessCheck: exec: command: | touch grass rm -rf life mv /outside/user /home/user ``` Read more about how the [readiness check works](/dotnet/how-to/deploy-process#readiness-checks) in Zerops. ---------------------------------------- # Dotnet > How To > Build Process ---------------------------------------- # Dotnet > How To > Controls ---------------------------------------- # Dotnet > How To > Create Zerops provides a .NET runtime service with extensive build support. .NET runtime is highly scalable and customisable to suit both development and production. ## Create .NET service using Zerops GUI First, set up a project in Zerops GUI. Then go to the project dashboard page and choose **Add new service** in the left menu in the **Services** block. Then add a new .NET service: [Video: /vids/services/dotnet.webm](/vids/services/dotnet.webm) ### Choose .NET version Following .NET versions are currently supported: :::info You can [change](/dotnet/how-to/upgrade) the major version at any time later. ::: ### Set a hostname Enter a unique service identifier like "app","cache", "gui" etc. Duplicate services with the same name in the same project are forbidden. #### Limitations: - maximum 25 characters - must contain only lowercase ASCII letters (a-z) or numbers (0-9) :::caution The hostname is fixed after the service is created. It can't be changed later. ::: ### Set secret environment variables Add environment variables with sensitive data, such as password, tokens, salts, certificates etc. These will be securely saved inside Zerops and added to your runtime service upon start. Setting the secret environment variables is optional. You can set them later in Zerops GUI. Read more about [different types of env variables](/dotnet/how-to/env-variables#service-env-variables) in Zerops. ## Create .NET service using zCLI zCLI is the Zerops command-line tool. To create a new .NET service via the command-line, follow these steps: 1. [Install & setup zCLI](/references/cli) 2. [Create a project description file](/dotnet/how-to/create#create-a-project-description-file) 3. [Create a project with a .NET and PostgreSQL service](#full-example) ### Create a project description file Zerops uses a yaml format to describe the project infrastructure. #### Basic example: Create a directory `my-project`. Create an `description.yaml` file inside the `my-project` directory with following content: ```yaml # basic project data project: # project name name: my-project # array of project services services: - # service name hostname: app # service type and version number in dotnet@6 format type: dotnet@6 # defines the minimum number of containers for horizontal autoscaling minContainers: 1 # defines the maximum number of containers for horizontal autoscaling. Max value = 6. maxContainers: 6 # optional: create env variables envSecrets: S3_ACCESS_KEY_ID: 'P8cX1vVVb' S3_ACCESS_SECRET: 'ogFthuiLYki8XoL73opSCQ' ``` The yaml file describes your future project infrastructure. The project will contain one .NET version 6 service with default [auto scaling](/dotnet/how-to/scaling) configuration. Hostname will be set to "app", the internal port(s) the service listens on will be defined later in the [zerops.yaml](/dotnet/how-to/build-pipeline#ports). Following secret env variables will be configured: ```env S3_ACCESS_KEY_ID="P8cX1vVVb" S3_ACCESS_SECRET="ogFthuiLYki8XoL73opSCQ" ``` #### Full example: Create a directory my-project. Create an description.yaml file inside the my-project directory with following content: ```yaml # basic project data project: # project name name: my-project # optional: project description description: A project with a .NET and PostgreSQL database # optional: project tags tags: - DEMO - ZEROPS # array of project services services: - # service name hostname: app # service type and version number in dotnet@6 format type: dotnet@6 # optional: vertical auto scaling customization verticalAutoscaling: cpuMode: DEDICATED minCpu: 2 maxCpu: 5 minRam: 2 maxRam: 24 minDisk: 6 maxDisk: 50 startCpuCoreCount: 3 minFreeRamGB: 0.5 minFreeRamPercent: 20 # defines the minimum number of containers for horizontal autoscaling. Max value = 6. minContainers: 2 # defines the maximum number of containers for horizontal autoscaling. Max value = 6. maxContainers: 4 # optional: create secret env variables envSecrets: S3_ACCESS_KEY_ID: 'P8cX1vVVb' S3_ACCESS_SECRET: 'ogFthuiLYki8XoL73opSCQ' - # second service hostname hostname: db # service type and version number in postgresql@{version} format type: postgresql@12 # mode of operation "HA"/"non_HA" mode: NON_HA ``` The yaml file describes your future project infrastructure. The project will contain a .NET service and a [PostgreSQL](/postgresql/overview) service. .NET service with "app" hostname, the internal port(s) the service listens on will be defined later in the [zerops.yaml](/dotnet/how-to/build-pipeline#ports). .NET service will run on version 6 with a custom vertical and horizontal scaling. Following secret env variables will be configured: ```env S3_ACCESS_KEY_ID="P8cX1vVVb" S3_ACCESS_SECRET="ogFthuiLYki8XoL73opSCQ" ``` The hostname of the PostgreSQL service will be set to "db". The [single container](/features/scaling#single-container-mode)(/features/scaling#deployment-modes-databases-and-shared-storage) mode will be chosen and the default auto [scaling configuration](/postgresql/how-to/scale#configure-scaling) will be set. #### Description of description.yaml parameters The `project:` section is required. Only one project can be defined.
Parameter Description Limitations
name The name of the new project. Duplicates are allowed.
description Optional. Description of the new project. Maximum 255 characters.
tags Optional. One or more string tags. Tags do not have a functional meaning, they only provide better orientation in projects.
At least one service in `services:` section is required. You can create a project with multiple services. The example above contains .NET and PostgreSQL services but you can create a `description.yaml` with your own combination of [services](/features/infrastructure).
Parameter Description
hostname The unique service identifier. The hostname of the new database will be set to the `hostname` value. Limitations:
  • duplicate services with the same name in the same project are forbidden
  • maximum 25 characters
  • must contain only lowercase ASCII letters (a-z) or numbers (0-9)
type Specifies the service type and version. See what [.NET service types](/references/import-yaml/type-list#runtime-services) are currently supported.
verticalAutoscaling Optional. Defines [custom vertical auto scaling parameters](/dotnet/how-to/create#set-auto-scaling-configuration). All verticalAutoscaling attributes are optional. Not specified attributes will be set to their default values.
- cpuMode Optional. Accepts `SHARED`, `DEDICATED` values. Default is `SHARED`
- minCpu/maxCpu Optional. Set the minCpu or maxCpu in CPU cores (integer).
- minRam/maxRam Optional. Set the minRam or maxRam in GB (float).
- minDisk/maxDisk Optional. Set the minDisk or maxDisk in GB (float).
minContainers Optional. Default = 1. Defines the minimum number of containers for [horizontal autoscaling](/dotnet/how-to/create#horizontal-auto-scaling). Limitations: Current maximum value = 10.
maxContainers Defines the maximum number of containers for [horizontal autoscaling](/dotnet/how-to/create#horizontal-auto-scaling). Limitations: Current maximum value = 10.
envSecrets Optional. Defines one or more secret env variables as a key value map. See env variable [restrictions](/dotnet/how-to/env-variables#env-variable-restrictions).
### Create a project based on the description.yaml When you have your `description.yaml` ready, use the `zcli project project-import` command to create a new project and the service infrastructure. ```sh Usage: zcli project project-import importYamlPath [flags] Flags: -h, --help Help for the project import command. --org-id string If you have access to more than one organization, you must specify the org ID for which the project is to be created. --working-dir string Sets a custom working directory. Default working directory is the current directory. (default "./") ``` Zerops will create a project and one or more services based on the `description.yaml` content. Maximum size of the `description.yaml` file is 100 kB. You don't specify the project name in the `zcli project project-import` command, because the project name is defined in the `description.yaml`. If you have access to more than one client, you must specify the client ID for which the project is to be created. The `clientID` is located in the Zerops GUI under the client name on the project dashboard page. ### Add .NET service to an existing project #### Example: Create a directory `my-project` if it doesn't exist. Create an `import.yaml` file inside the `my-project` directory with following content: ```yaml # basic project data project: # project name name: my-project # array of project services services: - # service name hostname: app # service type and version number in dotnet@6 format type: dotnet@6 # defines the minimum number of containers for horizontal autoscaling minContainers: 1 # defines the maximum number of containers for horizontal autoscaling. Max value = 6. maxContainers: 6 # optional: create env variables envSecrets: S3_ACCESS_KEY_ID: 'P8cX1vVVb' S3_ACCESS_SECRET: 'ogFthuiLYki8XoL73opSCQ' ``` The yaml file describes the list of one or more services that you want to add to your existing project. In the example above, one .NET service version 6 with default [auto scaling](/dotnet/how-to/scaling) configuration will be added to your project. Hostname of the new service will be set to `app`. Following secret env variables will be configured: ```env S3_ACCESS_KEY_ID="P8cX1vVVb" S3_ACCESS_SECRET="ogFthuiLYki8XoL73opSCQ" ``` The content of the `services:` section of `import.yaml` is identical to the project description file. The `import.yaml` never contains the `project:` section because the project already exists. When you have your `import.yaml` ready, use the `zcli project service-import` command to add one or more services to your existing Zerops project. ```sh Usage: zcli project service-import importYamlPath [flags] Flags: -h, --help Help for the project service import command. -P, --project-id string If you have access to more than one project, you must specify the project ID for which the command is to be executed. ``` zCLI commands are interactive, when you press enter after `zcli project service-import importYamlPath`, you will be given a list of your projects to choose from. Maximum size of the import.yaml file is 100 kB. ---------------------------------------- # Dotnet > How To > Customize Runtime ---------------------------------------- # Dotnet > How To > Deploy Process ---------------------------------------- # Dotnet > How To > Env Variables ---------------------------------------- # Dotnet > How To > Filebrowser ---------------------------------------- # Dotnet > How To > Logs ---------------------------------------- # Dotnet > How To > Scaling ---------------------------------------- # Dotnet > How To > Shared Storage ---------------------------------------- # Dotnet > How To > Trigger Pipeline ---------------------------------------- # Dotnet > How To > Upgrade ---------------------------------------- # Dotnet > Overview [.NET ↗](https://dotnet.microsoft.com/en-us/) is the free, open-source, cross-platform framework for building modern apps and powerful cloud services.. As said, there is no need for coding yet, we have created a [Github repository ↗](https://github.com/zeropsio/recipe-dotnet-hello-world), a **_recipe_**, containing the most simple .NET web application. The repo will be used as a source from which the app will be built. ### 🚀 Feel free to deploy the recipe yourself This is the most bare-bones example of .NET running in Zerops — as few libraries as possible, just a simple endpoint with connect, read and write to a Zerops PostgreSQL database. [Deploy "dotnet" recipe on Zerops](https://app.zerops.io/recipe/?lf=dotnet) 1. Log in/sign up to [Zerops GUI ↗](https://app.zerops.io) 2. In the **Projects** box click on **Import a project** and paste in the following YAML config ([source ↗](https://github.com/zeropsio/recipe-dotnet-hello-world/blob/main/import-project/description.yaml)): ```yaml project: name: my-first-project services: - hostname: helloworld type: dotnet@latest minContainers: 1 maxContainers: 3 buildFromGit: https://github.com/zeropsio/recipe-dotnet-hello-world@main enableSubdomainAccess: true ``` 3. Click on **Import project** and wait until all pipelines have finished. **That's it, your application is now up and running! :star: Let's check it works:** 1. A _subdomain_ should have been enabled and visible in the project's **IP addressed & Public Routing Overview** box. Its format should look similar to this `https://helloworld-24-8080.prg1.zerops.app`. 2. Click or the `subdomain` URL to open it in a browser and you should see ``` Hello, World! ``` :::tip Do you have any questions? Check the step-by-step tutorial, browse the documentation and join our **[Discord](https://discord.com/invite/WDvCZ54)** community to get help from our team and other members. ::: ## How to start - [Care for details?](/dotnet/how-to/create) — Dive in all Zerops has to offer for your .NET application. ## Feature Highlights - [Create .NET service](/dotnet/how-to/create) — Start with creating a .NET service using GUI or zCLI. - [zerops.yaml](/dotnet/how-to/build-pipeline#add-zeropsyaml-to-your-repository) — See a full example of zerops.yaml file to create your own app. - [Scaling configuration](/dotnet/how-to/scaling) — Set up scaling of your .NET application so that it runs smoothly while using only necessary resources. {" "} - [Customize build environment](/dotnet/how-to/build-process#customize-build-environment) - [Customize runtime environment](/dotnet/how-to/customize-runtime) ## When in doubt, reach out Don't know how to start or got stuck during the process? You might not be the first one, visit the FAQ section to find out. In case you haven't found an answer (and also if you have), we and our community are looking forward to hearing from you on Discord. Have you build something that others might find useful? Don't hesitate to share your knowledge! - [FAQ](/dotnet/faq) — Most common questions in one place. - [Discord](https://discord.com/invite/WDvCZ54) — Join our core team and Zerops community on Discord. Ask questions and share your tips with other members. ## Popular Guides - [zCLI](/references/cli) — Get even more out of Zerops with the zCLI command line tool. - [Zerops VPN](/references/networking/vpn) — Connect to your services easily with Zerops VPN. ---------------------------------------- # Elasticsearch > Overview Deploy [Elasticsearch](https://www.elastic.co/elasticsearch/) instances in Zerops with flexible scaling options, from standalone nodes to highly available clusters. ## Supported Versions Currently supported Elasticsearch versions: Import configuration version: - `elasticsearch@9.2` - `elasticsearch@8.16` ## Connection Details - **Port**: 9200 - **Protocol**: HTTP only - **Internal Access**: `http://{hostname}:9200` - **Basic auth security** - **User**: `elastic` - **Password**: randomly generated during service creation, find under **Access Details** in service detail #### Example ```sh curl -u elastic:generatedpassword http://elasticsearch:9200 ``` ## Configuration Options ### Plugin Management You can configure Elasticsearch plugins using a comma-separated list in your environment secrets: ```yaml envSecrets: PLUGINS: "analysis-icu,ingest-attachment" ``` **Plugin Configuration Details:** - Defines plugins to install at service startup - **Format**: `plugin1,plugin2,...` - Service automatically installs specified plugins during initialization - Removing a plugin from this list triggers uninstallation on service restart ### JVM Heap Allocation Control the JVM heap size as a percentage of container memory: ```yaml envSecrets: HEAP_PERCENT: "75" ``` **Heap Configuration Details:** - Value represents the percentage of container memory allocated to JVM heap - **Default**: 50% of available container memory - **Valid range**: 1-100 - To increase available memory, adjust the service's RAM allocation in scaling configuration :::note Requires Restart Changes to HEAP_PERCENT require a service restart to take effect. ::: ## Backup Elasticsearch backups are created using `elasticdump`: - **Format**: `.gz` (per index/component dump) - **Tooling**: `elasticdump` - **Compression**: Gzip compressed JSON data For backup configuration, scheduling, retention policies, and management options, see the [Zerops Backups](/features/backup) documentation. ### Restoring Backups To restore an Elasticsearch backup: 1. **Download** the backup file (`.gz`) from the Zerops UI 2. **Extract** the compressed files to access the JSON data 3. **Prepare** your target environment (clean existing indices or use a new instance) 4. **Restore** using either: - **elasticdump tool**: Use the same tool that created the backup for restoration via Zerops VPN or during deployment - **Elasticsearch API**: Import the data through REST API [calls](https://www.elastic.co/docs/deploy-manage/tools/snapshot-and-restore/restore-snapshot) For assistance with the restoration process, contact Zerops support. ## Example Configuration ```yaml services: - hostname: elasticsearch type: elasticsearch@8.16 mode: HA envSecrets: PLUGINS: "analysis-icu,ingest-attachment" HEAP_PERCENT: "75" ``` ## Related Resources - [Elasticsearch Official Documentation](https://www.elastic.co/guide/index.html) - [Available Elasticsearch Plugins](https://www.elastic.co/guide/en/elasticsearch/plugins/current/index.html) ---------------------------------------- # Elixir > How To > Build Pipeline Zerops provides a customizable build and runtime environment for your Elixir application. ## Add zerops.yaml to your repository Start by adding `zerops.yaml` file to the **root of your repository** and modify it to fit your application: ```yaml zerops: # define hostname of your service - setup: app # ==== how to build your application ==== build: # REQUIRED. Set the base technology for the build environment: base: elixir@latest # OPTIONAL. Set the operating system for the build environment. # os: ubuntu # OPTIONAL. Customise the build environment by installing additional packages # or tools to the base build environment. # prepareCommands: # - sudo apt-get something # - curl something else # OPTIONAL. Build your application buildCommands: - mix deps.get --only prod - mix compile - mix release # REQUIRED. Select which files / folders to deploy after # the build has successfully finished deployFiles: _build/prod/rel/app/ # OPTIONAL. Which files / folders you want to cache for the next build. # Next builds will be faster when the cache is used. cache: node_modules # ==== how to run your application ==== run: # OPTIONAL. Sets the base technology for the runtime environment: base: elixir@latest # OPTIONAL. Sets the internal port(s) your app listens on: ports: # port number - port: 3000 # OPTIONAL. Customise the runtime Elixir environment by installing additional # dependencies to the base Elixir runtime environment. # prepareCommands: # - sudo apt-get something # - curl something else # OPTIONAL. Run one or more commands each time a new runtime container # is started or restarted. These commands are triggered before # your Elixir application is started. # initCommands: # - rm -rf ./cache # REQUIRED. Your Elixir application start command start: npm start ``` The top-level element is always `zerops`. ### Setup The first element `setup` contains the **hostname** of your service. A runtime service with the same hostname must exist in Zerops. Zerops supports the definition of multiple runtime services in a single `zerops.yaml`. This is useful when you use a monorepo. Just add multiple setup elements in your `zerops.yaml`: ```yaml zerops: # definition for app service - setup: app # optional build: ... # optional deploy: ... # required run: ... # definition for api service - setup: api # optional build: ... # optional deploy: ... # required run: ... ``` Each service configuration contains at least the `run` section. Optional `build` and `deploy` sections can be added to further customize your process. ## Build pipeline configuration ### base _REQUIRED._ Sets the base technology for the build environment. Following options are available for Elixir builds: - `1.16` ```yaml zerops: # hostname of your service - setup: app # ==== how to build your application ==== build: # REQUIRED. Sets the base technology for the build environment: base: elixir@latest ... ```

The base build environment contains {data.alpine.default}, the selected major version of Elixir, [Zerops command line tool](/references/cli), `npm`, `yarn`, `git` and `npx` tools.

:::info You can change the base environment when you need to. Just simply modify the `zerops.yaml` in your repository. ::: If you need to install more technologies to the build environment, set multiple values as a yaml array. For example: ```yaml zerops: # hostname of your service - setup: app # ==== how to build your application ==== build: # REQUIRED. Sets the base technology for the build environment: base: - elixir@latest prepareCommands: - zsc add go@latest ... ``` See the full list of supported [build base environments](/zerops-yaml/base-list#runtime-services). To customise your build environment use the [prepareCommands](#preparecommands) attribute. :::note Modifying the base technology will invalidate your build cache. See our [Build Cache Documentation](/features/build-cache) for more details about cache invalidation. ::: ### os _OPTIONAL._ Sets the operating system for the build environment. Following options are available: - `alpine` - `ubuntu` Default value is `alpine`. We are currently using following os version: - {data.alpine.default} - {data.ubuntu.default} :::caution The os version is fixed and cannot be customised. ::: :::note Changing the OS setting will invalidate your build cache. See our [Build Cache Documentation](/features/build-cache) for details about cache behavior. ::: ### prepareCommands _OPTIONAL._ Customises the build environment by installing additional dependencies or tools to the base build environment. The base build environment contains: - {data.alpine.default} - selected version of Elixir defined in the [base](#base) attribute - [Zerops command line tool](/references/cli) - `npm`, `yarn`, `git` and `npx` tools To install additional packages or tools add one or more prepare commands: ```yaml zerops: # hostname of your service - setup: app # ==== how to build your application ==== build: # REQUIRED. Set the base technology for the build environment: base: elixir@latest # OPTIONAL. Customise the build environment by installing additional packages # or tools to the base build environment. prepareCommands: - sudo apt-get something - curl something else ... ``` When the first build is triggered, Zerops will 1. create a build container 2. download your application code from your repository 3. run the prepare commands in the defined order The application code is available in `/build/source` before the prepare commands are triggered, so you can use any file from your repository in your prepare commands (e.g. a configuration file). The commands themselves run in the `/home/zerops` directory. :::note These commands are skipped when using cached environment. Modifying `prepareCommands` will invalidate your build cache. See our [Build Cache Documentation](/features/build-cache) for details about cache invalidation. ::: #### Command exit code If any command fails, it returns an exit code other than 0 and the build is canceled. Read the [build log](/elixir/how-to/logs#build-log) to troubleshoot the error. If the command ends successfully, it returns the exit code 0 and Zerops triggers the following command. When all prepare commands are finished, your custom build environment is ready for the build phase. #### Single or separated shell instances You can configure your prepare commands to be run in a single shell instance or multiple shell instances. The format is identical to [build commands](#buildcommands). ### buildCommands _OPTIONAL._ Defines build commands. ```yaml zerops: # hostname of your service - setup: app # ==== how to build your application ==== build: # REQUIRED. Set the base technology for the build environment: base: elixir@latest # OPTIONAL. Build your application buildCommands: - npm i - npm run build ... ``` Build commands are optional. Zerops triggers each command in the defined order in a dedicated build container, running from the `/build/source` directory. Before the build commands are triggered the build container contains: 1. base environment defined by the [base](#base) attribute 2. optional customisation of the base environment defined in the [prepareCommands](#preparecommands) attribute 3. your application code #### Run build commands as a single shell instance Use following syntax to run all commands in the same environment context. For example, if one command changes the current directory, the next command continues in that directory. When one command creates an environment variable, the next command can access it. ```yaml buildCommands: - | npm i npm run build ``` #### Run build commands as a separate shell instances When the following syntax is used, each command is triggered in a separate environment context. For example, each shell instance starts in the home directory again. When one command creates an environment variable, it won't be available for the next command. ```yaml buildCommands: - npm i - npm run build ``` #### Command exit code If any command fails, it returns an exit code other than 0 and the build is canceled. Read the [build log](/elixir/how-to/logs#build-log) to troubleshoot the error. If the error log doesn't contain any specific error message, try to run your build with the --verbose option. ```yaml buildCommands: - npm i --verbose - npm run build ``` If the command ends successfully, it returns the exit code 0 and Zerops triggers the following command. When all `buildCommands` are finished, the application build is completed and ready for the deploy phase. ### deployFiles _REQUIRED._ Selects which files or folders will be deployed after the build has successfully finished. To filter out specific files or folders, use [`.deployignore`](#deployignore) file. ```yaml # REQUIRED. Select which files / folders to deploy after # the build has successfully finished deployFiles: - dist - package.json - node_modules ``` Determines files or folders produced by your build, which should be deployed to your runtime service containers. The path starts from the **root directory** of your project (the location of `zerops.yaml`). You must enclose the name in quotes if the folder or the file name contains a space. 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`. #### Examples Deploys a folder, and a file from the project root directory: ```yaml deployFiles: - dist - package.json ``` Deploys the whole content of the build container: ```yaml deployFiles: . ``` Deploys a folder, and a file in a defined path: ```yaml deployFiles: - ./path/to/file.txt - ./path/to/dir/ ``` #### How to use a wildcard in the path 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/` ```yaml deployFiles: ./path/~/to/file.txt ``` Deploys all folders that are located in any path that begins with `/path/to/` ```yaml deployFiles: ./path/to/~/ ``` Deploys all folders that are located in any path that begins with `/path/` and ends with `/to/` ```yaml deployFiles: ./path/~/to/ ``` :::note Example 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`](https://git-scm.com/docs/gitignore#_pattern_format). 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: ```yaml title="zerops.yaml" zerops: - setup: app build: deployFiles: ./ ``` ```text title=".deployignore" /src/file.txt ``` The example above ignores `file.txt` only in the root src directory. ```text title=".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`](/references/zcli/commands#deploy) command. ::: ### cache _OPTIONAL._ Defines which files or folders will be cached for the next build. ```yaml # OPTIONAL. Which files / folders you want to cache for the next build. # Next builds will be faster when the cache is used. cache: file.txt ``` The cache attribute helps optimize build times by preserving specified files between builds. The cache attribute supports the [~ wildcard character](#how-to-use-a-wildcard-in-the-path). Learn more about the [build cache system](/features/build-cache) in Zerops. ### envVariables _OPTIONAL._ Defines the environment variables for the build environment. Enter one or more env variables in following format: ```yaml zerops: # define hostname of your service - setup: app # ==== how to build your application ==== build: base: elixir@latest … # OPTIONAL. Defines the env variables for the build environment: envVariables: NODE_ENV: production DB_NAME: db DB_HOST: db DB_USER: db DB_PASS: ${db_password} ``` Read more about [environment variables](/elixir/how-to/env-variables) in Zerops. ## Runtime configuration ### base _OPTIONAL._ Sets the base technology for the runtime environment. If you don't specify the `run.base` attribute, Zerops keeps the current Elixir version for your runtime. Following options are available for Elixir builds: - `1.16` ```yaml zerops: # hostname of your service - setup: app # ==== how to build your application ==== build: # REQUIRED. Sets the base technology for the build environment: base: elixir@latest ... # ==== how to run your application ==== run: # OPTIONAL. Sets the base technology for the runtime environment: base: elixir@latest ... ```

The base runtime environment contains {data.alpine.default}, the selected major version of Elixir, Zerops command line tool, `npm`, `yarn`, `git` and `npx` tools.

:::info You can change the base environment when you need to. Just simply modify the `zerops.yaml` in your repository. ::: If you need to install more technologies to the runtime environment, set multiple values as a yaml array. For example: ```yaml zerops: # hostname of your service - setup: app # ==== how to build your application ==== build: # REQUIRED. Sets the base technology for the build environment: base: elixir@latest ... # ==== how to run your application ==== run: # OPTIONAL. Sets the base technology for the runtime environment: base: - elixir@latest prepareCommands: - zsc add go@latest ... ``` See the full list of supported [run base environments](/zerops-yaml/base-list). To customise your build environment use the `prepareCommands` attribute. ### os _OPTIONAL._ Sets the operating system for the runtime environment. Following options are available: - `alpine` - `ubuntu` Default value is `alpine`. We are currently using following os version: - {data.alpine.default} - {data.ubuntu.default} :::caution The os version is fixed and cannot be customised. ::: ### ports _OPTIONAL._ Specifies one or more internal ports on which your application will listen. Projects in Zerops represent a group of one or more services. Services can be of different types (runtime services, databases, message brokers, object storage, etc.). All services of the same project share a **dedicated private network**. To connect to a service within the same project, just use the service hostname and its internal port. For example, to connect to a Elixir service with hostname = "app" and port = 3000 from another service of the same project, simply use `app:3000`. Read more about [how to access a Elixir service](/references/networking/internal-access#basic-service-communication). Each port has following attributes: | parameter | description | | ----------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | port | Defines the port number. You can set any port number between _10_ and _65435_. Ports outside this interval are reserved for internal Zerops systems. | | protocol | **Optional.** Defines the protocol. Allowed values are `TCP` or `UDP`. Default value is `TCP`. | | httpSupport | **Optional.** `httpSupport = true` is the default setting for TCP protocol. Set `httpSupport = false` if a web server isn't running on the port. Zerops uses this information for the configuration of [public access](/features/access). `httpSupport = true` is available only in combination with the TCP protocol. | | httpSupport | **Optional.** `httpSupport = true` is the default setting for TCP protocol. Set `httpSupport = false` if a web server isn't running on the port. Zerops uses this information for the configuration of [public access](/features/access). `httpSupport = true` is available only in combination with the TCP protocol. | ### prepareCommands _OPTIONAL._ Customises the Elixir runtime environment by installing additional dependencies or tools to the runtime base environment.

The base Elixir environment contains {data.alpine.default} the selected major version of Elixir, [Zerops command line tool](/references/cli) and `npm`, `yarn`, `git` and `npx` tools. To install additional packages or tools add one or more prepare commands:

```yaml zerops: # hostname of your service - setup: app # ==== how to build your application ==== build: ... # ==== how to run your application ==== run: # OPTIONAL. Customise the runtime environment by installing additional packages # or tools to the base Elixir runtime environment. prepareCommands: - sudo apt-get something - curl something else ... ``` When the first deploy with a defined prepare attribute is triggered, Zerops will 1. create a prepare runtime container 2. optionally: [copy selected folders or files from your build container](#copy-folders-or-files-from-your-build-container) 3. run the `prepareCommands` commands in the defined order :::note `run.prepareCommands` run in the `/home/zerops` directory. ::: #### Command exit code If any command fails, it returns an exit code other than 0 and the deploy is canceled. Read the [prepare runtime log](/elixir/how-to/logs#prepare-runtime-log) to troubleshoot the error. If the command ends successfully, it returns the exit code 0 and Zerops triggers the following command. When all `prepareCommands` commands are finished, your custom runtime environment is ready for the deploy phase. #### Cache of your custom runtime environment Some packages or tools can take a long time to install. Therefore, Zerops caches your custom runtime environment after the installation of your custom packages or tools is completed. When the second or following deploy is triggered, Zerops will use the custom runtime cache from the previous deploy if following conditions are met: 1. Content of the [build.addToRunPrepare](#copy-folders-or-files-from-your-build-container) and `run.prepareCommands` attributes didn't change from the previous deploy 2. The custom runtime cache wasn't invalidated in the Zerops GUI. To invalidate the custom runtime cache go to `yyy` When the custom runtime cache is used, Zerops doesn't create a prepare runtime container and executes the deployment of your application directly. #### Single or separated shell instances You can configure your prepare commands to be run in a single shell instance or multiple shell instances. The format is identical to [build commands](#buildcommands). ### Copy folders or files from your build container

The prepare runtime container contains {data.alpine.default}, the selected major version of Elixir, [Zerops command line tool](/references/cli) and `npm`, `yarn`, `git` and `npx` tools.

The prepare runtime container does not contain your application code nor the built application. If you need to copy some folders or files from the build container to the runtime container (e.g. a configuration file) use the `addToRunPrepare` attribute in the [build section](#build-pipeline-configuration). ```yaml zerops: # hostname of your service - setup: app # ==== how to build your application ==== build: ... addToRunPrepare: ./runtime-config.yaml # ==== how to run your application ==== run: # OPTIONAL. Customise the runtime environment by installing additional packages # or tools to the base Elixir runtime environment. prepareCommands: - sudo apt-get something - curl something else ... ``` In the example above Zerops will copy the `runtime-config.yaml` file from your build container **after the build has finished** into the new **prepare runtime** container. The copied files and folders will be available in the `/home/zerops` folder in the new prepare runtime container before the prepare commands are triggered. ### initCommands _OPTIONAL._ Defines one or more commands to be run each time a new runtime container is started or a container is restarted. ```yaml zerops: # hostname of your service - setup: app # ==== how to build your application ==== build: ... # ==== how to run your application ==== run: # OPTIONAL. Run one or more commands each time a new runtime container # is started or restarted. These commands are triggered before # your Elixir application is started. initCommands: - rm -rf ./cache ``` These commands are triggered in the runtime container before your Elixir application is started via the [start command](#start). :::note `run.initCommands` run in the `/var/www` directory. ::: Use init commands to clean or initialise your application cache or similar operations. :::caution The init commands will delay the start of your application each time a new runtime container is started (including the horizontal [scaling](/elixir/how-to/scaling) or when a runtime container is restarted). Do not use the init commands for customising your runtime environment. Use the [run:prepareCommands](#preparecommands-1) attribute instead. ::: #### Command exit code If any of the `initCommands` fails, it returns an exit code other than 0, but deploy is **not** canceled. After all init commands are finished, regardless of the status code, the application is started. Read the [runtime log](/elixir/how-to/logs#runtime-log) to troubleshoot the error. #### Single or separated shell instances You can configure your `initCommands` to be run in a single shell instance or multiple shell instances. The format is identical to [build commands](#buildcommands). ### envVariables _OPTIONAL._ Defines the environment variables for the runtime environment. Enter one or more env variables in following format: ```yaml zerops: # define hostname of your service - setup: app # ==== how to run your application ==== run: # OPTIONAL. Defines the env variables for the runtime environment: envVariables: NODE_ENV: production DB_NAME: db DB_HOST: db DB_USER: db DB_PASS: ${db_password} ``` Read more about [environment variables](/elixir/how-to/env-variables) in Zerops. ### start _REQUIRED._ Defines the start command for your Elixir application. ```yaml zerops: # hostname of your service - setup: app # ==== how to build your application ==== build: ... # ==== how to run your application ==== run: # REQUIRED. Your Elixir application start command start: npm start ``` We recommend starting your Elixir application using `npm start`. ### health check _OPTIONAL._ Defines a health check. `healthCheck` requires either one `httpGet` object or one `exec` object. #### httpGet Configures the health check to request a local URL using a HTTP GET method. Following attributes are available:
Parameter Description
port Defines the port of the HTTP GET request. The readiness check will trigger a GET request on {'http://127.0.0.1:{port}/{path}'}
path Defines the URL path of the HTTP GET request. The readiness check will trigger a GET request on {'http://127.0.0.1:{port}/{path}'}
host Optional. The readiness check is triggered from inside of your runtime container so it always uses the localhost 127.0.0.1. If you need to add a host to the request header, specify it in the host attribute.
scheme Optional. The readiness check is triggered from inside of your runtime container so no https is required. If your application requires a https request, set scheme: https
**Example:** ```yaml zerops: # hostname of your service - setup: app # ==== how to build your application ==== build: ... # ==== how to run your application ==== run: # REQUIRED. Your Elixir application start command start: npm start # OPTIONAL. Define a health check with a HTTP GET request option. # Configures the check on http://127.0.0.1:80/status healthCheck: httpGet: port: 80 path: /status ``` #### exec Configures the health check to run a local command. Following attributes are available: | Parameter | Description | | ----------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | **command** | Defines a local command to be run. The command has access to the same [environment variables](/elixir/how-to/create#set-secret-environment-variables) as your Elixir application. A single string is required. If you need to run multiple commands create a shell script or, use a multiline format as in the example below. | **Example:** ```yaml zerops: # hostname of your service - setup: app # ==== how to build your application ==== build: ... # ==== how to run your application ==== run: # REQUIRED. Your Elixir application start command start: npm start # OPTIONAL. Define a health check with a shell command. healthCheck: exec: command: | touch grass rm -rf life mv /outside/user /home/user ``` ### crontab _OPTIONAL._ Defines cron jobs. Setup cron jobs in the following format: ```yaml zerops: # define hostname of your service - setup: app # ==== how to run your application ==== run: crontab: # REQUIRED. Sets the command to execute: - command: "" # REQUIRED. Sets the interval time to execute: timing: "0 * * * *" ``` Read more about setting up [cron](/zerops-yaml/cron) in Zerops. ## Deploy configuration ### readiness check _OPTIONAL._ Defines a readiness check. Read more about how the [readiness check works](/elixir/how-to/deploy-process#readiness-checks) in Zerops. `readinessCheck` requires either one `httpGet` object or one `exec` object. #### httpGet Configures the readiness check to request a local URL using a http GET method. Following attributes are available:
Parameter Description
port Defines the port of the HTTP GET request. The readiness check will trigger a GET request on {'http://127.0.0.1:{port}/{path}'}
path Defines the URL path of the HTTP GET request. The readiness check will trigger a GET request on {'http://127.0.0.1:{port}/{path}'}
host Optional. The readiness check is triggered from inside of your runtime container so it always uses the localhost 127.0.0.1. If you need to add a host to the request header, specify it in the host attribute.
scheme Optional. The readiness check is triggered from inside of your runtime container so no https is required. If your application requires a https request, set scheme: https
**Example:** ```yaml zerops: # hostname of your service - setup: app # ==== how to build your application ==== build: ... # ==== how to deploy your application ==== deploy: # OPTIONAL. Define a readiness check with a HTTP GET request option. # Configures the check on http://127.0.0.1:80/status readinessCheck: httpGet: port: 80 path: /status # ==== how to run your application ==== run: ... ``` Read more about how the [readiness check works](/elixir/how-to/deploy-process#readiness-checks) in Zerops. #### exec Configures the readiness check to run a local command. Following attributes are available: | Parameter | Description | | ----------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | **command** | Defines a local command to be run. The command has access to the same [environment variables](/elixir/how-to/create#set-secret-environment-variables) as your Elixir application. A single string is required. If you need to run multiple commands create a shell script or, use a multiline format as in the example below. | **Example:** ```yaml zerops: # hostname of your service - setup: app # ==== how to build your application ==== build: ... # ==== how to deploy your application ==== deploy: # OPTIONAL. Define a readiness check with a HTTP GET request option. # Configures the check on http://127.0.0.1:80/status readinessCheck: exec: command: | touch grass rm -rf life mv /outside/user /home/user ``` Read more about how the [readiness check works](/elixir/how-to/deploy-process#readiness-checks) in Zerops. ---------------------------------------- # Elixir > How To > Build Process ---------------------------------------- # Elixir > How To > Controls ---------------------------------------- # Elixir > How To > Create Zerops provides a powerful Elixir runtime service with extensive build support. The Elixir runtime is highly scalable and customizable to suit your development and production needs. With just a few clicks or commands, you can have a production-ready Elixir environment up and running in no time. ## Create a Elixir service using Zerops GUI First, set up a project in the Zerops GUI. Then go to the project dashboard page and choose **Add new service** in the left menu under the **Services** section. From there, you can add a new Elixir service: [Video: /vids/services/elixir.webm](/vids/services/elixir.webm) ### Choose a Elixir version Zerops supports the following Elixir versions: :::info You can easily [upgrade](/elixir/how-to/upgrade) the major version at any time later. ::: ### Set a hostname Enter a unique service identifier like "app", "cache", "gui", etc. Duplicate services with the same name within the same project are not allowed. #### Limitations: - Maximum 25 characters - Must contain only lowercase ASCII letters (a-z) or numbers (0-9) :::caution The hostname is fixed after the service is created and cannot be changed later. ::: ### Set secret environment variables Add environment variables with sensitive data, such as passwords, tokens, salts, certificates, etc. These will be securely saved inside Zerops and added to your runtime service upon start. Setting secret environment variables is optional. You can always set them later in the Zerops GUI. Read more about the [different types of environment variables](/elixir/how-to/env-variables#service-env-variables) in Zerops. ## Create a Elixir service using zCLI zCLI is the Zerops command-line tool. To create a new Elixir service via the command line, follow these steps: 1. [Install & setup zCLI](/references/cli) 2. [Create a project description file](/elixir/how-to/create#create-a-project-description-file) 3. [Create a project with a Elixir and PostgreSQL service](#full-example) ### Create a project description file Zerops uses a YAML format to describe the project infrastructure. #### Basic example: Create a directory called `my-project`. Inside the `my-project` directory, create a `description.yaml` file with the following content: ```yaml # basic project data project: # project name name: my-project # array of project services services: - # service name hostname: app # service type and version number in elixir@{version} format type: elixir@latest # defines the minimum number of containers for horizontal autoscaling minContainers: 1 # defines the maximum number of containers for horizontal autoscaling. Max value = 6. maxContainers: 6 # optional: create env variables envSecrets: S3_ACCESS_KEY_ID: 'P8cX1vVVb' S3_ACCESS_SECRET: 'ogFthuiLYki8XoL73opSCQ' ``` The yaml file describes your future project infrastructure. The project will contain one Elixir version 20 service with default [auto scaling](/elixir/how-to/scaling) configuration. Hostname will be set to "app", the internal port(s) the service listens on will be defined later in the [zerops.yaml](/elixir/how-to/build-pipeline#ports). Following secret env variables will be configured: ```env S3_ACCESS_KEY_ID="P8cX1vVVb" S3_ACCESS_SECRET="ogFthuiLYki8XoL73opSCQ" ``` #### Full example: Create a directory my-project. Create an description.yaml file inside the my-project directory with following content: ```yaml # basic project data project: # project name name: my-project # optional: project description description: A project with a Elixir and PostgreSQL database # optional: project tags tags: - DEMO - ZEROPS # array of project services services: - # service name hostname: app # service type and version number in elixir@{version} format type: elixir@latest # optional: vertical auto scaling customization verticalAutoscaling: cpuMode: DEDICATED minCpu: 2 maxCpu: 5 minRam: 2 maxRam: 24 minDisk: 6 maxDisk: 50 startCpuCoreCount: 3 minFreeRamGB: 0.5 minFreeRamPercent: 20 # defines the minimum number of containers for horizontal autoscaling. Max value = 6. minContainers: 2 # defines the maximum number of containers for horizontal autoscaling. Max value = 6. maxContainers: 4 # optional: create env variables envSecrets: S3_ACCESS_KEY_ID: 'P8cX1vVVb' S3_ACCESS_SECRET: 'ogFthuiLYki8XoL73opSCQ' - # second service hostname hostname: db # service type and version number in postgresql@{version} format type: postgresql@12 # mode of operation "HA"/"non_HA" mode: NON_HA ``` The yaml file describes your future project infrastructure. The project will contain a Elixir service and a [PostgreSQL](/postgresql/overview) service. Elixir service with "app" hostname, the internal port(s) the service listens on will be defined later in the [zerops.yaml](/elixir/how-to/build-pipeline#ports). Elixir service will run on version 20 with a custom vertical and horizontal scaling. Following secret env variables will be configured: ```env S3_ACCESS_KEY_ID="P8cX1vVVb" S3_ACCESS_SECRET="ogFthuiLYki8XoL73opSCQ" ``` The hostname of the PostgreSQL service will be set to "db". The [single container](/features/scaling#single-container-mode)(/features/scaling#deployment-modes-databases-and-shared-storage) mode will be chosen and the default auto [scaling configuration](/postgresql/how-to/scale#configure-scaling) will be set. #### Description of description.yaml parameters The `project:` section is required. Only one project can be defined. | Parameter | Description | Limitations | | --------------- | ------------------------------------------------------------------------------------------------------------------------------- | ----------------------- | | **name** | The name of the new project. Duplicates are allowed. | | | **description** | **Optional.** Description of the new project. | Maximum 255 characters. | | **tags** | **Optional.** One or more string tags. Tags do not have a functional meaning, they only provide better orientation in projects. | | **tags** | **Optional.** One or more string tags. Tags do not have a functional meaning, they only provide better orientation in projects. | At least one service in `services:` section is required. You can create a project with multiple services. The example above contains Elixir and PostgreSQL services but you can create a `description.yaml` with your own combination of [services](/features/infrastructure).
Parameter Description
hostname The unique service identifier.
  • duplicate services with the same name in the same project are forbidden
  • maximum 25 characters
  • must contain only lowercase ASCII letters (a-z) or numbers (0-9)
type Specifies the service type and version. See what [Elixir service types](/references/import-yaml/type-list#runtime-services) are currently supported.
verticalAutoscaling Optional. Defines [custom vertical auto scaling parameters](/elixir/how-to/create#set-auto-scaling-configuration). All verticalAutoscaling attributes are optional. Not specified attributes will be set to their default values.
- cpuMode Optional. Accepts `SHARED`, `DEDICATED` values. Default is `SHARED`
- minCpu/maxCpu Optional. Set the minCpu or maxCpu in CPU cores (integer).
- minRam/maxRam Optional. Set the minRam or maxRam in GB (float).
- minDisk/maxDisk Optional. Set the minDisk or maxDisk in GB (float).
minContainers Optional. Default = 1. Defines the minimum number of containers for [horizontal autoscaling](/elixir/how-to/create#horizontal-auto-scaling). Limitations: Current maximum value = 10.
maxContainers Defines the maximum number of containers for [horizontal autoscaling](/elixir/how-to/create#horizontal-auto-scaling). Limitations: Current maximum value = 10.
envSecrets Optional. Defines one or more secret env variables as a key value map. See env variable [restrictions](/elixir/how-to/env-variables#env-variable-restrictions).
### Create a project based on the description.yaml When you have your `description.yaml` ready, use the `zcli project project-import` command to create a new project and the service infrastructure. ```sh Usage: zcli project project-import importYamlPath [flags] Flags: -h, --help Help for the project import command. --org-id string If you have access to more than one organization, you must specify the org ID for which the project is to be created. --working-dir string Sets a custom working directory. Default working directory is the current directory. (default "./") ``` Zerops will create a project and one or more services based on the `description.yaml` content. Maximum size of the `description.yaml` file is 100 kB. You don't specify the project name in the `zcli project project-import` command, because the project name is defined in the `description.yaml`. If you have access to more than one client, you must specify the client ID for which the project is to be created. The `clientID` is located in the Zerops GUI under the client name on the project dashboard page. ### Add Elixir service to an existing project #### Example: Create a directory `my-project` if it doesn't exist. Create an `import.yaml` file inside the `my-project` directory with following content: ```yaml # basic project data project: # project name name: my-project # array of project services services: - # service name hostname: app # service type and version number in elixir@{version} format type: elixir@latest # defines the minimum number of containers for horizontal autoscaling minContainers: 1 # defines the maximum number of containers for horizontal autoscaling. Max value = 6. maxContainers: 6 # optional: create env variables envSecrets: S3_ACCESS_KEY_ID: 'P8cX1vVVb' S3_ACCESS_SECRET: 'ogFthuiLYki8XoL73opSCQ' ``` The yaml file describes the list of one or more services that you want to add to your existing project. In the example above, one Elixir service version 20 with default [auto scaling](/elixir/how-to/scaling) configuration will be added to your project. Hostname of the new service will be set to `app`. Following secret env variables will be configured: ```env S3_ACCESS_KEY_ID="P8cX1vVVb" S3_ACCESS_SECRET="ogFthuiLYki8XoL73opSCQ" ``` The content of the `services:` section of `import.yaml` is identical to the project description file. The `import.yaml` never contains the `project:` section because the project already exists. When you have your `import.yaml` ready, use the `zcli project service-import` command to add one or more services to your existing Zerops project. ```sh Usage: zcli project service-import importYamlPath [flags] Flags: -h, --help Help for the project service import command. -P, --project-id string If you have access to more than one project, you must specify the project ID for which the command is to be executed. ``` zCLI commands are interactive, when you press enter after `zcli project service-import importYamlPath`, you will be given a list of your projects to choose from. Maximum size of the import.yaml file is 100 kB. ---------------------------------------- # Elixir > How To > Customize Runtime ---------------------------------------- # Elixir > How To > Deploy Process ---------------------------------------- # Elixir > How To > Env Variables ---------------------------------------- # Elixir > How To > Filebrowser ---------------------------------------- # Elixir > How To > Logs ---------------------------------------- # Elixir > How To > Scaling ---------------------------------------- # Elixir > How To > Shared Storage ---------------------------------------- # Elixir > How To > Trigger Pipeline ---------------------------------------- # Elixir > How To > Upgrade ---------------------------------------- # Elixir > Overview [Elixir ↗](https://elixir.org/en) is an asynchronous event-driven JavaScript runtime, which is designed to build scalable network applications. As said, there is no need for coding yet, we have created a [Github repository ↗](https://github.com/zeropsio/recipe-elixir), a **_recipe_**, containing the most simple Elixir web application. The repo will be used as a source from which the app will be built. ### 🚀 Feel free to deploy the recipe yourself This is the most bare-bones example of Elixir app running in Zerops — as few libraries as possible, just a simple endpoint with connect, read and write to a Zerops PostgreSQL database. [Deploy "elixir" recipe on Zerops](https://app.zerops.io/recipe/?lf=elixir) 1. Log in/sign up to [Zerops GUI ↗](https://app.zerops.io) 2. In the **Projects** box click on **Import a project** and paste in the following YAML config ([source ↗](https://github.com/zeropsio/recipe-elixir/blob/main/zerops-project-import.yaml)): ```yaml project: name: recipe-elixir tags: - zerops-recipe services: - hostname: api type: elixir@1.16 enableSubdomainAccess: true buildFromGit: https://github.com/zeropsio/recipe-elixir - hostname: db type: postgresql@16 mode: NON_HA priority: 1 ``` 3. Click on **Import project** and wait until all pipelines have finished. **That's it, your application is now up and running! :star: Let's check it works:** 1. A _subdomain_ should have been enabled and visible in the project's **IP addressed & Public Routing Overview** box. Its format should look similar to this `https://api-808-4000.prg1.zerops.app`. 2. Click or the `subdomain` URL to open it in a browser and you should see ``` {"message":"This is a simple Elixir application running in Zerops.io, each request adds an entry to the PostgreSQL database and returns a count. See the source repository (https://github.com/zeropsio/recipe-elixir) for more information.","newEntry":"e64be640-d6c2-4be8-93ac-d1e40e56fa06","count":1} ``` :::tip Do you have any questions? Check the step-by-step tutorial, browse the documentation and join our **[Discord](https://discord.com/invite/WDvCZ54)** community to get help from our team and other members. ::: ## How to start It doesn't matter whether it's your first curious introduction to Zerops, you have already mastered the basics and are looking for a tiny detail or inspiration. Below, choose a section that fits your needs: - [Care for details?](/elixir/how-to/create) — Dive in all Zerops has to offer for your Elixir application. - [Elixir recipes](https://github.com/zeropsio?q=elixir&type=all&language=&sort=) — Get inspired by already existing repositories, ready to be imported to Zerops. ## Feature Highlights - [Create Elixir service](/elixir/how-to/create) — Start with creating a Elixir service using GUI or zCLI. - [Zerops.yaml](/elixir/how-to/build-pipeline#add-zeropsyaml-to-your-repository) — See a full example of zerops.yaml file to create your own app. - [Scaling configuration](/elixir/how-to/scaling) — Set up scaling of your Elixir application so that it runs smoothly while using only necessary resources. {" "} - [Customize build environment](/elixir/how-to/build-process#customize-build-environment) - [Customize runtime environment](/elixir/how-to/customize-runtime) ## When in doubt, reach out Don't know how to start or got stuck during the process? You might not be the first one, visit the FAQ section to find out. In case you haven't found an answer (and also if you have), we and our community are looking forward to hearing from you on Discord. Have you build something that others might find useful? Don't hesitate to share your knowledge! - [FAQ](/elixir/faq) — Most common questions in one place. - [Discord](https://discord.com/invite/WDvCZ54) — Join our core team and Zerops community on Discord. Ask questions and share your tips with other members. ## Popular Guides - [zCLI](/references/cli) — Get even more out of Zerops with the zCLI command line tool. - [Zerops VPN](/references/networking/vpn) — Connect to your services easily with Zerops VPN. ---------------------------------------- # Features > Access Zerops provides multiple ways to access your services, whether you need internal communication between services, secure access from your development machine, or public access from the internet. :::note By default, your services are not publicly accessible until you configure external access. Internal communication between services within the same project works automatically. ::: ## How Zerops Networking Works Every Zerops project includes a **shared networking infrastructure** that handles all access methods: **Private Project Network:** - All services within a project share a dedicated private network - Services communicate directly using hostnames and internal ports - Traffic stays isolated within your project **Public Access Infrastructure:** - **Core (L3) Balancer** manages IP addresses and direct port access - **L7 HTTP Balancer** handles domain routing and SSL termination - Can be extensively configured for advanced routing, performance optimization, and custom behaviors - See the [L7 Balancer Configuration Guide](/references/networking/l7-balancer-config) for detailed options - Both are shared across all services in your project **Secure External Access:** - **Built-in VPN** provides secure tunnel access to your project's private network - Useful for development, debugging, and administration ## Internal Access :::tip Complete Internal Access Setup See the [Internal access reference guide](/references/networking/internal-access). ::: Services within the same project can communicate directly using hostnames and internal ports. No additional configuration required. **Example:** Connect to your `api` service on port 3000: ``` http://api:3000 ``` **Key points:** - Use service hostname as the address - Use HTTP (not HTTPS) for internal communication - Access internal ports defined in your service configuration - Communication is automatically isolated from other projects ### Environment Variables Zerops automatically creates environment variables to help with internal connections between services. ## VPN Access :::tip Complete VPN Setup See the [VPN reference guide](/references/networking/vpn). ::: Connect securely to your project's internal network from your local machine: ```bash # Connect to your project zcli vpn up # Access services using internal hostnames curl http://api:3000/health # Disconnect when done zcli vpn down ``` ## Public Access :::tip Complete Public Access Setup See the [Public access reference guide](/references/networking/public-access). ::: Make your services accessible from the internet using one of three methods: ### Zerops Subdomain **Best for:** Development and testing - Quick setup with automatic `.zerops.app` subdomains - Each service gets its own unique subdomain - Automatic SSL certificate management - Shared infrastructure (has limitations for production use) ### Custom Domain **Best for:** Production deployments - Use your own domain names - Better performance with dedicated balancer - Full control over SSL and routing - Requires DNS configuration ### Direct Port Access **Best for:** Non-HTTP protocols and specialized use cases - Direct access to specific ports on your services - Supports any protocol (TCP/UDP) - Optional firewall configuration - Uses your project's IP addresses ## Next Steps - **Internal access setup:** [Internal Access Reference Guide](/references/networking/internal-access) - **Public access configuration:** [Public Access Reference Guide](/references/networking/public-access) - **VPN setup and troubleshooting:** [VPN Reference Guide](/references/networking/vpn) - **Advanced routing and SSL:** [L7 Balancer Configuration Guide](/references/networking/l7-balancer-config) ---------------------------------------- # Features > Backup Zerops provides an automated, secure backup system for supported services. This guide covers how to configure, manage, and restore your backups. ## Supported Services Zerops provides automated backup functionality for the following services. For specific backup format details and restore instructions, visit each service's documentation: [MariaDB](/mariadb/how-to/backup), [PostgreSQL](/postgresql/how-to/manage#backups), [Qdrant](/qdrant/overview), [Elasticsearch](/elasticsearch/overview), [NATS](/nats/overview), [Meilisearch](/meilisearch/overview), and [Shared Storage](/shared-storage/how-to/manage#backups). ## Managing Backups in the UI By default, your data is backed up automatically **every day** between 00:00:00 UTC and 01:00:00 UTC, unless you update your settings. To manage backups, go to the service detail and choose **Backups List & Configuration** in the left menu. From this section, you can: - Create a one-time backup - Change the frequency/disable of automatic backups - Configure retention policies and limits ### Backup Frequency Options Available schedules: - **No backups**: Disable automatic backups (not recommended) - **Once a day**: Daily backups at a specified time - **Once a week**: Weekly backups on a specific day and time - **Once a month**: Monthly backups on a specific day and time - **Custom CRON**: Define a custom schedule using CRON syntax For the Custom CRON option, you can use the following syntax:
Field name Allowed values
Minute 0-59
Hour 0-23
Day 1-31
Month 1-12
Week Day 0–7; both 0 and 7 represent Sunday
Examples: - `0 2 * * *` - Every day at 2:00 AM - `0 4 * * 0` - Every Sunday at 4:00 AM - `0 0 1 * *` - First day of every month at midnight - `0 */6 * * *` - Every 6 hours ### Backup Tagging Zerops uses tags to categorize and manage backups: **Time-Based Tags** (assigned automatically): - `daily`: Every automatic backup - `weekly`: First backup of each week (Monday UTC) - `monthly`: First backup of each month (1st UTC) **User Tags** (custom labels you create): - Used for organization and identification (e.g., `v2.1-release`, `before-migration`, `monthly-snapshot`) - Add when creating manual backups - up to 24 characters (letters, numbers, `:-_`) **Protected Tags** (configured in retention policy): - Backups with these tag names are exempt from automatic deletion, regardless of storage limits - Define in the backup retention configuration section of the UI and add when creating manual backups :::important Manual backups don't get automatic time-based tags. Always add a protected tag to preserve critical manual backups. ::: ### View and Manage Backup Files In this section, you can: - Create manual backups - View all backups with their timestamps and sizes - Download backups - Delete backups :::note When creating manual backups via the UI, you'll see immediate feedback. If the backup takes longer than 10 seconds, the process continues in the background. You can verify completion by refreshing the backup list or checking service logs. ::: ## Storage and Limits ### Project Storage Quotas Each Zerops project has a **technical maximum backup storage limit of 1 TiB**: - Only full backups are stored - If a backup would exceed the storage limit, it will not be stored - This quota is shared across all service backups within the project ### Billing - **Lightweight Project Core**: 5 GB backup storage and 100 GB egress included - **Serious Project Core**: 25 GB backup storage and 3 TB egress included When you exceed your plan's free limits, **additional charges apply** according to our [pricing](/company/pricing#overage-costs). ### Retention Policy and Configuration Zerops manages which backups are kept using a retention policy that you can customize through the UI: **Default Time-Based Retention** (minimums): - At least 7 daily backups - At least 4 weekly backups - At least 3 monthly backups **Default Resource Limits** (maximums): - Max 50 total backups per service - Storage limited to your project's 1 TiB technical maximum (with billing for usage beyond free tier) **Customization Options:** You can modify these defaults in the backup retention configuration interface: - **Set Protected Tags**: Define tag names that prevent automatic deletion of backups - **Configure Maximum Limits**: Adjust total number of backups and storage size limits per service - **Customize Minimum Retention**: Change how many daily, weekly, and monthly backups to keep - **Set Type-Specific Limits**: Control maximum backups for each type (0 means unlimited, subject to total limits) :::important Backups with [protected tags](#backup-tagging) and the minimum required time-based backups will always be kept, even if they exceed the limits above. This ensures your critical recovery points are preserved. ::: If you need more storage space, contact our support team. ### When Deleting Services or Projects Deleted services/projects have their backups kept for a 7-day grace period before final removal. ## Command Line Interface You can also manage backups using the Zerops CLI (zCLI): ```bash # Create a backup zcli backup create myServiceName # Create a backup with tags (including protection) zcli backup create myServiceName --tags pre-deploy,protected ``` Check `zcli backup --help` for current commands. :::note zCLI currently focuses on creation; listing/deletion/tag management is primarily via UI. ::: ## Restoring Backups Restoration involves downloading backups and using service-specific methods. Zerops facilitates the backup creation and download; the restore action uses service-specific tools and APIs. 1. **Download**: Find the backup in the UI (by date/tag) and download it 2. **Prepare**: Set up your target environment (clean existing data or use a new instance) 3. **Restore**: Use service-specific tools via Zerops VPN, run the restore during deployment, or use the service API if available. For service-specific restore instructions, see each service's documentation linked in the [Supported Services](#supported-services) section above. :::info Continuous Improvement We're working on enhancing the restore experience, potentially including more automated options in the future. ::: For assistance with restoration, contact Zerops support. ## High Availability (HA) For multi-node HA services: - **Automatic Backups**: Run on a randomly selected healthy node - **Manual Backups**: Typically run on the primary/designated node (check logs) - **Cluster State**: Other nodes stay operational ## Security Backups are protected with end-to-end encryption: - **Unique Encryption**: Each project gets its own encryption key (X25519) - **Secure Process**: Data is encrypted immediately as backups are created - **Zero-Trust**: Even Zerops staff cannot access your raw backup data - **Isolated Storage**: Backups are stored separately from your regular data - **Secure Download**: Backups are only decrypted when you download them :::important When a project is deleted, the encryption key is permanently destroyed after 7 days, making the backup data unrecoverable. ::: ## Best Practices 1. **Create backups before major changes**: - Always create a manual backup with a protected tag before database migrations, deployments, or large data operations - Use descriptive tags like `pre-migration` or `pre-release-v2` 2. **Manage storage efficiently**: - Regularly check usage in the Project Overview & Service Backup tabs to monitor free tier usage and stay within the 1 TiB technical limit - Remove unnecessary backups, especially those with [protected tags](#backup-tagging) - Adjust [retention policies](#retention-policy-and-configuration) based on your recovery needs - Regularly review and clean up old backups to optimize storage usage and minimize overage costs 3. **Test your restore process** periodically in a non-production environment to ensure you can recover when needed ## Troubleshooting ### Storage Quota Issues **Cause**: High backup frequency, long retention periods, or many protected tags can lead to exceeding free tier limits or approaching technical maximums. **Solutions**: 1. **Review & Prune**: Delete unnecessary manual backups or remove protected status from older backups 2. **Adjust Retention Policy**: Reduce minimum retention counts if your recovery requirements allow 3. **Optimize Schedule**: Reduce backup frequency if daily backups aren't essential 4. **Monitor Costs**: Check usage against your free tier (5GB/25GB) to avoid unexpected overage charges 5. **Contact Support**: If you need assistance managing storage ### Backup Failures **Cause**: Service health issues, resource exhaustion, or platform problems. **Solutions**: 1. **Check Service Logs**: Look for error messages around the scheduled backup time 2. **Verify Service Health**: Ensure the service is running properly with adequate resources 3. **Check Platform Status**: Visit status.zerops.io for any ongoing incidents 4. **Contact Support**: If issues persist, reach out with service name, failure time, and relevant logs ---------------------------------------- # Features > Build Cache > Zerops implements a sophisticated two-layer caching strategy that optimizes build times while maintaining complete control over the build environment. This documentation explores the architecture, configuration patterns, and practical implementation of the build cache system. ## Architecture Overview The build cache operates through two distinct layers: 1. **Base Layer**: Comprises the OS, installed dependencies, and prepare commands 2. **Build Layer**: Contains the state after executing build commands The layers work together to create an efficient and predictable build environment, though they are currently coupled in their cache invalidation behavior (invalidating one layer affects the other). ### Cache Implementation The caching mechanism is implemented through an efficient file movement strategy. This approach ensures near-instantaneous cache operations through simple directory relocation within the container, implementing the following characteristics: - Files are moved between `/build/source` and `/build/cache` using container-level rename operations - No packaging, compression, or network transfer is involved - Cache preservation is achieved through simple directory relocation within the container - Files maintain their original state and permissions throughout the process :::note See detailed [build process lifecycle](#build-process-lifecycle). ::: ## Configuration Guide ### Essential zerops.yaml Fields The following fields in `zerops.yaml` affect build cache behavior: **Direct Cache Configuration**: - `build.cache`: Explicitly defines what should be cached through paths or patterns **Cache Invalidation Triggers**: These parameters trigger cache invalidation when modified: - `build.os`: Base operating system selection - `build.base`: Pre-installed software stacks and runtimes - `build.prepareCommands`: System preparation and dependency installation - `build.cache`: Changes to cache configuration **Build Artifact Generation**: - `build.buildCommands`: Generates the build artifact that will be deployed. ## Cache Configuration Patterns ### Pattern 1: System-Wide Cache Control ```yaml build: cache: true # Cache everything # OR cache: false # Intended to disable all caching ``` The boolean values provide system-wide cache control: `cache: true`: - Preserves the entire build container state - Maintains system-level package installations - Ideal for globally installed packages (Python/PHP packages, Go modules) `cache: false`: - Intended to disable all caching - Currently, due to layer coupling, only files within `/build/source` are not cached - Everything outside `/build/source` remains cached (see [Common Pitfalls: Layer Coupling](#current-pitfalls)) ### Pattern 2: Path-Specific Caching ```yaml # Single path build: cache: node_modules # Multiple paths build: cache: - node_modules - package-lock.json - .build ``` Execution flow: 1. Source code extraction to `/build/source` 2. Build command execution 3. Specified path preservation in `/build/cache` 4. Cached content restoration (no-clobber mode - source files take precedence) :::tip Ideal for non-versioned dependencies in your working directory (e.g., `node_modules`, `vendor`, `.venv`). ::: ## Path Pattern Reference Zerops supports [Go's filepath.Match](https://pkg.go.dev/path/filepath#Match) syntax. Consider this example structure: ``` ├── node_modules/ ├── package.json ├── package-lock.json └── subdir/ ├── file1.txt ├── file2.txt └── file3.md ``` Pattern examples and matches: ```yaml build: cache: - "subdir/*.txt" # Matches: subdir/file1.txt, subdir/file2.txt - "package*" # Matches: package.json, package-lock.json - "node_modules" # Matches: entire node_modules directory recursively ``` :::note All patterns resolve relative to `/build/source`. Path variations like `./node_modules`, `node_modules`, and `node_modules/` are treated identically. ::: ## Build Process Lifecycle 1. **Initialization Phase** - Build container startup - Builder process launch - Source code loading into `/build/source` 2. **Cache Restoration Phase** - Cached file movement to `/build/source` (no-clobber mode) - Source file precedence handling - Conflict logging (no build interruption) - Cache directory cleanup 3. **Build Execution Phase** - Build command processing - Artifact packaging (`build.deployFiles`) 4. **Cache Preservation Phase** - Specific cache files movement outside `/build/source` - `/build/source` directory cleanup - Container termination ## Cache Invalidation Reference The build cache invalidates under these conditions: 1. **Manual Triggers** - API call: `DELETE /service-stack/{id}/build-cache` - GUI: Manual cache clear action 2. **Version Management** - Backup app version activation via `PUT /app-version/{id}/deploy` 3. **Configuration Changes** Any modifications to: ```yaml build.os build.base build.prepareCommands build.cache ``` ### Current Pitfalls The current implementation has some important characteristics: 1. **Layer Coupling** ```yaml build: base: go@1 prepareCommands: - sudo apk update - sudo apk add sqlite buildCommands: - go build -o app main.go cache: false ``` Even with `cache: false`, Go modules outside `/build/source` remain cached. 2. **Cascade Invalidation** ```yaml build: base: node@22 prepareCommands: - sudo apk update - sudo apk add sqlite vim # Adding 'vim' invalidates everything buildCommands: - npm install - npm build cache: - node_modules ``` Modifying `prepareCommands` invalidates both layers, including cached `node_modules`. ## Real-World Implementation Examples ### Node.js Project with TypeScript ```yaml build: base: node@22 buildCommands: - npm ci - npm run build cache: - node_modules - .next - .turbo - package-lock.json ``` ### Go Project with Multiple Dependencies ```yaml build: base: go@1 prepareCommands: - sudo apk add build-base buildCommands: - go mod download - go build -o bin/app cmd/main.go cache: true # Caches entire Go modules directory ``` ### PHP/Laravel Project ```yaml build: base: php@8.3 buildCommands: - composer install --no-dev - php artisan optimize cache: - vendor - composer.lock ``` ## Debugging and Monitoring * **Build Logs** - Cache operations are detailed in build logs - File conflicts during restoration are logged - Cache preservation status is visible ## Implementation Best Practices ### Cache Strategy Optimization 1. **Layer Management** - Maintain stable `prepareCommands` to prevent cache invalidation - Group related prepare commands logically 2. **Performance Optimization**: - Cache package manager lock files alongside dependency directories - Use system-wide caching (`cache: true`) for languages with global package managers 3. **Performance Tuning** - Leverage system-wide caching for complex builds - Monitor build logs for cache operations and potential conflicts - Use explicit patterns for precise control - Don't over-optimize – the system handles large caches efficiently ## Future Development Planned system enhancements include: - Layer independence implementation - Granular cache control mechanisms - Enhanced layer management capabilities - Improved cache invalidation patterns ---------------------------------------- # Features > Cdn Zerops CDN is a global content delivery network that brings your static content closer to your users, resulting in faster load times and improved user experience. Built on Nginx and Cloudflare geo-steering technology, our CDN automatically routes users to the nearest server location based on their DNS request. ## Key Benefits - **Global Reach**: Serve content from strategic locations across the world - **Reduced Latency**: Content is delivered from the server closest to your users - **Simple Integration**: No complex configuration required ## Global CDN Infrastructure Zerops CDN operates across **6 strategic regions** to ensure your content is always delivered from a location close to your users:
Region Location Coverage Area
EU CZ Prague, Czech Republic Primary European coverage + failover for all regions
DE Falkenstein, Germany
UK London, United Kingdom UK and surrounding areas
AU Sydney, Australia Australia and Oceania
SG Singapore, Singapore Southeast Asia
CA Beauharnois, Canada North America
### Geo-Steering Technology Zerops CDN's geo-steering technology automatically routes users to the server location closest to them. Here's how it works: * **Automatic routing**: Users are directed to the optimal CDN node based on their geographic location * **Quick failover**: The DNS TTL is set to just 30 seconds, allowing fast recovery if a node fails * **Redundancy**: If any node becomes unavailable, Cloudflare automatically redirects traffic to the next closest node * **Reliable backup**: The EU region serves as the ultimate fallback - if all other nodes go down, EU will always be served in DNS ## CDN Modes and Implementation Zerops CDN currently supports two distinct usage modes (with a third mode coming soon), each designed for specific content delivery needs. ### Object Storage Mode Perfect for efficiently delivering media files, documents, and other static assets stored in Zerops [Object Storage](/object-storage/overview) to users across different geographical regions. **Setup process:** 1. Create an Object Storage service or select an existing one 2. Enable the CDN option for this service 3. Set appropriate public read access policies for objects you want to serve via CDN **Accessing content:** ```txt https://storage.cdn.zerops.app/your-bucket/path/to/file ``` :::tip Access the storage CDN URL via the `storageCdnUrl` **project** environment variable `${storageCdnUrl}/your-bucket/path/to/file`. ::: ### Static Mode Ideal for caching and delivering static website assets like HTML, CSS, JavaScript, and images served from your custom domains. **Setup process:** 1. Configure domain access for your service through the L7 HTTP Balancer section 2. Access domain settings via the **three dots menu** or **gear icon** next to your domain entry 3. In the "Project Domain Access Modification" dialog, enable the **"Enable CDN for static files"** toggle 4. Optionally enable "Automatically install SSL Certificates" if not already configured **Accessing content:** ```txt https://static.cdn.zerops.app/your-domain.com/path/to/file ``` :::tip Access the static CDN URL via the `staticCdnUrl` **project** environment variable `${staticCdnUrl}/your-domain.com/path/to/file`. ::: :::warning Wildcard Domains Not Supported Static CDN cannot be activated for wildcard domains (e.g., *.example.com). You must use specific domain names. ::: ### API Mode *(Coming Soon)* Designed for caching API responses to reduce load on your backend services and deliver faster responses to clients. **Environment variable:** Once available, you'll be able to access the API CDN URL via the `apiCdnUrl` **project** environment variable. :::warning API Mode is currently under development and will be available in a future release. ::: ### HTML Implementation Examples Here's how to integrate CDN URLs in your HTML code: ```html ``` ### Testing Specific CDN Nodes For testing or debugging purposes, you can bypass the automatic geo-steering and access a specific CDN node directly: ``` https://{region}-{mode}.cdn.zerops.app/path/to/content ``` Available region prefixes: `cz`, `de`, `au`, `sg`, `uk`, and `ca` **Examples:** - Test Australia node: `https://au-storage.cdn.zerops.app/my-bucket/test.jpg` - Test UK node: `https://uk-static.cdn.zerops.app/my-domain.com/index.html` ## Managing CDN Content ### Cache Lifecycle Content served through Zerops CDN follows this lifecycle: 1. **First Request**: When a user requests content not yet in the CDN cache, the request goes to the origin server (your Zerops service), and the response is cached at the CDN node 2. **Subsequent Requests**: Further requests for the same content are served directly from the CDN cache, reducing latency and origin server load 3. **Cache Expiration**: By default, content remains cached for 30 days unless explicitly purged 4. **Automatic Management**: When CDN storage reaches capacity, the least recently used content is automatically removed :::note Important Cache Behavior Zerops CDN implements a fixed 30-day TTL policy. Currently, HTTP caching headers such as `Cache-Control`, `Expires`, `Pragma`, etc. do not influence CDN caching behavior. To refresh content sooner than the 30-day period, use the [purge API](#api-reference). Your `Cache-Control` headers will still affect browser caching behavior. ::: ### When to Purge Cache You should consider purging cached content when: - **Content Updates**: You've updated content but kept the same URL (e.g., updated images, CSS files) - **Deployment Rollouts**: You've deployed a new version of your application - **Emergency Removal**: You need to immediately remove content that was accidentally made public - **Testing Changes**: You want to ensure users see the latest version during testing ### Purging Cached Content Zerops provides multiple ways to manage and purge cached content before its normal expiration: - **Command Line**: Use the `zsc cdn purge` [command](/references/zsc#cdn) available in all Zerops containers: ```sh # Purge all content for a domain zsc cdn purge example.com # Purge all content (wildcard) zsc cdn purge example.com "/*" # Purge specific file zsc cdn purge example.com "/path/to/my-file$" ``` :::important - This command must be executed in any container within the project that has the CDN-enabled domain active - Currently only works for [Static Mode](#static-mode) CDN ::: - **API Endpoints**: For programmatic control, use the [API endpoints](#api-reference). Here are ready-to-use curl examples for quickly purging content in your scripts: ```sh # Static mode: Purge all content for a domain curl --location --request PUT "https://api.app-prg1.zerops.io/api/rest/public/project/$PROJECT_ID/purge-cdn/static/$DOMAIN/*" \ --header "Authorization: Bearer $USER_OR_ACCESS_TOKEN" ``` ```sh # Storage mode: Purge all content for object storage curl --location --request PUT "https://api.app-prg1.zerops.io/api/rest/public/service-stack/$OBJECT_STORAGE_SERVICE_ID/purge-cdn/*" \ --header "Authorization: Bearer $USER_OR_ACCESS_TOKEN" ``` #### Purge Pattern Examples
Pattern Description Example
`/*` Purges all content Useful after major updates
`/images/*` Purges all content in a directory Clear all cached images
`/css/main.css$` Purges a specific file Update a single CSS file
`/2023*` Purges content starting with pattern Clear content with date prefix
:::warning Pattern Rules - Wildcards (`*`) must be at the end of the pattern - Specific files must include `$` at the end - Nested wildcards (e.g., `/dir/*.jpg`) are not supported ::: ## API Reference Zerops provides a comprehensive set of API endpoints to manage your CDN configuration and content. For complete information about base URLs, authorization, and general API usage, please refer to our [API specification](/references/api). The endpoint links below will take you to the Swagger documentation with detailed request/response schemas and examples: ### CDN Management API - **[Enable CDN for Storage ↗](https://api.app-prg1.zerops.io/api/rest/public/swagger/#/PublicServiceStack/EnableStorageCdn)** `PUT /api/rest/public/service-stack/{id}/cdn` - **[Disable CDN for Storage ↗](https://api.app-prg1.zerops.io/api/rest/public/swagger/#/PublicServiceStack/DisableStorageCdn)** `DELETE /api/rest/public/service-stack/{id}/cdn` - **[Create Object Storage with CDN ↗](https://api.app-prg1.zerops.io/api/rest/public/swagger/#/PublicServiceStackObjectStorage/CreateObjectStorageV1)** `POST /api/rest/public/service-stack/object_storage_v1` - **[Create Domain Routing with CDN ↗](https://api.app-prg1.zerops.io/api/rest/public/swagger/#/PublicPublicHttpRouting/CreatePublicHttpRouting)** `POST /api/public/public-http-routing` - **[Update Domain Routing with CDN ↗](https://api.app-prg1.zerops.io/api/rest/public/swagger/#/PublicPublicHttpRouting/UpdatePublicHttpRouting)** `PUT /api/public/public-http-routing/{id}` ### Cache Purge API - **[Purge Storage Mode Cache ↗](https://api.app-prg1.zerops.io/api/rest/public/swagger/#/PublicServiceStack/PurgeStorageCdn)** `PUT /api/rest/public/service-stack/{id}/purge-cdn/{path}` - **[Purge Static Mode Cache ↗](https://api.app-prg1.zerops.io/api/rest/public/swagger/#/PublicProject/PurgeStaticCdn)** `PUT /api/rest/public/project/{id}/purge-cdn/static/{domain}/{path}` - **Purge Api Mode Cache *(Coming soon)*** ## Troubleshooting Having issues with your CDN? Here are solutions to the most common problems: #### Content Not Updated After Changes * **Issue:** You've updated content, but users still see the old version. * **Possible Cause:** The CDN cache is continuing to serve the previously cached version. * **Solution:** - Use the [purge API](#api-reference) with the specific content path - For immediate changes, use versioned file names (e.g., `style.v2.css` instead of just `style.css`) #### Content Not Being Cached * **Issue:** Your content isn't being cached by the CDN. * **Possible Cause:** Missing public read permissions on objects. * **Solution:** - For object storage: Check bucket and object access policies - Verify the object is accessible directly before attempting CDN access :::note Remember that only publicly accessible objects will be cached by the CDN. Private objects will always be fetched directly from the origin. ::: #### Environment Variables Not Available * **Issue:** You can't access the new CDN-related project level environment variables in your containers. * **Possible Cause:** When new environment variables are created, existing services need to be restarted to access them. Services created before the CDN feature release require special handling. * **Solution:** - For services created after CDN release: Restart the service to apply the new environment variables - For services created before CDN release: Add and then remove a dummy environment variable in the project settings adn restart the service #### Unexpected 404 Errors * **Issue:** Users receive 404 errors when accessing content via CDN. * **Possible Cause:** Incorrect CDN URL formatting or missing content at origin. * **Solution:** - Double-check your [URL structure](#) (pay attention to domain names and paths) - Verify content exists at the origin before attempting CDN access - Test accessing the content directly from origin first **Correct URL patterns:** - Object Storage: `https://storage.cdn.zerops.app/your-bucket/path/to/file` - Static Mode: `https://static.cdn.zerops.app/your-domain.com/path/to/file` --- *Need help implementing CDN in your project? Join our [Discord community](https://discord.gg/zeropsio) where our team and other Zerops users can assist you!* ---------------------------------------- # Features > Coding Agents Zerops was built on the idea of **environment parity** — giving developers the full development lifecycle, from remote development to highly available production, with the observability and developer tools for maximum flexibility, and sensible defaults so the configs stay reasonable. Turns out that's **exactly what coding agents need** to produce and iterate on production-ready applications.