build.sh 1.3 KB

12345678910111213141516171819202122232425262728293031
  1. #!/usr/bin/env bash
  2. # Build the Mia TP4 production image (docker-images/mia-tp4, vendored from
  3. # github.com/MiaAI-Lab/DeepSeek-v4.1-Flash-DGX-Sparks @ cad252b7d3
  4. # (2026-09-25, the "production line" README rev)). The Dockerfile's fetch
  5. # stage pulls the pinned third-party trees declared in runtime/sources.manifest
  6. # (checks sha256) and applies the repo's own patches — GitHub + PyPI must be
  7. # reachable from the build node.
  8. #
  9. # TAG is set by the sm121 launcher to the recipe's docker_image
  10. # (manual: TAG=dsv41-4x-spark:mia-tp4 bash build.sh).
  11. set -euo pipefail
  12. cd "$(dirname "$0")"
  13. TAG="${TAG:-dsv41-4x-spark:mia-tp4}"
  14. ARGS=()
  15. while IFS= read -r line; do
  16. case "$line" in ''|\#*) continue ;; esac
  17. key="${line%%=*}"; val="${line#*=}"
  18. val="${val%\"}"; val="${val#\"}"
  19. [ -n "$key" ] && ARGS+=(--build-arg "${key}=${val}")
  20. done < versions.env
  21. echo "=== Building ${TAG} (Dockerfile.canary-roce) ==="
  22. # Persistent buildkit cache; the pinned fetch stage is content-addressed, so
  23. # only the adapter/test layers re-run on a rebuild.
  24. CACHE_DIR="${SM121_BUILDKIT_CACHE:-$HOME/.cache/sm121-buildkit}"
  25. mkdir -p "${CACHE_DIR}"
  26. docker buildx build "${ARGS[@]}" --cache-from "type=local,src=${CACHE_DIR}" \
  27. --cache-to "type=local,dest=${CACHE_DIR},mode=max" \
  28. --progress=plain --load -t "${TAG}" -f Dockerfile.canary-roce . 2>&1
  29. echo "=== Done: ${TAG} ==="