Files
foxhunt/services/ml_training_service/Dockerfile
jgrusewski d8d51aa2d0 fix(docker): add missing workspace members and SQLX_OFFLINE to all Dockerfiles
All 6 service Dockerfiles were missing newly-added workspace crates
(web-gateway, ctrader-openapi, foxhunt-deploy, broker_gateway_service),
causing cargo workspace resolution failures during Docker builds.

Changes across all Dockerfiles:
- Add COPY directives for web-gateway, ctrader-openapi, foxhunt-deploy,
  broker_gateway_service (new workspace members since Dockerfiles written)
- Add SQLX_OFFLINE=true env and .sqlx cache copy where missing
- Add perl and make system deps (needed for OpenSSL build from source)
- Remove COPY migrations (dir excluded by .dockerignore, not needed)
- Expand broker_gateway_service from 3-crate to full workspace copy

Validated: docker build --check passes all 6, cargo check -p passes all 6.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-23 16:46:24 +01:00

125 lines
4.1 KiB
Docker

# Multi-stage build for Foxhunt ML Training Service
# Wave 112 Agent 18: CUDA-enabled production Docker image
# =============================================================================
# Builder Stage with CUDA Support
# =============================================================================
FROM nvidia/cuda:12.3.0-devel-ubuntu22.04 AS builder
# Install Rust
RUN apt-get update && apt-get install -y \
curl \
build-essential \
&& curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y \
&& . $HOME/.cargo/env \
&& rustup default stable \
&& rustup component add rustfmt clippy
ENV PATH="/root/.cargo/bin:${PATH}"
# Install build dependencies including CUDA toolkit
RUN apt-get update && apt-get install -y \
pkg-config \
libssl-dev \
protobuf-compiler \
nvidia-cuda-toolkit \
&& rm -rf /var/lib/apt/lists/*
# Set working directory
WORKDIR /build
# Set CUDA environment variables to skip GPU detection during build
# CUDA 13.0 matches development environment, RTX 3050 Ti = compute capability 8.6
ENV CUDARC_CUDA_VERSION=13000
ENV CUDA_COMPUTE_CAP=86
# Copy workspace manifests
COPY Cargo.toml Cargo.lock ./
# Copy sqlx offline cache for compile-time query verification
COPY .sqlx ./.sqlx
# Copy workspace members to satisfy manifest dependencies
COPY trading_engine ./trading_engine
COPY risk ./risk
COPY risk-data ./risk-data
COPY trading-data ./trading-data
COPY tli ./tli
COPY ml ./ml
COPY ml-data ./ml-data
COPY data ./data
COPY backtesting ./backtesting
COPY adaptive-strategy ./adaptive-strategy
COPY common ./common
COPY storage ./storage
COPY model_loader ./model_loader
COPY market-data ./market-data
COPY database ./database
COPY config ./config
COPY web-gateway ./web-gateway
COPY ctrader-openapi ./ctrader-openapi
COPY foxhunt-deploy ./foxhunt-deploy
COPY services/backtesting_service ./services/backtesting_service
COPY services/broker_gateway_service ./services/broker_gateway_service
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/data_acquisition_service ./services/data_acquisition_service
COPY services/trading_agent_service ./services/trading_agent_service
COPY tests ./tests
# Enable sqlx offline mode to use cached query metadata
ENV SQLX_OFFLINE=true
# Build the application (CUDA available at runtime via nvidia/cuda base image)
RUN cargo build --release -p ml_training_service
# =============================================================================
# Runtime Stage with CUDA Runtime
# =============================================================================
FROM nvidia/cuda:12.3.0-runtime-ubuntu22.04
# Install runtime dependencies
RUN apt-get update && apt-get install -y \
ca-certificates \
libssl3 \
curl \
&& rm -rf /var/lib/apt/lists/*
# Download and install grpc_health_probe
RUN curl -sSL https://github.com/grpc-ecosystem/grpc-health-probe/releases/download/v0.4.25/grpc_health_probe-linux-amd64 \
-o /usr/local/bin/grpc_health_probe && \
chmod +x /usr/local/bin/grpc_health_probe
# Create non-root user
RUN groupadd --system --gid 1000 foxhunt && \
useradd --system --uid 1000 --gid foxhunt --shell /bin/bash foxhunt
# Create application directories
RUN mkdir -p /app/config /app/logs /app/models /app/checkpoints && \
chown -R foxhunt:foxhunt /app
# Set working directory
WORKDIR /app
# Copy binary from builder
COPY --from=builder /build/target/release/ml_training_service ./ml_training_service
RUN chmod +x ./ml_training_service
# Switch to non-root user
USER foxhunt
# Expose gRPC, metrics, and health ports
EXPOSE 50053 9094 8080
# Health check using HTTP endpoint (no TLS required)
HEALTHCHECK --interval=10s --timeout=5s --start-period=30s --retries=3 \
CMD curl -f http://localhost:8080/health || exit 1
# Run the application with default serve command
ENTRYPOINT ["./ml_training_service"]
CMD ["serve"]