This commit is contained in:
Raghotham Murthy 2025-05-28 17:31:32 -07:00
parent fb47cc0931
commit 414642b092
8 changed files with 46 additions and 29 deletions

View file

@ -110,6 +110,7 @@ def build_image(
image_name: str,
template_or_config: str,
run_config: str | None = None,
exit_after_containerfile: bool = False,
):
container_base = build_config.distribution_spec.container_image or "python:3.10-slim"
@ -130,6 +131,10 @@ def build_image(
# build arguments
if run_config is not None:
args.append(run_config)
# Add exit_after_containerfile flag if specified
if exit_after_containerfile:
args.append("--exit-after-containerfile")
elif build_config.image_type == LlamaStackImageType.CONDA.value:
script = str(importlib.resources.files("llama_stack") / "distribution/build_conda_env.sh")
args = [

View file

@ -43,6 +43,7 @@ shift
# Handle optional arguments
run_config=""
special_pip_deps=""
exit_after_containerfile=false
# Check if there are more arguments
# The logics is becoming cumbersom, we should refactor it if we can do better
@ -53,11 +54,19 @@ if [ $# -gt 0 ]; then
shift
# If there's another argument after .yaml, it must be special_pip_deps
if [ $# -gt 0 ]; then
special_pip_deps="$1"
if [[ "$1" == "--exit-after-containerfile" ]]; then
exit_after_containerfile=true
else
special_pip_deps="$1"
fi
fi
else
# If it's not .yaml, it must be special_pip_deps
special_pip_deps="$1"
# If it's not .yaml, check if it's the exit flag
if [[ "$1" == "--exit-after-containerfile" ]]; then
exit_after_containerfile=true
else
special_pip_deps="$1"
fi
fi
fi
@ -270,6 +279,15 @@ printf "Containerfile created successfully in %s/Containerfile\n\n" "$TEMP_DIR"
cat "$TEMP_DIR"/Containerfile
printf "\n"
# Exit after creating Containerfile if requested
if [ "$exit_after_containerfile" = true ]; then
# Copy Containerfile to current directory
cp "$TEMP_DIR/Containerfile" "$BUILD_CONTEXT_DIR/Containerfile"
echo "Containerfile has been copied to $(pwd)/Containerfile"
echo "Exiting after Containerfile creation as requested"
exit 0
fi
# Start building the CLI arguments
CLI_ARGS=()