mirror of
https://github.com/meta-llama/llama-stack.git
synced 2025-08-06 02:32:40 +00:00
Allow build with host network
This commit is contained in:
parent
78727aad26
commit
c01a89c0e8
3 changed files with 16 additions and 1 deletions
|
@ -120,6 +120,7 @@ def build_image(build_config: BuildConfig, build_file_path: Path):
|
||||||
docker_image,
|
docker_image,
|
||||||
str(build_file_path),
|
str(build_file_path),
|
||||||
str(BUILDS_BASE_DIR / ImageType.docker.value),
|
str(BUILDS_BASE_DIR / ImageType.docker.value),
|
||||||
|
"--use-host-network" if build_config.use_host_network else "",
|
||||||
" ".join(normal_deps),
|
" ".join(normal_deps),
|
||||||
]
|
]
|
||||||
elif build_config.image_type == ImageType.conda.value:
|
elif build_config.image_type == ImageType.conda.value:
|
||||||
|
|
|
@ -10,6 +10,7 @@ LLAMA_MODELS_DIR=${LLAMA_MODELS_DIR:-}
|
||||||
LLAMA_STACK_DIR=${LLAMA_STACK_DIR:-}
|
LLAMA_STACK_DIR=${LLAMA_STACK_DIR:-}
|
||||||
TEST_PYPI_VERSION=${TEST_PYPI_VERSION:-}
|
TEST_PYPI_VERSION=${TEST_PYPI_VERSION:-}
|
||||||
BUILD_PLATFORM=${BUILD_PLATFORM:-}
|
BUILD_PLATFORM=${BUILD_PLATFORM:-}
|
||||||
|
USE_HOST_NETWORK=${USE_HOST_NETWORK:-}
|
||||||
|
|
||||||
if [ "$#" -lt 4 ]; then
|
if [ "$#" -lt 4 ]; then
|
||||||
echo "Usage: $0 <build_name> <docker_base> <pip_dependencies> [<special_pip_deps>]" >&2
|
echo "Usage: $0 <build_name> <docker_base> <pip_dependencies> [<special_pip_deps>]" >&2
|
||||||
|
@ -163,14 +164,23 @@ if [ -n "$BUILD_PLATFORM" ]; then
|
||||||
elif [ "$ARCH" = "arm64" ] || [ "$ARCH" = "aarch64" ]; then
|
elif [ "$ARCH" = "arm64" ] || [ "$ARCH" = "aarch64" ]; then
|
||||||
PLATFORM="--platform linux/arm64"
|
PLATFORM="--platform linux/arm64"
|
||||||
elif [ "$ARCH" = "x86_64" ]; then
|
elif [ "$ARCH" = "x86_64" ]; then
|
||||||
|
# TODO: This is a hack, make the network host into a flag
|
||||||
PLATFORM="--platform linux/amd64"
|
PLATFORM="--platform linux/amd64"
|
||||||
else
|
else
|
||||||
echo "Unsupported architecture: $ARCH"
|
echo "Unsupported architecture: $ARCH"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Optionally add host network flag if requested.
|
||||||
|
# Set USE_HOST_NETWORK=1 (or "true") in the environment to enable it.
|
||||||
|
if [ "${USE_HOST_NETWORK:-}" = "1" ] || [ "${USE_HOST_NETWORK:-}" = "true" ]; then
|
||||||
|
HOST_NETWORK="--network host"
|
||||||
|
else
|
||||||
|
HOST_NETWORK=""
|
||||||
|
fi
|
||||||
|
|
||||||
set -x
|
set -x
|
||||||
$DOCKER_BINARY build $DOCKER_OPTS $PLATFORM -t $image_tag -f "$TEMP_DIR/Dockerfile" "$REPO_DIR" $mounts
|
$DOCKER_BINARY build $DOCKER_OPTS $PLATFORM $HOST_NETWORK -t $image_tag -f "$TEMP_DIR/Dockerfile" "$REPO_DIR" $mounts
|
||||||
|
|
||||||
# clean up tmp/configs
|
# clean up tmp/configs
|
||||||
set +x
|
set +x
|
||||||
|
|
|
@ -174,3 +174,7 @@ class BuildConfig(BaseModel):
|
||||||
default="conda",
|
default="conda",
|
||||||
description="Type of package to build (conda | docker | venv)",
|
description="Type of package to build (conda | docker | venv)",
|
||||||
)
|
)
|
||||||
|
use_host_network: bool = Field(
|
||||||
|
default=False,
|
||||||
|
description="Use host network for the build",
|
||||||
|
)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue