Skip to content

🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.

fix(ai-gateway): retain build revision in runtime image (#17503)

Hassieb Pakzad1b986aec8fd2
diff --git a/ai-gateway/Dockerfile b/ai-gateway/Dockerfile
index 25b7491895..c82ae0571f 100644
--- a/ai-gateway/Dockerfile
+++ b/ai-gateway/Dockerfile
@@ -11,6 +11,8 @@ FROM debian:bookworm-slim AS runtime
RUN apt-get update && apt-get install -y --no-install-recommends ca-certificates wget \
&& rm -rf /var/lib/apt/lists/*
COPY --from=builder /app/target/release/ai-gateway /usr/local/bin/ai-gateway
+ARG BUILD_ID
+ENV BUILD_ID=$BUILD_ID
USER 10001:10001
EXPOSE 8080
STOPSIGNAL SIGTERM
diff --git a/ai-gateway/README.md b/ai-gateway/README.md
index cce2022dac..acac378690 100644
--- a/ai-gateway/README.md
+++ b/ai-gateway/README.md
@@ -337,7 +337,9 @@ key metadata remain in Langfuse ingestion and are excluded from operational logs
From the repository root:
```sh
-docker build --target runtime -t langfuse-ai-gateway:dev ./ai-gateway
+docker build --target runtime \
+ --build-arg BUILD_ID="$(git rev-parse HEAD)" \
+ -t langfuse-ai-gateway:dev ./ai-gateway
docker run --rm --name langfuse-ai-gateway-dev \
-e LANGFUSE_LOG_FORMAT=json -p 127.0.0.1:8080:8080 langfuse-ai-gateway:dev
# In another terminal:
@@ -345,6 +347,10 @@ docker stop --time 15 langfuse-ai-gateway-dev
bash ai-gateway/scripts/smoke-image.sh langfuse-ai-gateway:dev
```
+The `BUILD_ID` build argument is stored as runtime `BUILD_ID`, so operational
+telemetry identifies the built commit. Omit the build argument to use the Cargo
+package version, or override `BUILD_ID` at runtime.
+
The runtime image runs as UID/GID 10001, includes CA certificates, and executes
the binary directly so it receives signals. Set the container/orchestrator stop
grace period longer than the gateway shutdown timeout. The smoke test uses an