build.sh 1.2 KB

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