diff --git a/llama_stack/distribution/build_container.sh b/llama_stack/distribution/build_container.sh index 6e794b36f..74776dd7d 100755 --- a/llama_stack/distribution/build_container.sh +++ b/llama_stack/distribution/build_container.sh @@ -19,6 +19,9 @@ UV_HTTP_TIMEOUT=${UV_HTTP_TIMEOUT:-500} # mounting is not supported by docker buildx, so we use COPY instead USE_COPY_NOT_MOUNT=${USE_COPY_NOT_MOUNT:-} +# Mount command for cache container .cache, can be overridden by the user if needed +MOUNT_CACHE=${MOUNT_CACHE:-"--mount=type=cache,id=llama-stack-cache,target=/root/.cache"} + # Path to the run.yaml file in the container RUN_CONFIG_PATH=/app/run.yaml @@ -125,11 +128,16 @@ RUN pip install uv EOF fi +# Set the link mode to copy so that uv doesn't attempt to symlink to the cache directory +add_to_container << EOF +ENV UV_LINK_MODE=copy +EOF + # Add pip dependencies first since llama-stack is what will change most often # so we can reuse layers. if [ -n "$pip_dependencies" ]; then add_to_container << EOF -RUN uv pip install --no-cache $pip_dependencies +RUN $MOUNT_CACHE uv pip install $pip_dependencies EOF fi @@ -137,7 +145,7 @@ if [ -n "$special_pip_deps" ]; then IFS='#' read -ra parts <<<"$special_pip_deps" for part in "${parts[@]}"; do add_to_container <