| 1 | #!/bin/bash |
| 2 | |
| 3 | # Copyright (c) Meta Platforms, Inc. and affiliates. |
| 4 | # All rights reserved. |
| 5 | # |
| 6 | # This source code is licensed under the terms described in the LICENSE file in |
| 7 | # the root directory of this source tree. |
| 8 | |
| 9 | DOCKER_BINARY=${DOCKER_BINARY:-docker} |
| 10 | DOCKER_OPTS=${DOCKER_OPTS:-} |
| 11 | |
| 12 | set -euo pipefail |
| 13 | |
| 14 | RED='\033[0;31m' |
| 15 | NC='\033[0m' # No Color |
| 16 | |
| 17 | error_handler() { |
| 18 | echo "Error occurred in script at line: ${1}" >&2 |
| 19 | exit 1 |
| 20 | } |
| 21 | |
| 22 | trap 'error_handler ${LINENO}' ERR |
| 23 | |
| 24 | if [ $# -lt 3 ]; then |
| 25 | echo "Usage: $0 <build_name> <yaml_config> <port> <other_args...>" |
| 26 | exit 1 |
| 27 | fi |
| 28 | |
| 29 | build_name="$1" |
| 30 | docker_image="llamastack-$build_name" |
| 31 | shift |
| 32 | |
| 33 | yaml_config="$1" |
| 34 | shift |
| 35 | |
| 36 | port="$1" |
| 37 | shift |
| 38 | |
| 39 | set -x |
| 40 | $DOCKER_BINARY run $DOCKER_OPTS -it \ |
| 41 | -p $port:$port \ |
| 42 | -v "$yaml_config:/app/config.yaml" \ |
| 43 | $docker_image \ |
| 44 | python -m llama_stack.distribution.server.server \ |
| 45 | --yaml_config /app/config.yaml \ |
| 46 | --port $port "$@" |