build.sh 1.4 KB

12345678910111213141516171819202122232425262728293031323334
  1. #!/usr/bin/env bash
  2. # Build Solar Open2 250B NVFP4 (Nota) Docker image for DGX Spark (aarch64/sm_121a).
  3. # All build inputs are version-pinned in versions.env and locks/.
  4. #
  5. # Generic driver: forwards every KEY=VAL pin in versions.env as a
  6. # --build-arg to the Dockerfile (no hardcoded variable list). The sm121
  7. # launcher writes a merged versions.env here when a recipe carries
  8. # [build.versions] overrides (recipe wins over the image defaults).
  9. set -euo pipefail
  10. cd "$(dirname "$0")"
  11. TAG="${TAG:-solar-open2-nvfp4:probe}"
  12. ARGS=()
  13. while IFS= read -r line; do
  14. # Skip blank lines and comments (# ...).
  15. case "$line" in
  16. ''|\#*) continue ;;
  17. esac
  18. key="${line%%=*}"
  19. val="${line#*=}"
  20. [ -n "$key" ] && ARGS+=(--build-arg "${key}=${val}")
  21. done < versions.env
  22. echo "=== Building ${TAG} ==="
  23. # Persistent buildkit cache (per node, shared across image dirs): the
  24. # version-independent stages (apt, torch, CUDA base) are reused across
  25. # rebuilds — only the pinned source stages (vllm/b12x/…) re-download and
  26. # re-compile. Override the dir with SM121_BUILDKIT_CACHE if desired.
  27. CACHE_DIR="${SM121_BUILDKIT_CACHE:-$HOME/.cache/sm121-buildkit}"
  28. mkdir -p "${CACHE_DIR}"
  29. docker buildx build "${ARGS[@]}" --cache-from "type=local,src=${CACHE_DIR}" \
  30. --cache-to "type=local,dest=${CACHE_DIR},mode=max" \
  31. --progress=plain --load -t "${TAG}" -f Dockerfile . 2>&1
  32. echo "=== Done: ${TAG} ==="