diff --git a/docs/source/distributions/building_distro.md b/docs/source/distributions/building_distro.md index 0dbabf8aa..521071cc6 100644 --- a/docs/source/distributions/building_distro.md +++ b/docs/source/distributions/building_distro.md @@ -260,7 +260,41 @@ Containerfile created successfully in /tmp/tmp.viA3a3Rdsg/ContainerfileFROM pyth You can now edit ~/meta-llama/llama-stack/tmp/configs/ollama-run.yaml and run `llama stack run ~/meta-llama/llama-stack/tmp/configs/ollama-run.yaml` ``` -After this step is successful, you should be able to find the built container image and test it with `llama stack run `. +Now set some environment variables for the inference model ID and Llama Stack Port and create a local directory to mount into the container's file system. +``` +export INFERENCE_MODEL="llama3.2:3b" +export LLAMA_STACK_PORT=8321 +mkdir -p ~/.llama +``` + +After this step is successful, you should be able to find the built container image and test it with the below Docker command: + +``` +docker run -d \ + -p $LLAMA_STACK_PORT:$LLAMA_STACK_PORT \ + -v ~/.llama:/root/.llama \ + localhost/distribution-ollama:dev \ + --port $LLAMA_STACK_PORT \ + --env INFERENCE_MODEL=$INFERENCE_MODEL \ + --env OLLAMA_URL=http://host.docker.internal:11434 +``` + +Here are the docker flags and their uses: + +* `-d`: Runs the container in the detached mode as a background process + +* `-p $LLAMA_STACK_PORT:$LLAMA_STACK_PORT`: Maps the container port to the host port for accessing the server + +* `-v ~/.llama:/root/.llama`: Mounts the local .llama directory to persist configurations and data + +* `localhost/distribution-ollama:dev`: The name and tag of the container image to run + +* `--port $LLAMA_STACK_PORT`: Port number for the server to listen on + +* `--env INFERENCE_MODEL=$INFERENCE_MODEL`: Sets the model to use for inference + +* `--env OLLAMA_URL=http://host.docker.internal:11434`: Configures the URL for the Ollama service + ::: :::: diff --git a/llama_stack/cli/stack/run.py b/llama_stack/cli/stack/run.py index 27745edac..387d913e9 100644 --- a/llama_stack/cli/stack/run.py +++ b/llama_stack/cli/stack/run.py @@ -59,7 +59,7 @@ class StackRun(Subcommand): "--image-type", type=str, help="Image Type used during the build. This can be either conda or container or venv.", - choices=[e.value for e in ImageType], + choices=[e.value for e in ImageType if e.value != ImageType.CONTAINER.value], ) self.parser.add_argument( "--enable-ui", diff --git a/llama_stack/distribution/start_stack.sh b/llama_stack/distribution/start_stack.sh index 996935a5e..85bfceec4 100755 --- a/llama_stack/distribution/start_stack.sh +++ b/llama_stack/distribution/start_stack.sh @@ -7,10 +7,6 @@ # the root directory of this source tree. -CONTAINER_BINARY=${CONTAINER_BINARY:-docker} -CONTAINER_OPTS=${CONTAINER_OPTS:-} -LLAMA_CHECKPOINT_DIR=${LLAMA_CHECKPOINT_DIR:-} -LLAMA_STACK_DIR=${LLAMA_STACK_DIR:-} TEST_PYPI_VERSION=${TEST_PYPI_VERSION:-} PYPI_VERSION=${PYPI_VERSION:-} VIRTUAL_ENV=${VIRTUAL_ENV:-} @@ -132,63 +128,7 @@ if [[ "$env_type" == "venv" || "$env_type" == "conda" ]]; then $env_vars \ $other_args elif [[ "$env_type" == "container" ]]; then - set -x - - # Check if container command is available - if ! is_command_available $CONTAINER_BINARY; then - printf "${RED}Error: ${CONTAINER_BINARY} command not found. Is ${CONTAINER_BINARY} installed and in your PATH?${NC}" >&2 - exit 1 - fi - - if is_command_available selinuxenabled &> /dev/null && selinuxenabled; then - # Disable SELinux labels - CONTAINER_OPTS="$CONTAINER_OPTS --security-opt label=disable" - fi - - mounts="" - if [ -n "$LLAMA_STACK_DIR" ]; then - mounts="$mounts -v $(readlink -f $LLAMA_STACK_DIR):/app/llama-stack-source" - fi - if [ -n "$LLAMA_CHECKPOINT_DIR" ]; then - mounts="$mounts -v $LLAMA_CHECKPOINT_DIR:/root/.llama" - CONTAINER_OPTS="$CONTAINER_OPTS --gpus=all" - fi - - if [ -n "$PYPI_VERSION" ]; then - version_tag="$PYPI_VERSION" - elif [ -n "$LLAMA_STACK_DIR" ]; then - version_tag="dev" - elif [ -n "$TEST_PYPI_VERSION" ]; then - version_tag="test-$TEST_PYPI_VERSION" - else - if ! is_command_available jq; then - echo -e "${RED}Error: jq not found" >&2 - exit 1 - fi - URL="https://pypi.org/pypi/llama-stack/json" - version_tag=$(curl -s $URL | jq -r '.info.version') - fi - - # Build the command with optional yaml config - cmd="$CONTAINER_BINARY run $CONTAINER_OPTS -it \ - -p $port:$port \ - $env_vars \ - $mounts \ - --env LLAMA_STACK_PORT=$port \ - --entrypoint python \ - $container_image:$version_tag \ - -m llama_stack.distribution.server.server" - - # Add yaml config if provided, otherwise use default - if [ -n "$yaml_config" ]; then - cmd="$cmd -v $yaml_config:/app/run.yaml --config /app/run.yaml" - else - cmd="$cmd --config /app/run.yaml" - fi - - # Add any other args - cmd="$cmd $other_args" - - # Execute the command - eval $cmd + echo -e "${RED}Warning: Llama Stack no longer supports running Containers via the 'llama stack run' command.${NC}" + echo -e "Please refer to the documentation for more information: https://llama-stack.readthedocs.io/en/latest/distributions/building_distro.html#llama-stack-build" + exit 1 fi diff --git a/llama_stack/distribution/utils/exec.py b/llama_stack/distribution/utils/exec.py index 7c2e00524..2db01689f 100644 --- a/llama_stack/distribution/utils/exec.py +++ b/llama_stack/distribution/utils/exec.py @@ -23,11 +23,8 @@ from llama_stack.distribution.utils.image_types import LlamaStackImageType def formulate_run_args(image_type, image_name, config, template_name) -> list: env_name = "" - if image_type == LlamaStackImageType.CONTAINER.value: - env_name = ( - f"distribution-{template_name}" if template_name else (config.container_image if config else image_name) - ) - elif image_type == LlamaStackImageType.CONDA.value: + + if image_type == LlamaStackImageType.CONDA.value: current_conda_env = os.environ.get("CONDA_DEFAULT_ENV") env_name = image_name or current_conda_env if not env_name: