- Dockerfile.service: unified multi-stage with sccache S3 support - Dockerfile.web-gateway: Node dashboard + Rust gateway combined - Dockerfile.training: CUDA 12.4 with H100 target (compute cap 9.0) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
101 lines
3.0 KiB
Docker
101 lines
3.0 KiB
Docker
# GPU training image for ML model training Jobs
|
|
# Usage: docker build -f infra/docker/Dockerfile.training .
|
|
# Run: docker run --gpus all foxhunt-training train_dqn [args...]
|
|
|
|
# =============================================================================
|
|
# Stage 1: Builder (CUDA dev image with Rust toolchain)
|
|
# =============================================================================
|
|
FROM nvidia/cuda:12.4.1-cudnn-devel-ubuntu22.04 AS builder
|
|
|
|
ENV DEBIAN_FRONTEND=noninteractive
|
|
|
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
|
curl \
|
|
git \
|
|
build-essential \
|
|
pkg-config \
|
|
libssl-dev \
|
|
protobuf-compiler \
|
|
perl \
|
|
make \
|
|
ca-certificates \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
# Install Rust stable toolchain
|
|
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain stable
|
|
ENV PATH="/root/.cargo/bin:${PATH}"
|
|
|
|
WORKDIR /build
|
|
|
|
# Copy workspace manifests first for layer caching
|
|
COPY Cargo.toml Cargo.lock ./
|
|
COPY .sqlx ./.sqlx
|
|
|
|
# Copy all workspace crate directories
|
|
COPY trading_engine ./trading_engine
|
|
COPY risk ./risk
|
|
COPY risk-data ./risk-data
|
|
COPY trading-data ./trading-data
|
|
COPY fxt ./fxt
|
|
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 ./services
|
|
COPY tests ./tests
|
|
|
|
ENV SQLX_OFFLINE=true
|
|
ENV CUDA_COMPUTE_CAP=90
|
|
|
|
# Build all training example binaries with CUDA support
|
|
RUN cargo build --release -p ml --features ml/cuda \
|
|
--example train_dqn \
|
|
--example train_ppo_parquet \
|
|
--example hyperopt_dqn_demo \
|
|
--example hyperopt_ppo_demo \
|
|
--example hyperopt_tft_demo \
|
|
--example hyperopt_mamba2_demo \
|
|
&& mkdir -p /build/out \
|
|
&& for bin in train_dqn train_ppo_parquet hyperopt_dqn_demo hyperopt_ppo_demo hyperopt_tft_demo hyperopt_mamba2_demo; do \
|
|
cp target/release/examples/${bin} /build/out/ && strip /build/out/${bin}; \
|
|
done
|
|
|
|
# =============================================================================
|
|
# Stage 2: Runtime (CUDA runtime — no compiler, smaller image)
|
|
# =============================================================================
|
|
FROM nvidia/cuda:12.4.1-cudnn-runtime-ubuntu22.04
|
|
|
|
ENV DEBIAN_FRONTEND=noninteractive
|
|
|
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
|
ca-certificates \
|
|
libssl3 \
|
|
curl \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
RUN groupadd -g 1000 foxhunt \
|
|
&& useradd -u 1000 -g foxhunt -m -s /bin/false foxhunt
|
|
|
|
COPY --from=builder /build/out/* /usr/local/bin/
|
|
|
|
# CUDA runtime environment
|
|
ENV NVIDIA_VISIBLE_DEVICES=all
|
|
ENV NVIDIA_DRIVER_CAPABILITIES=compute,utility
|
|
ENV CUDA_COMPUTE_CAP=90
|
|
|
|
USER foxhunt
|
|
|
|
WORKDIR /data
|
|
|
|
CMD ["echo", "Specify training command via K8s Job args"]
|