feat: improve llama.cpp base image tag for cpu (#391)

Refactor the container build script to resolve llama.cpp base image for CPU, also tag these builds accordingly.

- For CPU containers, now fetch the latest 'server' tagged llama.cpp image instead of using a generic 'server' tag
- Cleans up the docker build command to use dynamic BASE_TAG variable
- Maintains existing push functionality for built images
This commit is contained in:
Ryan Steed
2025-11-08 17:56:49 +00:00
committed by GitHub
parent 6aedbe121a
commit eab2efd7b5

View File

@@ -25,18 +25,19 @@ fi
LS_VER=$(curl -s https://api.github.com/repos/mostlygeek/llama-swap/releases/latest | jq -r .tag_name | sed 's/v//') LS_VER=$(curl -s https://api.github.com/repos/mostlygeek/llama-swap/releases/latest | jq -r .tag_name | sed 's/v//')
if [ "$ARCH" == "cpu" ]; then if [ "$ARCH" == "cpu" ]; then
# cpu only containers just use the latest available # cpu only containers just use the server tag
CONTAINER_LATEST="ghcr.io/mostlygeek/llama-swap:cpu" LCPP_TAG=$(curl -s -H "Authorization: Bearer $GITHUB_TOKEN" \
echo "Building ${CONTAINER_LATEST} $LS_VER" "https://api.github.com/users/ggml-org/packages/container/llama.cpp/versions" \
docker build -f llama-swap.Containerfile --build-arg BASE_TAG=server --build-arg LS_VER=${LS_VER} -t ${CONTAINER_LATEST} . | jq -r '.[] | select(.metadata.container.tags[] | startswith("server")) | .metadata.container.tags[]' \
if [ "$PUSH_IMAGES" == "true" ]; then | sort -r | head -n1 | awk -F '-' '{print $3}')
docker push ${CONTAINER_LATEST} BASE_TAG=server-${LCPP_TAG}
fi
else else
LCPP_TAG=$(curl -s -H "Authorization: Bearer $GITHUB_TOKEN" \ LCPP_TAG=$(curl -s -H "Authorization: Bearer $GITHUB_TOKEN" \
"https://api.github.com/users/ggml-org/packages/container/llama.cpp/versions" \ "https://api.github.com/users/ggml-org/packages/container/llama.cpp/versions" \
| jq -r --arg arch "$ARCH" '.[] | select(.metadata.container.tags[] | startswith("server-\($arch)")) | .metadata.container.tags[]' \ | jq -r --arg arch "$ARCH" '.[] | select(.metadata.container.tags[] | startswith("server-\($arch)")) | .metadata.container.tags[]' \
| sort -r | head -n1 | awk -F '-' '{print $3}') | sort -r | head -n1 | awk -F '-' '{print $3}')
BASE_TAG=server-${ARCH}-${LCPP_TAG}
fi
# Abort if LCPP_TAG is empty. # Abort if LCPP_TAG is empty.
if [[ -z "$LCPP_TAG" ]]; then if [[ -z "$LCPP_TAG" ]]; then
@@ -47,9 +48,8 @@ else
CONTAINER_TAG="ghcr.io/mostlygeek/llama-swap:v${LS_VER}-${ARCH}-${LCPP_TAG}" CONTAINER_TAG="ghcr.io/mostlygeek/llama-swap:v${LS_VER}-${ARCH}-${LCPP_TAG}"
CONTAINER_LATEST="ghcr.io/mostlygeek/llama-swap:${ARCH}" CONTAINER_LATEST="ghcr.io/mostlygeek/llama-swap:${ARCH}"
echo "Building ${CONTAINER_TAG} $LS_VER" echo "Building ${CONTAINER_TAG} $LS_VER"
docker build -f llama-swap.Containerfile --build-arg BASE_TAG=server-${ARCH}-${LCPP_TAG} --build-arg LS_VER=${LS_VER} -t ${CONTAINER_TAG} -t ${CONTAINER_LATEST} . docker build -f llama-swap.Containerfile --build-arg BASE_TAG=${BASE_TAG} --build-arg LS_VER=${LS_VER} -t ${CONTAINER_TAG} -t ${CONTAINER_LATEST} .
if [ "$PUSH_IMAGES" == "true" ]; then if [ "$PUSH_IMAGES" == "true" ]; then
docker push ${CONTAINER_TAG} docker push ${CONTAINER_TAG}
docker push ${CONTAINER_LATEST} docker push ${CONTAINER_LATEST}
fi fi
fi