#!/usr/bin/env bash # Build the TensorFold 2x 1017 image (upstream sources at pins + their Dockerfile). # # Uses the classic docker builder (not buildx docker-container): the base # image dsv41-flash:local is local-only (never pushed to a registry), and # the container-driver builder cannot resolve local FROM references. # # Generic driver: forwards every KEY=VAL pin in versions.env as a # --build-arg to the Dockerfile (no hardcoded variable list). The sm121 # launcher writes a merged versions.env here when a recipe carries # [build.versions] overrides (recipe wins over the image defaults). set -euo pipefail cd "$(dirname "$0")" TAG="${TAG:-dsv41-tf-1017:v1}" SRC="${SRC:-/tmp/dsv41-tf-1017-src}" # Sources are fetched OUTSIDE this directory (keeps the image-dir checksum stable). bash ./fetch-sources.sh "$SRC" cp Dockerfile "$SRC/Dockerfile" ARGS=() while IFS= read -r line; do # Skip blank lines and comments (# ...). case "$line" in ''|\#*) continue ;; esac key="${line%%=*}" val="${line#*=}" [ -n "$key" ] && ARGS+=(--build-arg "${key}=${val}") done < versions.env echo "=== Building ${TAG} ===" docker build "${ARGS[@]}" --progress=plain -t "${TAG}" -f "$SRC/Dockerfile" "$SRC" 2>&1 echo "=== Done: ${TAG} ===" # Publish the host-side helper files next to the model cache so the launch # nodes can stage (chat template, Engram packer, CUDA prebuild) WITHOUT needing # the image first — serve runs before_serve hooks before it syncs the image. PUB="${SM121_TF1017_PUBDIR:-/mnt/nas/ai/sm121/dsv41-tf-1017}" if mkdir -p "$PUB" 2>/dev/null; then for f in pack_engram.py prebuild_ext.py prebuild-offline.py pfdense-table.json chat_template.jinja; do cp -f "$SRC/upstream/$(case $f in pack_engram.py) echo build/jayleaton/scripts/pack_engram.py ;; prebuild_ext.py) echo build/jayleaton/scripts/prebuild_ext.py ;; prebuild-offline.py) echo scripts/prebuild-offline.py ;; pfdense-table.json) echo build/jayleaton/config/pfdense-table.json ;; chat_template.jinja) echo build/mia-runtime/files/chat_template.jinja ;; esac)" "$PUB/$f" done echo "$TAG" > "$PUB/IMAGE_TAG" echo "=== helpers published to $PUB ===" fi