- Rust 1.75 (Nov 2023) too old for base64ct-1.8.0 dependency - base64ct requires edition2024 features not in Cargo 1.75 - Local system uses Rust 1.89, need Docker parity - Updated all 6 Dockerfile variants across 3 services Fixes: - ML training service Docker build - Trading service Docker build - Backtesting service Docker build Related: Wave 125 Phase 3B Docker deployment
116 lines
4.0 KiB
Docker
116 lines
4.0 KiB
Docker
# =============================================================================
|
|
# FOXHUNT TRADING SERVICE - ULTRA-PERFORMANCE PRODUCTION CONTAINER
|
|
# =============================================================================
|
|
# This Dockerfile creates a specialized container for the Trading Service
|
|
# optimized for 14ns latency requirements with minimal overhead
|
|
|
|
# =============================================================================
|
|
# BUILDER STAGE - Static Build with Maximum Optimization
|
|
# =============================================================================
|
|
FROM rust:1.83-slim as trading-builder
|
|
|
|
# Install build dependencies
|
|
RUN apt-get update && apt-get install -y \
|
|
build-essential \
|
|
pkg-config \
|
|
libssl-dev \
|
|
ca-certificates \
|
|
libpq-dev \
|
|
protobuf-compiler \
|
|
musl-tools \
|
|
musl-dev \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
# Add musl target for static linking
|
|
RUN rustup target add x86_64-unknown-linux-musl
|
|
|
|
# Ultra-performance Cargo configuration
|
|
ENV CARGO_NET_GIT_FETCH_WITH_CLI=true
|
|
ENV CARGO_INCREMENTAL=0
|
|
ENV CARGO_PROFILE_RELEASE_LTO=true
|
|
ENV CARGO_PROFILE_RELEASE_CODEGEN_UNITS=1
|
|
ENV CARGO_PROFILE_RELEASE_PANIC=abort
|
|
ENV CARGO_PROFILE_RELEASE_OPT_LEVEL=3
|
|
ENV CARGO_PROFILE_RELEASE_DEBUG=false
|
|
ENV CARGO_PROFILE_RELEASE_DEBUG_ASSERTIONS=false
|
|
ENV CARGO_PROFILE_RELEASE_OVERFLOW_CHECKS=false
|
|
ENV CARGO_PROFILE_RELEASE_STRIP=true
|
|
|
|
# Performance-critical build flags
|
|
ENV RUSTFLAGS="-C target-feature=+crt-static -C target-cpu=native -C opt-level=3"
|
|
|
|
WORKDIR /workspace
|
|
|
|
# Copy workspace files
|
|
COPY Cargo.toml Cargo.lock ./
|
|
COPY trading_engine ./trading_engine
|
|
COPY risk ./risk
|
|
COPY ml ./ml
|
|
COPY data ./data
|
|
COPY risk-data ./risk-data
|
|
COPY trading-data ./trading-data
|
|
COPY ml-data ./ml-data
|
|
COPY tli ./tli
|
|
COPY backtesting ./backtesting
|
|
COPY adaptive-strategy ./adaptive-strategy
|
|
COPY market-data ./market-data
|
|
COPY database ./database
|
|
COPY common ./common
|
|
COPY storage ./storage
|
|
COPY config ./config
|
|
COPY model_loader ./model_loader
|
|
COPY services/trading_service ./services/trading_service
|
|
COPY services/ml_training_service ./services/ml_training_service
|
|
COPY services/api_gateway ./services/api_gateway
|
|
COPY services/load_tests ./services/load_tests
|
|
COPY services/stress_tests ./services/stress_tests
|
|
COPY services/integration_tests ./services/integration_tests
|
|
COPY services/backtesting_service ./services/backtesting_service
|
|
COPY tests ./tests
|
|
COPY tests/e2e ./tests/e2e
|
|
COPY services/trading_service ./services/trading_service
|
|
|
|
# Build with static linking and maximum optimization
|
|
RUN cargo build \
|
|
--release \
|
|
--target x86_64-unknown-linux-musl \
|
|
--package trading_service \
|
|
--features minimal
|
|
|
|
# Strip additional symbols for minimum binary size
|
|
RUN strip target/x86_64-unknown-linux-musl/release/trading_service
|
|
|
|
# =============================================================================
|
|
# ULTRA-PERFORMANCE RUNTIME - Distroless for Minimal Overhead
|
|
# =============================================================================
|
|
FROM gcr.io/distroless/static-debian12
|
|
|
|
# Ultra-minimal runtime environment
|
|
# - No shell, no package manager, no libc
|
|
# - Only the binary and minimal certificates
|
|
# - ~2MB container overhead
|
|
# - Designed for <1ns container latency impact
|
|
|
|
# Copy the statically linked binary
|
|
COPY --from=trading-builder /workspace/target/x86_64-unknown-linux-musl/release/trading_service /trading_service
|
|
|
|
# Copy SSL certificates for HTTPS connections
|
|
COPY --from=trading-builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
|
|
|
|
# Performance-critical environment variables
|
|
ENV MALLOC_CONF="background_thread:false,dirty_decay_ms:0,muzzy_decay_ms:0,abort_conf:true"
|
|
ENV RUST_LOG=error
|
|
ENV RUST_BACKTRACE=0
|
|
ENV RUST_LOG_STYLE=never
|
|
|
|
# No user creation - runs as root for maximum performance
|
|
# Security handled at Kubernetes level with securityContext
|
|
|
|
# Expose gRPC port only
|
|
EXPOSE 50051
|
|
|
|
# No health check in ultra-performance mode
|
|
# Health monitoring handled by Kubernetes probes
|
|
|
|
# Entry point - direct binary execution
|
|
ENTRYPOINT ["/trading_service"] |