dmlc-xgboost
SUCCESS
17m 01s
History Source
SummaryIterations1Transcript15Dockerfile
Dockerfile60 lines · 1508 chars
# Multi-stage build for XGBoost from source on Ubuntu jammy

FROM ubuntu:jammy-20260210.1 as builder

# Install build dependencies
RUN apt-get update \
    && apt-get install -y --no-install-recommends \
        build-essential \
        cmake \
        git \
        ca-certificates \
        pkg-config \
        python3-pip \
        libopenmpi-dev \
        openmpi-bin \
    && rm -rf /var/lib/apt/lists/*

WORKDIR /workspace

# Copy source
COPY . .

# Ensure dmlc-core is available with a CMakeLists.txt (fallback to upstream if missing)
RUN if [ -d dmlc-core ]; then \
        if [ ! -f dmlc-core/CMakeLists.txt ]; then \
            rm -rf dmlc-core; \
            git clone --depth 1 https://github.com/dmlc/dmlc-core.git dmlc-core; \
        fi; \
    else \
        git clone --depth 1 https://github.com/dmlc/dmlc-core.git dmlc-core; \
    fi

# Configure and build
RUN cmake -S . -B build -DCMAKE_BUILD_TYPE=Release
RUN cmake --build build -j$(nproc)

# Install the built artifacts to /usr/local
RUN cmake --install build

FROM ubuntu:jammy-20260210.1 as runtime

# Runtime dependencies
RUN apt-get update \
    && apt-get install -y --no-install-recommends \
        libstdc++6 \
        libgomp1 \
        ca-certificates \
        pkg-config \
    && rm -rf /var/lib/apt/lists/*

# Copy installed artifacts from builder
COPY --from=builder /usr/local /usr/local

# Ensure dynamic linker can find libs
ENV LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH

WORKDIR /workspace

CMD ["/bin/bash"]