57 lines
1.3 KiB
Bash
Executable File
57 lines
1.3 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
CURDIR="$(realpath "$(dirname "${0}")")"
|
|
|
|
get_latest() {
|
|
# Find all tags for zefie/nvfp4_quant, sort by creation timestamp (descending), return the newest
|
|
latest_image=$(docker images --format '{{.CreatedAt}}\t{{.Repository}}:{{.Tag}}' zefie/nvfp4_quant \
|
|
| sort -r \
|
|
| cut -f2- \
|
|
| grep -v latest \
|
|
| head -n 1)
|
|
|
|
if [[ -z "$latest_image" ]]; then
|
|
echo "No images found for repository 'zefie/nvfp4_quant'" >&2
|
|
exit 1
|
|
fi
|
|
|
|
echo "$latest_image"
|
|
}
|
|
|
|
if [ "${1}" == "build" ]; then
|
|
THETAG=$(date +%Y%m%d)
|
|
cd "$(realpath "$(dirname "${0}")")"
|
|
docker buildx build --tag "zefie/nvfp4_quant:${THETAG}" .
|
|
elif [ "${1}" == "mklatest" ]; then
|
|
LATEST=$(get_latest)
|
|
if [ -z "${LATEST}" ]; then
|
|
exit 1;
|
|
fi
|
|
docker tag "${LATEST}" zefie/nvfp4_quant:latest
|
|
echo "Set zefie/nvfp4_quant:latest to ${LATEST}"
|
|
elif [ "${1}" == "run" ]; then
|
|
shift
|
|
IMAGE=$(get_latest)
|
|
if [ -z "${IMAGE}" ]; then
|
|
exit 1;
|
|
fi
|
|
export EMBEDDED=1
|
|
source "${CURDIR}/nvfp4_quant"
|
|
CMD=("${COMMON[@]}" "${@}")
|
|
echo "Executing ${CMD[@]}"
|
|
"${CMD[@]}"
|
|
elif [ "${1}" == "push" ]; then
|
|
# push dated one first, then latest
|
|
"${0}" mklatest
|
|
IMAGE=$(get_latest)
|
|
echo "Pushing ${IMAGE}"
|
|
docker push "${IMAGE}"
|
|
echo "Pushing zefie/nvfp4_quant:latest"
|
|
docker push "zefie/nvfp4_quant:latest"
|
|
else
|
|
echo "Usage: ${0} [build|run|mklatest]"
|
|
exit 1;
|
|
fi
|
|
|