Overview
NanoARB provides Docker configurations for both development and production deployments. The multi-stage Dockerfile is optimized for minimal latency and small image size, critical for high-frequency trading applications.Container Architecture
The deployment uses a multi-stage build process:Stage 1: Build Environment
Builds the Rust application with all necessary dependencies:- Dependency caching: Copies
Cargo.tomlfiles first to cache dependency builds - Release build: Compiles with
--releaseflag for maximum performance - Binary stripping: Removes debug symbols to reduce image size
Stage 2: Runtime Environment
Creates a minimal runtime container:- Runs as non-root user (
nanoarb) - Only includes runtime dependencies (
ca-certificates,libssl3) - Health check endpoint configured
Docker Compose Configurations
Full Stack Deployment
Thedocker-compose.yml file deploys the complete stack including monitoring:
- CPU: 2-4 cores reserved for consistent performance
- Memory: 2-4GB allocated for order book and strategy state
Monitoring-Only Stack
For local development, usedocker-compose-monitoring.yml to run only Prometheus and Grafana while running the trading engine natively:
- Runs Prometheus on port 9091
- Runs Grafana on port 3000
- Scrapes metrics from host machine via
host.docker.internal:9090
Setup Commands
Building the Image
Starting the Stack
- Full Stack
- Monitoring Only
Viewing Logs
Checking Status
Teardown Commands
Stop Services
Clean Up
Volume Management
The deployment creates persistent volumes:| Volume | Purpose | Location |
|---|---|---|
nanoarb-data | Market data and state | /app/data |
nanoarb-logs | Application logs | /app/logs |
prometheus-data | Metrics time-series | /prometheus |
grafana-data | Dashboard configs | /var/lib/grafana |
Backup Volumes
Restore Volumes
Configuration
The default configuration is mounted fromdocker/config.toml:
Environment Variables
The container accepts these environment variables:| Variable | Default | Description |
|---|---|---|
RUST_LOG | info | Log level (debug, info, warn, error) |
RUST_BACKTRACE | 1 | Enable stack traces on errors |
PORT | 9090 | Metrics server port |
NANOARB_CONFIG | /app/config.toml | Configuration file path |
Networking
All services communicate via thenanoarb-network bridge network:
- nanoarb: Exposes port 9090 for metrics
- prometheus: Exposes port 9091 (mapped from 9090)
- grafana: Exposes port 3000 for dashboards
Prometheus scrapes the trading engine at
nanoarb:9090 when using the full stack, or host.docker.internal:9090 in monitoring-only mode.Health Checks
The trading engine includes a health check that runs every 30 seconds:Troubleshooting
Container Won’t Start
Port Conflicts
If ports are already in use, modify the port mappings indocker-compose.yml:
Memory Issues
Adjust memory limits if the container is killed:Next Steps
Monitoring
Configure Prometheus and Grafana dashboards
Production
Production deployment best practices