install.sh: show a progress bar while loading the image

`docker load -i` shows no useful progress and the installer captured its output
into a variable, so a ~12G load looked like a multi-minute hang. Stream the
tarball through a meter into `docker load` instead — the file read tracks load
progress closely. Prefer `pv` (bar + ETA), fall back to GNU `dd status=progress`
(bytes + throughput), else plain load with a tip to install pv. The meter draws
on stderr so the "Loaded image:" line is still captured. Pre-authenticate sudo
first so its prompt doesn't collide with the bar.
Co-Authored-By: 's avatarClaude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RdMufYvtTbtGDWsiZVoXce
parent 41093571
...@@ -54,8 +54,27 @@ if ! "$ENGINE" info >/dev/null 2>&1; then ...@@ -54,8 +54,27 @@ if ! "$ENGINE" info >/dev/null 2>&1; then
fi fi
fi fi
say "[install] loading image from $IMAGE_TAR — this is large, please wait…" # Pre-authenticate sudo (if used) so its password prompt doesn't collide with the
LOAD_OUT="$("${DK[@]}" load -i "$IMAGE_TAR")" # progress bar drawn below.
if [ "${DK[0]}" = "sudo" ]; then sudo -v || true; fi
# Load the image WITH a progress bar. `docker load -i` shows nothing useful and we
# used to capture its output (hiding even that), so a 12G load looked like a hang.
# Stream the tarball through a meter into `docker load` instead: the read of the
# file tracks load progress closely. `pv` gives a real bar+ETA; GNU `dd` is the
# fallback (bytes + throughput); otherwise plain load. The progress is drawn on
# stderr, so command substitution still captures the "Loaded image:" line.
IMG_SIZE="$(stat -c %s "$IMAGE_TAR" 2>/dev/null || wc -c < "$IMAGE_TAR" 2>/dev/null || echo 0)"
say "[install] loading image from $IMAGE_TAR — this is large (~$(( IMG_SIZE / 1024 / 1024 / 1024 ))G), please wait…"
if command -v pv >/dev/null 2>&1 && [ "${IMG_SIZE:-0}" -gt 0 ]; then
LOAD_OUT="$(pv -s "$IMG_SIZE" "$IMAGE_TAR" | "${DK[@]}" load)"
elif dd --version >/dev/null 2>&1; then
LOAD_OUT="$(dd if="$IMAGE_TAR" bs=4M status=progress | "${DK[@]}" load)"
else
say "[install] (tip: install 'pv' for a progress bar) loading…"
LOAD_OUT="$("${DK[@]}" load -i "$IMAGE_TAR")"
fi
say ""
say "$LOAD_OUT" say "$LOAD_OUT"
# e.g. "Loaded image: coderai:full_all_0.1.0" — the tag we just installed. # e.g. "Loaded image: coderai:full_all_0.1.0" — the tag we just installed.
LOADED_TAG="$(printf '%s\n' "$LOAD_OUT" | sed -n 's/^Loaded image: //p' | head -1)" LOADED_TAG="$(printf '%s\n' "$LOAD_OUT" | sed -n 's/^Loaded image: //p' | head -1)"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment