build.sh 1.3 KB

1234567891011121314151617181920212223242526272829303132
  1. #!/usr/bin/env bash
  2. # Build the SM121 GLM-5.3-Flash NVFP4 (lab quant) image: day-0 base +
  3. # NoPE-MLA mod + FujitsuPolycom lab-checkpoint patches.
  4. #
  5. # Generic driver: forwards every KEY=VAL pin in versions.env as a --build-arg
  6. # to the Dockerfile. TAG is set by the sm121 launcher to the recipe's
  7. # docker_image (manual build: TAG=glm53-flash-nvfp4-lab:local bash build.sh).
  8. set -euo pipefail
  9. cd "$(dirname "$0")"
  10. TAG="${TAG:-glm53-flash-exl3:local}"
  11. ARGS=()
  12. while IFS= read -r line; do
  13. case "$line" in
  14. ''|\#*) continue ;;
  15. esac
  16. key="${line%%=*}"; val="${line#*=}"
  17. val="${val%\"}"; val="${val#\"}" # versions.env values may be shell-quoted
  18. [ -n "$key" ] && ARGS+=(--build-arg "${key}=${val}")
  19. done < versions.env
  20. echo "=== Building ${TAG} ==="
  21. # Persistent buildkit cache (per node, shared across image dirs): the
  22. # version-independent stages (apt, torch, CUDA base) are reused across
  23. # rebuilds — only the pinned source stages (vllm/b12x/…) re-download and
  24. # re-compile. Override the dir with SM121_BUILDKIT_CACHE if desired.
  25. CACHE_DIR="${SM121_BUILDKIT_CACHE:-$HOME/.cache/sm121-buildkit}"
  26. mkdir -p "${CACHE_DIR}"
  27. docker buildx build "${ARGS[@]}" --cache-from "type=local,src=${CACHE_DIR}" \
  28. --cache-to "type=local,dest=${CACHE_DIR},mode=max" \
  29. --progress=plain --load -t "${TAG}" -f Dockerfile . 2>&1
  30. echo "=== Done: ${TAG} ==="