Lokasi ngalangkungan proxy:   [ UP ]  
[Ngawartoskeun bug]   [Panyetelan cookie]                
Skip to main content
Open console

Rust

A compiled Rust binary serving its own HTTP — Axum, Actix Web, Rocket or a server of your own

2 min read

A compiled Rust binary serving its own HTTP: Axum, Actix Web, Rocket or a server of your own. It replaces PHP-FPM and nginx; the platform's proxy in front of it terminates TLS, routes the hostname and compresses responses.

Build and runtime images

Your build steps run in the official Rust image, slim, on Debian trixie, with pkg-config, cmake and the OpenSSL, PostgreSQL and MySQL client headers, so the crates that link against them build. The binary runs in a slim Debian image with no Rust in it, about a tenth of the size, carrying the libraries those crates link against. The container runs as vallic with the release at /var/www/html/current (WEB_ROOT), read-only, and the release's own bin/ on PATH.

Deploy steps, cron jobs, workers and vallic ssh have the binary and no cargo: run what you built (bin/server migrate), not cargo run.

A crate that links any other system library needs it in the image: open a ticket naming the library, and we add it (Support).

A Rust project

vallic.yaml at the root of the repository:

version: 1
type: rust

runtime:
  rust: '1.99'

build:
  steps:
    - name: Build
      run: cargo install --locked --path . --root .

port: 8080

health:
  path: /healthz
  timeout: 10

cargo install --root . puts the binary in bin/, and the image starts bin/server. A package named server needs no start; for any other name write start: bin/<name>. Listen on 0.0.0.0 and on the port in PORT, which is 8080 unless port says otherwise.

Nothing under cache. Cargo's registry and its build directory are kept between builds, outside the checkout, so a build whose dependencies did not change compiles only your own crate. target listed as a cache would be copied into every release. A build directory that has grown past 4 GB is emptied, and that one build compiles everything again. Cargo runs one compile job for each gigabyte a build may use, so a small machine builds slowly rather than running out of memory.

The version is the one under runtime. A rust-toolchain.toml is not obeyed: a build does not download another toolchain. --locked builds what Cargo.lock says, so commit it.

Write uploads and anything else created at runtime under /mnt/files (VALLIC_PUBLIC_DIR, VALLIC_PRIVATE_DIR), which outlives the release; the release itself is read-only. Set environment variables on the environment in the console, and RUST_LOG and RUST_BACKTRACE on the service as well (see Service settings).

Versions

Version Status
1.99 Supported, and the default
1.100 Supported
1.98 Supported

Pin the version, not the build: name 1.99 and the platform matches it to the current build, so a security rebuild reaches you without anybody editing a repository.

What you can change

In vallic.yaml — what each one does is on Service settings:

services:
  - rust:
      version: '1.99'
      environment:
        RUST_LOG: …
        RUST_BACKTRACE: …

Anything not on this list refuses the deploy, naming the variable — rather than being accepted and quietly ignored.

Need a hand?

Open a ticket from Support in the console. We answer on the ticket.

Open the console How support works