From b833da0d150c5ed7d3be54ad0f6ebc5155cd5f76 Mon Sep 17 00:00:00 2001 From: Eric Huang Date: Thu, 3 Jul 2025 11:46:21 -0700 Subject: [PATCH] fix: build container script # What does this PR do? ## Test Plan --- llama_stack/distribution/build_container.sh | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/llama_stack/distribution/build_container.sh b/llama_stack/distribution/build_container.sh index d9a918fb5..ec3b6b1ab 100755 --- a/llama_stack/distribution/build_container.sh +++ b/llama_stack/distribution/build_container.sh @@ -202,8 +202,14 @@ install_local_package() { fi if [ "$USE_COPY_NOT_MOUNT" = "true" ]; then + # Docker COPY needs relative path from build context + # we need to copy them to the build context first + local basename=$(basename "$dir") + local temp_name="${basename}-tmp-$$" + echo "Copying $dir to build context as $temp_name..." >&2 + cp -r "$dir" "$BUILD_CONTEXT_DIR/$temp_name" add_to_container << EOF -COPY $dir $mount_point +COPY $temp_name $mount_point EOF fi add_to_container << EOF @@ -327,8 +333,9 @@ $CONTAINER_BINARY build \ -f "$TEMP_DIR/Containerfile" \ "$BUILD_CONTEXT_DIR" -# clean up tmp/configs +# clean up tmp/configs and any temporary copied directories rm -f "$BUILD_CONTEXT_DIR/run.yaml" +rm -rf "$BUILD_CONTEXT_DIR"/*-tmp-* set +x echo "Success!"