|
| 1 | +# syntax=docker/dockerfile:1.3-labs |
| 2 | +# |
| 3 | +# Ray C++ Wheel Builder |
| 4 | +# ===================== |
| 5 | +# Builds manylinux2014-compatible ray-cpp wheel using pre-built C++ artifacts from wanda cache. |
| 6 | +# |
| 7 | +# This is a minimal Dockerfile for ray-cpp wheel builds only. |
| 8 | +# It copies only the files needed for the cpp wheel, reducing build context size. |
| 9 | + |
| 10 | +ARG RAY_CORE_IMAGE |
| 11 | +ARG RAY_CPP_CORE_IMAGE |
| 12 | +ARG RAY_JAVA_IMAGE |
| 13 | +ARG RAY_DASHBOARD_IMAGE |
| 14 | +ARG MANYLINUX_VERSION |
| 15 | +ARG HOSTTYPE |
| 16 | + |
| 17 | +FROM ${RAY_CORE_IMAGE} AS ray-core |
| 18 | +FROM ${RAY_CPP_CORE_IMAGE} AS ray-cpp-core |
| 19 | +FROM ${RAY_JAVA_IMAGE} AS ray-java |
| 20 | +FROM ${RAY_DASHBOARD_IMAGE} AS ray-dashboard |
| 21 | + |
| 22 | +# Main build stage - manylinux2014 provides GLIBC 2.17 |
| 23 | +FROM rayproject/manylinux2014:${MANYLINUX_VERSION}-jdk-${HOSTTYPE} AS builder |
| 24 | + |
| 25 | +ARG PYTHON_VERSION=3.10 |
| 26 | +ARG BUILDKITE_COMMIT |
| 27 | + |
| 28 | +# Set environment variables for the build |
| 29 | +ENV BUILDKITE_COMMIT=${BUILDKITE_COMMIT:-unknown} \ |
| 30 | + PYTHON_VERSION=${PYTHON_VERSION} \ |
| 31 | + SKIP_BAZEL_BUILD=1 \ |
| 32 | + WHEEL_TYPE=cpp |
| 33 | + |
| 34 | +WORKDIR /home/forge/ray |
| 35 | + |
| 36 | +# Copy artifacts from all stages |
| 37 | +COPY --from=ray-core /ray_pkg.zip /tmp/ |
| 38 | +COPY --from=ray-core /ray_py_proto.zip /tmp/ |
| 39 | +COPY --from=ray-java /ray_java_pkg.zip /tmp/ |
| 40 | +COPY --from=ray-dashboard /dashboard.tar.gz /tmp/ |
| 41 | + |
| 42 | +# Minimal source files needed for cpp wheel build |
| 43 | +COPY --chown=2000:100 ci/build/build-manylinux-wheel.sh ci/build/ |
| 44 | +COPY --chown=2000:100 README.rst pyproject.toml ./ |
| 45 | +COPY --chown=2000:100 python/setup.py python/ |
| 46 | +COPY --chown=2000:100 python/LICENSE.txt python/ |
| 47 | +COPY --chown=2000:100 python/MANIFEST.in python/ |
| 48 | +COPY --chown=2000:100 python/ray/_version.py python/ray/ |
| 49 | + |
| 50 | +USER forge |
| 51 | +RUN --mount=from=ray-cpp-core,source=/,target=/ray-cpp-core,ro \ |
| 52 | + <<'EOF' |
| 53 | +#!/bin/bash |
| 54 | +set -euo pipefail |
| 55 | + |
| 56 | +PY_VERSION="${PYTHON_VERSION//./}" |
| 57 | +PY_BIN="cp${PY_VERSION}-cp${PY_VERSION}" |
| 58 | + |
| 59 | +# Verify required artifacts exist before unpacking |
| 60 | +for f in /tmp/ray_pkg.zip /tmp/ray_py_proto.zip /tmp/ray_java_pkg.zip /tmp/dashboard.tar.gz; do |
| 61 | + [[ -f "$f" ]] || { echo "ERROR: missing artifact: $f"; exit 1; } |
| 62 | +done |
| 63 | + |
| 64 | +# Verify cpp core artifacts exist |
| 65 | +if [[ ! -f /ray-cpp-core/ray_cpp_pkg.zip ]]; then |
| 66 | + echo "ERROR: ray_cpp_pkg.zip not found - required for cpp wheel build" |
| 67 | + exit 1 |
| 68 | +fi |
| 69 | + |
| 70 | +# Clean extraction dirs to avoid stale leftovers |
| 71 | +rm -rf /tmp/ray_pkg /tmp/ray_java_pkg /tmp/ray_cpp_pkg |
| 72 | +mkdir -p /tmp/ray_pkg /tmp/ray_java_pkg /tmp/ray_cpp_pkg |
| 73 | + |
| 74 | +# Unpack pre-built artifacts |
| 75 | +unzip -o /tmp/ray_pkg.zip -d /tmp/ray_pkg |
| 76 | +unzip -o /tmp/ray_py_proto.zip -d python/ |
| 77 | +unzip -o /tmp/ray_java_pkg.zip -d /tmp/ray_java_pkg |
| 78 | +mkdir -p python/ray/dashboard/client/build |
| 79 | +tar -xzf /tmp/dashboard.tar.gz -C python/ray/dashboard/client/build/ |
| 80 | + |
| 81 | +# C++ core artifacts |
| 82 | +cp -r /tmp/ray_pkg/ray/* python/ray/ |
| 83 | + |
| 84 | +# Java JARs |
| 85 | +cp -r /tmp/ray_java_pkg/ray/* python/ray/ |
| 86 | + |
| 87 | +# C++ API artifacts (headers, libs, examples) |
| 88 | +unzip -o /ray-cpp-core/ray_cpp_pkg.zip -d /tmp/ray_cpp_pkg |
| 89 | +cp -r /tmp/ray_cpp_pkg/ray/cpp python/ray/ |
| 90 | + |
| 91 | +# Build cpp wheel |
| 92 | +export WHEEL_TYPE=cpp |
| 93 | +./ci/build/build-manylinux-wheel.sh "$PY_BIN" |
| 94 | + |
| 95 | +# Sanity check: ensure wheels exist |
| 96 | +shopt -s nullglob |
| 97 | +wheels=(.whl/*.whl) |
| 98 | +if (( ${#wheels[@]} == 0 )); then |
| 99 | + echo "ERROR: No wheels produced in .whl/" |
| 100 | + ls -la .whl || true |
| 101 | + exit 1 |
| 102 | +fi |
| 103 | + |
| 104 | +EOF |
| 105 | + |
| 106 | +FROM scratch |
| 107 | +COPY --from=builder /home/forge/ray/.whl/*.whl / |
0 commit comments