Deploy Rust on Your Own Server

Deploy Rust web applications with optimized release builds and minimal Alpine-based containers. Supports Axum, Actix, Rocket, and any HTTP framework.


Quickstart

From your project root, deploy with your preferred package manager:

npx @temps-sdk/cli up

Temps detects your Cargo.toml, compiles a release build, and runs it in a minimal container. Builds take around 5 minutes; subsequent deploys are faster with layer caching.


What Temps Handles Automatically

FeatureHow Temps handles it
Buildcargo build --release
Cachingcargo-chef for dependency layer caching
ImageMulti-stage: builder (musl) + minimal Alpine
HTTPSLet's Encrypt, auto-renewed
PortPORT env var injected, defaults to 8080
StartupNear-instant — static binary

Dockerfile with cargo-chef

Temps generates an optimized Dockerfile using cargo-chef to cache dependencies between builds. You can also provide your own:

FROM lukemathwalker/cargo-chef:latest-rust-1 AS chef
WORKDIR /app

FROM chef AS planner
COPY . .
RUN cargo chef prepare --recipe-path recipe.json

FROM chef AS builder
COPY --from=planner /app/recipe.json recipe.json
RUN cargo chef cook --release --recipe-path recipe.json
COPY . .
RUN cargo build --release --bin my-app

FROM debian:bookworm-slim AS runtime
WORKDIR /app
COPY --from=builder /app/target/release/my-app /usr/local/bin
EXPOSE 8080
ENTRYPOINT ["/usr/local/bin/my-app"]

Reading PORT from Environment

use std::env;

let port = env::var("PORT").unwrap_or_else(|_| "8080".to_string());
let addr = format!("0.0.0.0:{}", port);

Axum Example

use axum::{routing::get, Router};
use std::env;

#[tokio::main]
async fn main() {
    let app = Router::new().route("/", get(|| async { "Hello from Temps!" }));
    let port = env::var("PORT").unwrap_or_else(|_| "8080".to_string());
    let listener = tokio::net::TcpListener::bind(format!("0.0.0.0:{}", port))
        .await
        .unwrap();
    axum::serve(listener, app).await.unwrap();
}

Managed PostgreSQL

npx @temps-sdk/cli environments vars set DATABASE_URL "postgres://user:pass@host/db" -e production

Use sqlx or diesel to connect.


Platform behavior

These rules apply to every app deployed on Temps, regardless of framework.

Health checks

After your container starts, Temps sends HTTP GET requests to verify it is healthy before routing traffic to it.

  • Path: / (the root of your application)
  • Success: 2 consecutive responses with a 2xx or 3xx status code
  • Timeout: 300 seconds (5 minutes) for the app to become healthy
  • Retry interval: every 5 seconds

Connection errors while the app is still starting are retried without penalty. If the app returns 4xx or 5xx errors for 60 consecutive seconds, the deployment fails. Customize the check by adding a .temps.yaml to your repository root:

.temps.yaml
health:
  path: /health
  status: 200
  interval: 30
  timeout: 5
  retries: 3

Auto-injected environment variables

Temps injects these variables into every deployment automatically:

VariableValueDescription
PORTResolved portThe port your app must listen on
HOST0.0.0.0Bind address
SENTRY_DSNAuto-generatedError tracking endpoint
TEMPS_API_URLYour Temps URLPlatform API endpoint
TEMPS_API_TOKENDeployment tokenAuthentication for Temps SDKs
OTEL_EXPORTER_OTLP_ENDPOINTYour Temps OTLP URLOpenTelemetry trace collection
OTEL_SERVICE_NAMEProject nameService identifier for traces

You do not need to configure these manually. They are available in process.env (Node.js), os.environ (Python), os.Getenv (Go), and the equivalent in other languages.


Next Steps

Was this page helpful?