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