Skip to main content

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:
Key optimizations:
  • Dependency caching: Copies Cargo.toml files first to cache dependency builds
  • Release build: Compiles with --release flag for maximum performance
  • Binary stripping: Removes debug symbols to reduce image size

Stage 2: Runtime Environment

Creates a minimal runtime container:
Security features:
  • Runs as non-root user (nanoarb)
  • Only includes runtime dependencies (ca-certificates, libssl3)
  • Health check endpoint configured

Docker Compose Configurations

Full Stack Deployment

The docker-compose.yml file deploys the complete stack including monitoring:
Key configuration details:
Resource limits:
  • CPU: 2-4 cores reserved for consistent performance
  • Memory: 2-4GB allocated for order book and strategy state

Monitoring-Only Stack

For local development, use docker-compose-monitoring.yml to run only Prometheus and Grafana while running the trading engine natively:
This configuration:
  • 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

Build takes approximately 5-10 minutes on first run due to Rust dependency compilation. Subsequent builds leverage Docker layer caching.

Starting the Stack

Starts all services in detached mode.

Viewing Logs

Checking Status

Teardown Commands

Stop Services

Clean Up

Volume Management

The deployment creates persistent volumes:

Backup Volumes

Restore Volumes

Configuration

The default configuration is mounted from docker/config.toml:
Configuration override:

Environment Variables

The container accepts these environment variables:

Networking

All services communicate via the nanoarb-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:
View health status:

Troubleshooting

Container Won’t Start

Port Conflicts

If ports are already in use, modify the port mappings in docker-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