Skip to content

Hello Rust

A minimal Actix-web application in Rust. Multi-stage Docker build compiling to a static binary. One container, one service, no database, no cache.

Overview

Repository git@gitlab.com:appmecca-sample-apps/hello-rust.git
Tech Stack Rust 1.84 / Actix-web
Services web (port 8080)
Database None
Cache None
URL Pattern https://hello-rust-web.{env}.appmecca.net

What This App Demonstrates

  • Deploying a Rust application on AppMecca
  • Multi-stage Docker build (Rust compiler + Debian runtime)
  • Compiled binary with minimal runtime overhead
  • Health check endpoint pattern

appmecca.yaml

containers:
  - name: hello-rust
    dockerfile: Dockerfile
    context: .

deploy:
  - name: web
    container: hello-rust
    port: 8080
    health_check:
      path: /health

The configuration is identical in structure to any other single-container app. Actix-web is configured to listen on port 8080.

Step-by-Step Deployment

1. Register the app

mecca register git@gitlab.com:appmecca-sample-apps/hello-rust.git -e dev

2. Build the container

mecca build trigger -e dev -g git@gitlab.com:appmecca-sample-apps/hello-rust.git
Expected output
Build started: build-xxxxxxxx
Cloning repository...
Building container: hello-rust
Pushing image to the private registry: hello-rust/web
Build complete. Duration: 120s

Rust builds are slow the first time because the compiler downloads and compiles all dependencies from source. Subsequent builds with cached Docker layers are faster.

3. Deploy

mecca app deploy -e dev hello-rust
Expected output
Deploying hello-rust to dev...
Deployment queued: deploy-xxxxxxxx
Waiting for agents...
Container started: hello-rust-web
Health check passed: /health -> 200 OK
Deployment complete.

Services:
  web: https://hello-rust-web.dev.appmecca.net

4. Verify

mecca app show hello-rust -e dev

Test the endpoint:

curl https://hello-rust-web.dev.appmecca.net/health
{"status": "healthy"}

Key Concepts

Multi-stage Docker builds for Rust

Rust compiles to a native binary, making multi-stage builds particularly effective. The build stage uses the full Rust toolchain (~1.5 GB). The runtime stage needs only a minimal Debian image plus your compiled binary (~30 MB final image). No runtime interpreter, no garbage collector, no virtual machine.

Image size comparison

Stage Image size
rust:1.84-slim (build stage) ~1.5 GB
Final image (Debian slim + binary) ~30 MB

Actix-web

Actix-web is one of the fastest web frameworks available in any language. It uses Rust's async runtime (Tokio) for non-blocking I/O and achieves exceptional throughput. Despite the performance, the API is straightforward for simple services.

Any language, same workflow

AppMecca does not care what language your application is written in. As long as your container listens on the declared port and responds to health checks, the deployment workflow is identical.

What's Next?