diff --git a/.gitignore b/.gitignore index f155cd1a4..9d19ae51b 100644 --- a/.gitignore +++ b/.gitignore @@ -133,6 +133,7 @@ grafana-data prom_data arch_log/ arch_logs/ +arch/logs/ crates/*/target/ crates/target/ build.log diff --git a/arch/README.md b/arch/README.md index 49c62797c..adb524b83 100644 --- a/arch/README.md +++ b/arch/README.md @@ -6,10 +6,19 @@ $ rustup target add wasm32-wasip1 ``` -## Building +## Container Runtime Support ```sh -$ cargo build --target wasm32-wasip1 --release +# Build the gateway WASM modules (must be run from the crates directory) +$ cd ../crates +$ cargo build --target wasm32-wasip1 --release -p llm_gateway +$ cargo build --target wasm32-wasip1 --release -p prompt_gateway +``` + +Or build both at once: +```sh +$ cd ../crates +$ cargo build --target wasm32-wasip1 --release -p llm_gateway -p prompt_gateway ``` ## Testing @@ -25,12 +34,15 @@ $ cargo test - Build filter binary, ``` - $ cargo build --target wasm32-wasip1 --release + $ cd ../crates + $ cargo build --target wasm32-wasip1 --release -p llm_gateway -p prompt_gateway ``` - Start envoy with arch_config.yaml and test, ``` $ docker compose -f docker-compose.dev.yaml up archgw ``` -- dev version of docker-compose file uses following files that are mounted inside the container. That means no docker rebuild is needed if any of these files change. Just restart the container and chagne will be picked up, +- dev version of docker-compose file uses following files that are mounted inside the container. That means no docker rebuild is needed if any of these files change. Just restart the container and change will be picked up, - envoy.template.yaml - - intelligent_prompt_gateway.wasm + - llm_gateway.wasm + - prompt_gateway.wasm + - logs/ directory (for container logs) diff --git a/arch/docker-compose.dev.yaml b/arch/docker-compose.dev.yaml index 0b52d057a..2f2a4ae08 100644 --- a/arch/docker-compose.dev.yaml +++ b/arch/docker-compose.dev.yaml @@ -15,11 +15,14 @@ services: - ./tools/cli/config_generator.py:/app/config_generator.py - ../crates/target/wasm32-wasip1/release/llm_gateway.wasm:/etc/envoy/proxy-wasm-plugins/llm_gateway.wasm - ../crates/target/wasm32-wasip1/release/prompt_gateway.wasm:/etc/envoy/proxy-wasm-plugins/prompt_gateway.wasm - - ~/archgw_logs:/var/log/ + # Log volume location is now configurable via ARCHGW_LOGS_DIR (default: ~/archgw_logs) + - ${ARCHGW_LOGS_DIR:-~/archgw_logs}:/var/log/ extra_hosts: - - "host.docker.internal:host-gateway" + - "${HOST_INTERNAL:-host.docker.internal}:${HOST_IP:-host-gateway}" + environment: - OPENAI_API_KEY=${OPENAI_API_KEY:?error} - MISTRAL_API_KEY=${MISTRAL_API_KEY:?error} - - OTEL_TRACING_HTTP_ENDPOINT=http://host.docker.internal:4318/v1/traces + - OTEL_TRACING_HTTP_ENDPOINT=http://${HOST_INTERNAL:-host.docker.internal}:4318/v1/traces - MODEL_SERVER_PORT=${MODEL_SERVER_PORT:-51000} + - HOST_INTERNAL=${HOST_INTERNAL:-host.docker.internal} diff --git a/arch/envoy.template.yaml b/arch/envoy.template.yaml index 530447707..d3a1b0290 100644 --- a/arch/envoy.template.yaml +++ b/arch/envoy.template.yaml @@ -685,7 +685,7 @@ static_resources: - endpoint: address: socket_address: - address: host.docker.internal + address: $HOST_INTERNAL port_value: $MODEL_SERVER_PORT hostname: {{ internal_cluster }} {% endfor %} diff --git a/arch/tools/cli/docker_cli.py b/arch/tools/cli/docker_cli.py index e8a12a137..29d733efa 100644 --- a/arch/tools/cli/docker_cli.py +++ b/arch/tools/cli/docker_cli.py @@ -1,6 +1,7 @@ import subprocess import json import sys +import os import requests from cli.consts import ( @@ -74,7 +75,7 @@ def docker_start_archgw_detached( *volume_mappings_args, *env_args, "--add-host", - "host.docker.internal:host-gateway", + f"{os.getenv('HOST_INTERNAL', 'host.docker.internal')}:{os.getenv('HOST_IP', 'host-gateway')}", ARCHGW_DOCKER_IMAGE, ] diff --git a/arch/tools/cli/main.py b/arch/tools/cli/main.py index 001f3d9c6..74017c5cb 100644 --- a/arch/tools/cli/main.py +++ b/arch/tools/cli/main.py @@ -105,7 +105,7 @@ def build(service): "-t", f"{ARCHGW_DOCKER_IMAGE}", ".", - "--add-host=host.docker.internal:host-gateway", + f"--add-host={os.getenv('HOST_INTERNAL', 'host.docker.internal')}:{os.getenv('HOST_IP', 'host-gateway')}", ], check=True, ) @@ -197,8 +197,9 @@ def up(file, path, service, foreground): # Set the ARCH_CONFIG_FILE environment variable env_stage = { - "OTEL_TRACING_HTTP_ENDPOINT": "http://host.docker.internal:4318/v1/traces", + "OTEL_TRACING_HTTP_ENDPOINT": f"http://{os.getenv('HOST_INTERNAL', 'host.docker.internal')}:4318/v1/traces", "MODEL_SERVER_PORT": os.getenv("MODEL_SERVER_PORT", "51000"), + "HOST_INTERNAL": os.getenv("HOST_INTERNAL", "host.docker.internal"), } env = os.environ.copy() # check if access_keys are preesnt in the config file