Production-Ready Layered Rust 2024 Service Template for Hyperlane, SeaORM, Redis & Static musl Delivery
Overview · Architecture · Workspace Matrix · Quick Start · Configuration · Verification · Agent Governance
hyperlane-quick-start is the official production starter template and layered reference architecture for the hyperlane web framework. It organizes a full-stack Rust 2024 backend into 5 strictly bounded workspace crates—covering configuration, environment/Docker/SQL resources, MySQL/PostgreSQL/Redis infrastructure plugins, HTTP application layers, and a unified composition root—ready to deploy via one-command Docker Compose or a zero-libc static x86_64-unknown-linux-musl binary.
flowchart TB
Main["src/main.rs\nExecutable Entry Point"] --> Bootstrap["hyperlane_bootstrap\nEnv · Logger · Runtime · Db · Server"]
Bootstrap --> Application["hyperlane_application\nControllers · Middleware · Views · Exceptions · Services"]
Bootstrap --> Plugin["hyperlane_plugin\nMySQL · PostgreSQL · Redis · Env · Logger · Process · Shutdown"]
Application --> Plugin
Plugin --> Config["hyperlane_config\nStatic Framework & App Constants"]
Plugin --> Resources["hyperlane_resources\nEnv Files · Dockerfiles · SQL · Templates"]
Plugin --> Datastores["External Infrastructure\nMySQL · PostgreSQL · Redis"]
- Boot Sequence (
src/main.rs):EnvBootstrap::init()->LoggerBootstrap::init()->RuntimeBootstrap::init()->DbBootstrap::init().await(connects MySQL, PostgreSQL, Redis and runs topological schema auto-creation) ->ProcessPlugin::create(...)->ServerBootstrap::init().await. - Server Composition (
hyperlane_bootstrap):ServerBootstrapappliesServerConfigandRequestConfigloaded from environment settings, bindshyperlane_applicationhooks via#[hyperlane(server: Server)]and#[import(hyperlane_application)], logs every static/dynamic/regex route, and registersShutdownPluginbefore awaiting the server control handle. - Middleware & Error Hooks (
hyperlane_application): Request pipeline (HttpRequestMiddleware,CrossMiddleware,ResponseHeaderMiddleware,ResponseStatusCodeMiddleware), response pipeline (SendMiddleware,LogMiddleware), exception handlers (TaskPanicHook,RequestErrorHook), and views (FaviconRoute).
All crates share a unified version in root Cargo.toml (Rust edition 2024, resolver 3):
| Crate | Path | crates.io | docs.rs | Responsibility |
|---|---|---|---|---|
hyperlane-quick-start |
. (src/) |
N/A (binary) | Executable entry point wiring bootstrap, process PID lifecycle, and Tokio runtime | |
hyperlane_resources |
resources/ |
Dev/release .env templates, Dockerfiles, Compose files, SQL scripts, and HTML/static asset paths |
||
hyperlane_config |
config/ |
Static application and framework constants (logger defaults, logo URL, server defaults) | ||
hyperlane_plugin |
plugin/ |
Infrastructure plugins (database, env, logger, mysql, postgresql, process, redis, shutdown) |
||
hyperlane_application |
application/ |
Business layers: controllers, services, repositories, mappers, models, middleware, views, exceptions | ||
hyperlane_bootstrap |
bootstrap/ |
Composition root initializing env, logger, runtime, databases, and the Hyperlane HTTP server |
git clone https://github.com/hyperlane-dev/hyperlane-quick-start.git
cd hyperlane-quick-start
docker compose up -dOpen http://127.0.0.1:65002.
Root compose.yaml builds the multi-stage release image (resources/docker/release/server.dockerfile), starts MySQL, PostgreSQL, and Redis, waits for all three health checks to report healthy, and launches the server using resources/env/release/server.env.
A healthy startup logs:
[AUTO-CREATION] Initialization complete MySQL (mysql_default) verified,
PostgreSQL (postgres_default) verified, Redis (redis_default) verified
Server listen in 0.0.0.0:65002
To skip the first-run Rust compilation (the release profile disables LTO and is verified in CI inside a 2-CPU / 4 GiB no-swap Alpine container), pull the prebuilt image:
| Branch | Published Image |
|---|---|
master |
hkccr.ccs.tencentyun.com/hyperlane-dev/hyperlane-quick-start:1.0.0 |
playground |
hkccr.ccs.tencentyun.com/hyperlane-dev/hyperlane-quick-start-playground:1.0.0 |
docker compose pull
docker compose up -dThe image uses a two-stage Alpine build (rust:1.99-alpine -> alpine:3.22 + ca-certificates), shipping only the static musl executable and resources/ with no compiler or target/ artifacts.
Every GitHub Release ships a statically linked x86_64-unknown-linux-musl binary that runs on any Linux distribution without shared libraries:
curl -fL -o hyperlane-quick-start \
https://github.com/hyperlane-dev/hyperlane-quick-start/releases/latest/download/hyperlane-quick-start-<version>-linux-x86_64
chmod +x hyperlane-quick-start
./hyperlane-quick-startKeep ./resources/env and ./resources/static alongside the binary (e.g., from a clone of this repository).
cargo build --release
cargo test --workspace --all-featuresSet explicit parallelism with cargo build --release -j <N> on memory-constrained hosts.
- Development (
cargo run): Readsresources/env/dev/server.env(SERVER_PORT=80, logs in./data/dev/logs, PID in./data/dev/process/hyperlane.pid). - Release (
cargo run --release/ Docker): Readsresources/env/release/server.env(SERVER_PORT=65002, logs in./data/release/logs, PID in./data/release/process/hyperlane.pid).
Key settings include SERVER_HOST, SERVER_PORT, SERVER_BUFFER, SERVER_NODELAY, SERVER_TTI, SERVER_REQUEST_HTTP_READ_TIMEOUT_MS, SERVER_REQUEST_MAX_BODY_SIZE, MYSQL, POSTGRESQL, REDIS, DB_CONNECTION_TIMEOUT_MILLIS, and DB_RETRY_INTERVAL_MILLIS.
docker compose ps
docker compose logs -f server
docker compose down # stop and preserve database volumes
docker compose down -v # stop and remove database volumesMySQL, PostgreSQL, and Redis are exposed only inside the private Compose network to avoid host port conflicts. Inspect them directly with docker compose exec:
docker compose exec postgresql psql -U hyperlane -d hyperlane
docker compose exec mysql mysql -uhyperlane -phyperlane hyperlane
docker compose exec redis redis-cli -a hyperlane pingPass -T when invoking docker compose exec non-interactively in scripts.
Before committing or pushing, run the full local verification suite matching .github/workflows/rust.yml:
crate fmt
crate fmt --check
cargo fmt --all -- --check
cargo clippy --workspace --all-features --all-targets -- -D warnings
cargo test --workspace --all-features
cargo check --release --workspace --all-features
docker compose config -q- Layered boundaries, engineering rules, Docker/musl invariants, and release governance live in
AGENTS.md. - Project-specific agent workflows live in
.agents/skills/hyperlane-quick-start/SKILL.md. - Framework API reference:
docs.rs/hyperlane.
This project is licensed under the MIT License. See the LICENSE file for details.
Contributions are welcome! Follow the standards in AGENTS.md and open an issue or pull request.
For inquiries, please contact the author at root@devhub.vip.