- Added risk-data, trading-data, ml-data to all .dev and .production - Added tli, backtesting, adaptive-strategy to all variants - Added market-data, database to all variants - Ensures Cargo workspace manifest satisfied during build All 9 Dockerfile variants now have complete workspace member copies. Note: Backtesting Dockerfiles have duplicate COPY lines (will clean in next commit) Wave 125 Phase 3B - Complete Dockerfile workspace fix
110 lines
3.3 KiB
Docker
110 lines
3.3 KiB
Docker
# =============================================================================
|
|
# FOXHUNT BACKTESTING SERVICE - CLOUD-NATIVE PRODUCTION CONTAINER
|
|
# =============================================================================
|
|
# This Dockerfile creates a balanced performance container for the Backtesting Service
|
|
# optimized for cloud-native deployment with service mesh compatibility
|
|
|
|
# =============================================================================
|
|
# BUILDER STAGE - Optimized Build
|
|
# =============================================================================
|
|
FROM rust:1.75-slim as backtesting-builder
|
|
|
|
# Install build dependencies
|
|
RUN apt-get update && apt-get install -y \
|
|
build-essential \
|
|
pkg-config \
|
|
libssl-dev \
|
|
ca-certificates \
|
|
libpq-dev \
|
|
protobuf-compiler \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
# Production 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_OPT_LEVEL=3
|
|
ENV CARGO_PROFILE_RELEASE_DEBUG=false
|
|
ENV CARGO_PROFILE_RELEASE_STRIP=true
|
|
|
|
WORKDIR /workspace
|
|
|
|
# Copy workspace files for backtesting
|
|
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 backtesting ./backtesting
|
|
COPY adaptive-strategy ./adaptive-strategy
|
|
COPY config ./config
|
|
COPY model_loader ./model_loader
|
|
COPY services/backtesting_service ./services/backtesting_service
|
|
|
|
# Build backtesting service with production optimizations
|
|
RUN cargo build \
|
|
--release \
|
|
--package backtesting_service \
|
|
--features standalone
|
|
|
|
# =============================================================================
|
|
# CLOUD-NATIVE RUNTIME - Ubuntu Slim with Service Mesh Support
|
|
# =============================================================================
|
|
FROM ubuntu:22.04-slim
|
|
|
|
# Install runtime dependencies
|
|
RUN apt-get update && apt-get install -y \
|
|
ca-certificates \
|
|
libssl3 \
|
|
libpq5 \
|
|
curl \
|
|
wget \
|
|
# Service mesh compatibility
|
|
iptables \
|
|
&& rm -rf /var/lib/apt/lists/* \
|
|
&& apt-get clean
|
|
|
|
# Create app user and directories
|
|
RUN groupadd -r foxhunt && useradd -r -g foxhunt foxhunt
|
|
RUN mkdir -p /app/config /app/data /app/backtests /app/reports /app/logs \
|
|
&& chown -R foxhunt:foxhunt /app
|
|
|
|
# Copy binary from builder
|
|
COPY --from=backtesting-builder /workspace/target/release/backtesting_service /app/backtesting_service
|
|
RUN chmod +x /app/backtesting_service
|
|
|
|
# Copy configuration templates
|
|
COPY services/backtesting_service/config/ /app/config/ || true
|
|
|
|
# Switch to app user
|
|
USER foxhunt
|
|
WORKDIR /app
|
|
|
|
# Expose gRPC and health check ports
|
|
EXPOSE 50052 8082
|
|
|
|
# Resource limits for cloud deployment
|
|
ENV RUST_LOG=info
|
|
ENV RUST_BACKTRACE=0
|
|
ENV FOXHUNT_CONFIG=/app/config/production.toml
|
|
|
|
# Health check for Kubernetes
|
|
HEALTHCHECK --interval=30s --timeout=10s --start-period=45s --retries=3 \
|
|
CMD curl -f http://localhost:8082/health || exit 1
|
|
|
|
# Graceful shutdown support
|
|
STOPSIGNAL SIGTERM
|
|
|
|
# Entry point with proper signal handling
|
|
CMD ["./backtesting_service"] |