Skip to main content

What is Rust on Zerops?

Zerops provides a fully managed Rust runtime environment with automatic compilation, built-in Cargo support, and zero-config deployment. Build and deploy high-performance, memory-safe Rust applications with enterprise-grade reliability.
Rust is a language empowering everyone to build reliable and efficient software. Learn more about Rust →

Key Features

Latest Rust Versions

Support for Rust 1.70 through latest stable versions

Automatic Scaling

Horizontal and vertical auto-scaling based on actual resource usage

Cargo Integration

Built-in Cargo support for dependency management and builds

Zero-Cost Abstractions

Deploy compiled Rust binaries for maximum performance

Supported Versions

Zerops supports multiple Rust versions:
  • Rust 1.75 (Latest stable)
  • Rust 1.74
  • Rust 1.73
  • Rust 1.70+
You can change the Rust version at any time through the zerops.yaml configuration.

Quick Example

Deploy a Rust application in minutes:
project:
  name: my-rust-app
services:
  - hostname: app
    type: rust@latest
    minContainers: 1
    maxContainers: 3
    buildFromGit: https://github.com/zeropsio/recipe-rust-hello-world@main
    enableSubdomainAccess: true

Runtime Environment

The Rust runtime environment includes:
  • Alpine Linux (default) or Ubuntu
  • Rust toolchain (rustc, cargo)
  • Build essentials
  • Git utilities
  • Zerops CLI tools

Common Use Cases

Build high-performance web services with Actix-web.
zerops:
  - setup: api
    build:
      base: rust@latest
      buildCommands:
        - cargo build --release
      deployFiles:
        - target/release/app
    run:
      start: ./target/release/app
      ports:
        - port: 8080
Deploy async applications with Tokio and axum.
zerops:
  - setup: web
    build:
      base: rust@latest
      buildCommands:
        - cargo build --release --bin web-server
      deployFiles:
        - target/release/web-server
    run:
      start: ./target/release/web-server
Create lightweight, efficient microservices.
zerops:
  - setup: service
    build:
      base: rust@latest
      buildCommands:
        - cargo build --release
      deployFiles:
        - target/release/service
        - config
    run:
      start: ./target/release/service
Deploy async task processors and workers.
zerops:
  - setup: worker
    build:
      base: rust@latest
      buildCommands:
        - cargo build --release --bin worker
      deployFiles:
        - target/release/worker
    run:
      start: ./target/release/worker

Build Process

Standard Build

zerops:
  - setup: app
    build:
      base: rust@latest
      buildCommands:
        - cargo build --release
      deployFiles:
        - target/release/app
      cache: target

Optimized Build

Create smaller, optimized binaries:
build:
  base: rust@latest
  buildCommands:
    - cargo build --release
    - strip target/release/app
  deployFiles:
    - target/release/app

Workspace Build

Build Rust workspaces with multiple crates:
build:
  base: rust@latest
  buildCommands:
    - cargo build --release --workspace
  deployFiles:
    - target/release/api
    - target/release/worker

Runtime Configuration

Simple HTTP Server

run:
  start: ./target/release/app
  ports:
    - port: 8080
      httpSupport: true

With Environment Variables

run:
  start: ./target/release/app
  envVariables:
    RUST_LOG: info
    APP_ENV: production

Health Check

run:
  start: ./target/release/app
  healthCheck:
    httpGet:
      port: 8080
      path: /health

Advanced Build Configurations

With System Dependencies

build:
  base: rust@latest
  os: ubuntu
  prepareCommands:
    - sudo apt-get update
    - sudo apt-get install -y libpq-dev
    - sudo apt-get install -y libssl-dev
  buildCommands:
    - cargo build --release
  deployFiles:
    - target/release/app

Cross-Compilation

build:
  base: rust@latest
  prepareCommands:
    - rustup target add x86_64-unknown-linux-musl
  buildCommands:
    - cargo build --release --target x86_64-unknown-linux-musl
  deployFiles:
    - target/x86_64-unknown-linux-musl/release/app

Feature Flags

build:
  buildCommands:
    - cargo build --release --features production

Environment Variables

Set runtime configuration:
run:
  envVariables:
    RUST_LOG: info
    RUST_BACKTRACE: 1
    APP_ENV: production
    PORT: 8080
Access in Rust:
use std::env;

fn main() {
    let log_level = env::var("RUST_LOG").unwrap_or_else(|_| "info".to_string());
    let port = env::var("PORT").unwrap_or_else(|_| "8080".to_string());
}

Common Frameworks

Actix-web

src/main.rs
use actix_web::{web, App, HttpServer, Responder};

async fn index() -> impl Responder {
    "Hello from Actix on Zerops!"
}

#[actix_web::main]
async fn main() -> std::io::Result<()> {
    HttpServer::new(|| {
        App::new()
            .route("/", web::get().to(index))
    })
    .bind("0.0.0.0:8080")?
    .run()
    .await
}

Axum

src/main.rs
use axum::{
    routing::get,
    Router,
};

#[tokio::main]
async fn main() {
    let app = Router::new().route("/", get(|| async { "Hello from Axum on Zerops!" }));
    
    axum::Server::bind(&"0.0.0.0:8080".parse().unwrap())
        .serve(app.into_make_service())
        .await
        .unwrap();
}

Rocket

src/main.rs
#[macro_use] extern crate rocket;

#[get("/")]
fn index() -> &'static str {
    "Hello from Rocket on Zerops!"
}

#[launch]
fn rocket() -> _ {
    rocket::build().mount("/", routes![index])
}

Database Integration

PostgreSQL with SQLx

use sqlx::postgres::PgPoolOptions;
use std::env;

#[tokio::main]
async fn main() -> Result<(), sqlx::Error> {
    let database_url = format!(
        "postgres://{}:{}@db/{}",
        env::var("DB_USER").unwrap(),
        env::var("DB_PASSWORD").unwrap(),
        env::var("DB_NAME").unwrap(),
    );
    
    let pool = PgPoolOptions::new()
        .max_connections(5)
        .connect(&database_url)
        .await?;
    
    Ok(())
}

Redis Connection

use redis::Client;

fn main() {
    let client = Client::open("redis://redis:6379").unwrap();
    let mut con = client.get_connection().unwrap();
}

Performance Optimization

Build Cache

Cache build artifacts for faster builds:
build:
  cache:
    - target
    - ~/.cargo/registry
    - ~/.cargo/git

Release Optimizations

Add to Cargo.toml:
[profile.release]
opt-level = 3
lto = true
codegen-units = 1
strip = true

Parallel Compilation

build:
  buildCommands:
    - cargo build --release -j 4

Next Steps

Quickstart Guide

Deploy your first Rust application

Example Projects

Explore Rust examples on GitHub

Build docs developers (and LLMs) love