build.sh 1.4 KB

1234567891011121314151617181920212223242526272829303132
  1. #!/usr/bin/env bash
  2. # Build the SM121 DeepSeek-V4-Flash-Vision-Exp image. The generic driver
  3. # forwards every KEY=VAL pin in versions.env as a --build-arg to the
  4. # Dockerfile; TAG and BASE_IMAGE can be overridden via the environment for
  5. # the fork comparison (TAG=dsv4-flash-vision-eugr:local and
  6. # TAG=dsv4-flash-vision-aiden:local from the same context).
  7. set -euo pipefail
  8. cd "$(dirname "$0")"
  9. TAG="${TAG:-dsv4-flash-vision:local}"
  10. ARGS=()
  11. while IFS= read -r line; do
  12. case "$line" in
  13. ''|\#*) continue ;;
  14. esac
  15. key="${line%%=*}"; val="${line#*=}"
  16. val="${val%\"}"; val="${val#\"}"
  17. [ -n "$key" ] && ARGS+=(--build-arg "${key}=${val}")
  18. done < versions.env
  19. [ -n "${BASE_IMAGE:-}" ] && ARGS+=(--build-arg "BASE_IMAGE=${BASE_IMAGE}")
  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/sm121-cache/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} ==="