Skip to content

Commit 716b59d

Browse files
Optionally use different host internal and host ip for networking.
1 parent bb71d04 commit 716b59d

File tree

6 files changed

+30
-13
lines changed

6 files changed

+30
-13
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ grafana-data
133133
prom_data
134134
arch_log/
135135
arch_logs/
136+
arch/logs/
136137
crates/*/target/
137138
crates/target/
138139
build.log

arch/README.md

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,19 @@
66
$ rustup target add wasm32-wasip1
77
```
88

9-
## Building
9+
## Container Runtime Support
1010

1111
```sh
12-
$ cargo build --target wasm32-wasip1 --release
12+
# Build the gateway WASM modules (must be run from the crates directory)
13+
$ cd ../crates
14+
$ cargo build --target wasm32-wasip1 --release -p llm_gateway
15+
$ cargo build --target wasm32-wasip1 --release -p prompt_gateway
16+
```
17+
18+
Or build both at once:
19+
```sh
20+
$ cd ../crates
21+
$ cargo build --target wasm32-wasip1 --release -p llm_gateway -p prompt_gateway
1322
```
1423

1524
## Testing
@@ -25,12 +34,15 @@ $ cargo test
2534

2635
- Build filter binary,
2736
```
28-
$ cargo build --target wasm32-wasip1 --release
37+
$ cd ../crates
38+
$ cargo build --target wasm32-wasip1 --release -p llm_gateway -p prompt_gateway
2939
```
3040
- Start envoy with arch_config.yaml and test,
3141
```
3242
$ docker compose -f docker-compose.dev.yaml up archgw
3343
```
34-
- 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,
44+
- 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,
3545
- envoy.template.yaml
36-
- intelligent_prompt_gateway.wasm
46+
- llm_gateway.wasm
47+
- prompt_gateway.wasm
48+
- logs/ directory (for container logs)

arch/docker-compose.dev.yaml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,20 @@ services:
88
- "12000:12000"
99
- "19901:9901"
1010
volumes:
11-
- ${ARCH_CONFIG_FILE:-../demos/samples_python/weather_forecast/arch_config.yaml}:/app/arch_config.yaml
11+
- ${ARCH_CONFIG_FILE:-../demos/samples_python/weather_forecast}:/app/arch_config.yaml
1212
- /etc/ssl/cert.pem:/etc/ssl/cert.pem
1313
- ./envoy.template.yaml:/app/envoy.template.yaml
1414
- ./arch_config_schema.yaml:/app/arch_config_schema.yaml
1515
- ./tools/cli/config_generator.py:/app/config_generator.py
1616
- ../crates/target/wasm32-wasip1/release/llm_gateway.wasm:/etc/envoy/proxy-wasm-plugins/llm_gateway.wasm
1717
- ../crates/target/wasm32-wasip1/release/prompt_gateway.wasm:/etc/envoy/proxy-wasm-plugins/prompt_gateway.wasm
18-
- ~/archgw_logs:/var/log/
18+
- ./logs:/var/log/
1919
extra_hosts:
20-
- "host.docker.internal:host-gateway"
20+
- "${HOST_INTERNAL:-host.docker.internal}:${HOST_IP:-host-gateway}"
21+
2122
environment:
2223
- OPENAI_API_KEY=${OPENAI_API_KEY:?error}
2324
- MISTRAL_API_KEY=${MISTRAL_API_KEY:?error}
24-
- OTEL_TRACING_HTTP_ENDPOINT=http://host.docker.internal:4318/v1/traces
25+
- OTEL_TRACING_HTTP_ENDPOINT=http://${HOST_INTERNAL:-host.docker.internal}:4318/v1/traces
2526
- MODEL_SERVER_PORT=${MODEL_SERVER_PORT:-51000}
27+
- HOST_INTERNAL=${HOST_INTERNAL:-host.docker.internal}

arch/envoy.template.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -685,7 +685,7 @@ static_resources:
685685
- endpoint:
686686
address:
687687
socket_address:
688-
address: host.docker.internal
688+
address: $HOST_INTERNAL
689689
port_value: $MODEL_SERVER_PORT
690690
hostname: {{ internal_cluster }}
691691
{% endfor %}

arch/tools/cli/docker_cli.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import subprocess
22
import json
33
import sys
4+
import os
45
import requests
56

67
from cli.consts import (
@@ -74,7 +75,7 @@ def docker_start_archgw_detached(
7475
*volume_mappings_args,
7576
*env_args,
7677
"--add-host",
77-
"host.docker.internal:host-gateway",
78+
f"{os.getenv('HOST_INTERNAL', 'host.docker.internal')}:{os.getenv('HOST_IP', 'host-gateway')}",
7879
ARCHGW_DOCKER_IMAGE,
7980
]
8081

arch/tools/cli/main.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ def build(service):
105105
"-t",
106106
f"{ARCHGW_DOCKER_IMAGE}",
107107
".",
108-
"--add-host=host.docker.internal:host-gateway",
108+
f"--add-host={os.getenv('HOST_INTERNAL', 'host.docker.internal')}:{os.getenv('HOST_IP', 'host-gateway')}",
109109
],
110110
check=True,
111111
)
@@ -197,8 +197,9 @@ def up(file, path, service, foreground):
197197

198198
# Set the ARCH_CONFIG_FILE environment variable
199199
env_stage = {
200-
"OTEL_TRACING_HTTP_ENDPOINT": "http://host.docker.internal:4318/v1/traces",
200+
"OTEL_TRACING_HTTP_ENDPOINT": f"http://{os.getenv('HOST_INTERNAL', 'host.docker.internal')}:4318/v1/traces",
201201
"MODEL_SERVER_PORT": os.getenv("MODEL_SERVER_PORT", "51000"),
202+
"HOST_INTERNAL": os.getenv("HOST_INTERNAL", "host.docker.internal"),
202203
}
203204
env = os.environ.copy()
204205
# check if access_keys are preesnt in the config file

0 commit comments

Comments
 (0)