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

Rust build process

image

Description of the build process​

Zerops starts a temporary build container and performs following actions:

  1. Installs the build environment:
    • Sets up base system and Go runtime
    • Restores cached files if available (based on build.cache configuration)
    • Validates cache against current build.os, build.base, and build.prepareCommands
  2. Downloads your application source code from GitHub ↗, GitLab ↗ or via Zerops CLI
  3. Optionally customizes the build environment
  4. Runs the build commands
  5. Uploads the application artefact to the internal Zerops storage
  6. Preserves specified files for future builds (based on build.cache configuration)
  7. Optionally customizes the runtime environment
  8. Deploys your application

The build container is automatically deleted after the build has finished or failed.

Cancel running build​

When you know that the running build is not correct and you want to cancel it, you can do it in Zerops GUI. Go to the service detail, select Service dashboard & runtime containers from the left menu and click on the Open pipeline detail button. Then click on the Cancel build button.

// TODO screenshot of a running build pipeline

The build cancellation is available before the build pipeline is finished. When the build is finished, the deployment cannot be cancelled.

Customize Rust build environment​

The default Rust build environment contains:

  • Alpine 3.20
  • selected version of Rust defined in zerops.yml build.base parameter
  • zCLI, Zerops command line tool
  • npm, yarn, git and npx tools

If you prefer the Ubuntu OS instead of Alpine, set the build.os attribute to ubuntu. To install additional packages or tools add one or more build.prepareCommands commands to your zerops.yml.

Info

The application code is available in the /var/www 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).

Rust build hardware resources​

Build of your Rust application is run in a separate build container with following resource configuration:

HW resourceMinimumMaximum
CPU cores620
RAM8 GB8 GB
Disk1 GB100 GB

The build container is always started with the minimum hardware resources and scales vertically up to the maximum resources.

Info

Hardware resources of the build containers are not charged. The build costs are covered by the standard Zerops project fee.

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.

Failure of a build prepare command​

If any prepare command fails, it returns an exit code other than 0 and the build is canceled. Read the 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 prepareCommands commands are finished, your custom build environment is ready for the build phase.

Invalidate the build cache​

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, which can help resolve cache-related issues. After invalidation, your next build will also create a fresh cache.

Failure of a build command​

If any build command fails, it returns an exit code other than 0 and the build is canceled. Read the 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.

buildCommands:
- cargo build --release -v

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.