fix(ci): unset empty UV index env vars to prevent uv errors

Docker ARGs with empty defaults (ARG VAR="") are exposed as environment
variables with empty string values in RUN commands. UV interprets these
as if --index-strategy "" was passed, causing "value required" errors.

Fixed by:
- Unsetting UV_EXTRA_INDEX_URL and UV_INDEX_STRATEGY at the start of RUN blocks
- Saving values early and only restoring them for editable installs with RC deps
- Ensuring all other install modes run with clean environment

This fixes container builds failing with:
  error: a value is required for '--index-strategy <UV_INDEX_STRATEGY>'
This commit is contained in:
Ashwin Bharambe 2025-10-31 13:21:57 -07:00
parent f8fe3018af
commit 02cfdcca18

View file

@ -64,7 +64,9 @@ COPY . /workspace
# Install the client package if it is provided
# NOTE: this is installed before llama-stack since llama-stack depends on llama-stack-client-python
# Unset UV index env vars to ensure we only use PyPI for the client
RUN set -eux; \
unset UV_EXTRA_INDEX_URL UV_INDEX_STRATEGY; \
if [ -n "$LLAMA_STACK_CLIENT_DIR" ]; then \
if [ ! -d "$LLAMA_STACK_CLIENT_DIR" ]; then \
echo "LLAMA_STACK_CLIENT_DIR is set but $LLAMA_STACK_CLIENT_DIR does not exist" >&2; \
@ -74,18 +76,20 @@ RUN set -eux; \
fi;
# Install llama-stack
# Use UV_EXTRA_INDEX_URL inline only for this step to avoid affecting distribution deps
# Use UV_EXTRA_INDEX_URL inline only for editable install with RC dependencies
RUN set -eux; \
SAVED_UV_EXTRA_INDEX_URL="${UV_EXTRA_INDEX_URL:-}"; \
SAVED_UV_INDEX_STRATEGY="${UV_INDEX_STRATEGY:-}"; \
unset UV_EXTRA_INDEX_URL UV_INDEX_STRATEGY; \
if [ "$INSTALL_MODE" = "editable" ]; then \
if [ ! -d "$LLAMA_STACK_DIR" ]; then \
echo "INSTALL_MODE=editable requires LLAMA_STACK_DIR to point to a directory inside the build context" >&2; \
exit 1; \
fi; \
if [ -n "$UV_EXTRA_INDEX_URL" ] && [ -n "$UV_INDEX_STRATEGY" ]; then \
UV_EXTRA_INDEX_URL="$UV_EXTRA_INDEX_URL" UV_INDEX_STRATEGY="$UV_INDEX_STRATEGY" \
if [ -n "$SAVED_UV_EXTRA_INDEX_URL" ] && [ -n "$SAVED_UV_INDEX_STRATEGY" ]; then \
UV_EXTRA_INDEX_URL="$SAVED_UV_EXTRA_INDEX_URL" UV_INDEX_STRATEGY="$SAVED_UV_INDEX_STRATEGY" \
uv pip install --no-cache-dir -e "$LLAMA_STACK_DIR"; \
else \
unset UV_EXTRA_INDEX_URL UV_INDEX_STRATEGY; \
uv pip install --no-cache-dir -e "$LLAMA_STACK_DIR"; \
fi; \
elif [ "$INSTALL_MODE" = "test-pypi" ]; then \