content: FROM python:3.13-slim AS base
  ENV PYTHONUNBUFFERED=1 \
      PYTHONDONTWRITEBYTECODE=1 \
      PIP_NO_CACHE_DIR=off \
      PIP_DISABLE_PIP_VERSION_CHECK=on \
      PIP_DEFAULT_TIMEOUT=100 \
      PYO3_PYTHON="/usr/local/bin/python3" \
      PYSETUP_PATH="/opt/pysetup" \
      RUSTUP_TOOLCHAIN="stable" \
      BUILD_MODE="release" \
      CC="clang"
  ENV PATH="/root/.local/bin:/root/.cargo/bin:$PATH"
  WORKDIR $PYSETUP_PATH
  
  FROM base AS builder
  
  # Install build deps
  RUN apt-get update && \
      apt-get install -y curl clang git make pkg-config capnproto libcapnp-dev && \
      apt-get clean && \
      rm -rf /var/lib/apt/lists/*
  
  # Install Rust
  RUN curl https://sh.rustup.rs -sSf | bash -s -- -y
  
  # Install UV
  COPY uv-version ./
  RUN UV_VERSION=$(cat uv-version) && curl -LsSf https://astral.sh/uv/$UV_VERSION/install.sh | sh
  
  # Install package requirements
  COPY uv.lock pyproject.toml build.py ./
  RUN uv sync --no-install-package nautilus_trader
  
  # Build nautilus_trader
  COPY Cargo.toml ./
  COPY Cargo.lock ./
  COPY crates ./crates
  RUN cargo build --lib --release --all-features
  
  COPY nautilus_trader ./nautilus_trader
  COPY README.md ./
  RUN uv build --wheel
  RUN uv pip install --system dist/*.whl
  RUN find /usr/local/lib/python3.13/site-packages -name "*.pyc" -exec rm -f {} \;
  
  # Final application image
  FROM base AS application
  
  COPY --from=builder /usr/local/lib/python3.13/site-packages /usr/local/lib/python3.13/site-packages
  