mirror of
https://github.com/meta-llama/llama-stack.git
synced 2025-10-09 13:14:39 +00:00
Add api build
subcommand -- WIP
This commit is contained in:
parent
f5620c09ad
commit
3a337c5f1c
7 changed files with 203 additions and 0 deletions
40
llama_toolchain/distribution/build_image.sh
Normal file
40
llama_toolchain/distribution/build_image.sh
Normal file
|
@ -0,0 +1,40 @@
|
|||
#!/bin/bash
|
||||
|
||||
if [ "$#" -ne 4 ]; then
|
||||
echo "Usage: $0 <image_name> <base_image> <pip_dependencies> <entrypoint_command>"
|
||||
echo "Example: $0 my-fastapi-app python:3.9-slim 'fastapi uvicorn' 'python3 -m llama_toolchain.distribution.server --port 8000'"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
IMAGE_NAME=$1
|
||||
BASE_IMAGE=$2
|
||||
PIP_DEPENDENCIES=$3
|
||||
ENTRYPOINT_COMMAND=$4
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
SCRIPT_DIR=$(dirname "$(readlink -f "$0")")
|
||||
SOURCE_DIR=$(dirname $(dirname "$SCRIPT_DIR"))
|
||||
|
||||
TEMP_DIR=$(mktemp -d)
|
||||
echo "Created temporary directory: $TEMP_DIR"
|
||||
|
||||
cat <<EOF >"$TEMP_DIR/Dockerfile"
|
||||
FROM $BASE_IMAGE
|
||||
WORKDIR /app
|
||||
COPY llama_toolchain /app
|
||||
|
||||
RUN pip install --no-cache-dir $PIP_DEPENDENCIES
|
||||
|
||||
EXPOSE 8000
|
||||
CMD $ENTRYPOINT_COMMAND
|
||||
EOF
|
||||
|
||||
echo "Dockerfile created successfully in $TEMP_DIR/Dockerfile"
|
||||
|
||||
podman build -t $IMAGE_NAME -f "$TEMP_DIR/Dockerfile" "$SOURCE_DIR"
|
||||
|
||||
echo "Podman image '$IMAGE_NAME' built successfully."
|
||||
echo "You can run it with: podman run -p 8000:8000 $IMAGE_NAME"
|
||||
|
||||
rm -rf "$TEMP_DIR"
|
|
@ -43,6 +43,13 @@ class InlineProviderSpec(ProviderSpec):
|
|||
default_factory=list,
|
||||
description="The pip dependencies needed for this implementation",
|
||||
)
|
||||
docker_image: Optional[str] = Field(
|
||||
default=None,
|
||||
description="""
|
||||
The docker image to use for this implementation. If one is provided, pip_packages will be ignored.
|
||||
If a provider depends on other providers, the dependencies MUST NOT specify a docker image.
|
||||
""",
|
||||
)
|
||||
module: str = Field(
|
||||
...,
|
||||
description="""
|
||||
|
|
|
@ -42,6 +42,10 @@ def distribution_dependencies(distribution: DistributionSpec) -> List[str]:
|
|||
] + SERVER_DEPENDENCIES
|
||||
|
||||
|
||||
def stack_apis() -> List[Api]:
|
||||
return [Api.inference, Api.safety, Api.agentic_system, Api.memory]
|
||||
|
||||
|
||||
def api_endpoints() -> Dict[Api, List[ApiEndpoint]]:
|
||||
apis = {}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue