Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,7 @@ jobs:
run: bash e2e/run_e2e.sh
- name: Local JavaScript smoke
run: bash e2e/js_smoke.sh
- name: Build local demo image (no registry push)
run: docker build --tag llmgate:ci .
- name: Verify installed image over loopback HTTP
run: python e2e/docker_smoke.py llmgate:ci
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ ENV PYTHONDONTWRITEBYTECODE=1 PYTHONUNBUFFERED=1
WORKDIR /app
COPY pyproject.toml ./
COPY llmgate ./llmgate
COPY actas ./actas
RUN pip install --no-cache-dir . && useradd --uid 10001 --create-home llmgate
USER llmgate
EXPOSE 8000
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ original Actas tests and the gateway's separate regression checks.

## Demo and limits
https://llmgate-demo.vercel.app/
The public demo labels simulated and real-model paths. Redis-backed limits are optional; breaker and latency state are per process. Usage telemetry is not billing-grade. The Docker packaging has not been built or verified.
The public demo labels simulated and real-model paths. Redis-backed limits are optional; breaker and latency state are per process. Usage telemetry is not billing-grade. The default simulated Docker image was built and checked on hosted CI on 11 November 2026, including installed-package imports, non-root execution, authentication, streaming and forced-primary failover. Docker Compose and mounted real-provider configurations remain unverified.

## Repository setup
GitHub is the source of truth for project changes. The active
Expand Down
2 changes: 1 addition & 1 deletion docs/DEPLOYMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ section and the demo against `gpt-sim` / `gpt-sim-pro`.

## Honest limits

- The Dockerfile and compose file provide install-and-run recipes. The container image itself has not been built or verified.
- On 11 November 2026, [hosted CI](https://github.com/Rajatendu1/llmgate/actions/runs/42977091731/job/130378576049?pr=8) built the default Python 3.11 simulated image and checked installed gateway/Actas imports from site-packages, actual non-root execution, loopback HTTP health, authentication, completion, SSE, unknown-model rejection, admin isolation and usage in healthy and forced-primary-failure modes. This verifies the default demo image only. Docker Compose and mounted real-provider configurations remain unverified; no image was pushed or deployed.
- Usage metering and rate limits are per process by default and can use a shared Redis store when configured. Rate limiting fails closed when the store is unreachable. Circuit-breaker and latency state remain per process. Usage telemetry is not billing-grade.
- No TLS inside the container; put it behind a proxy that terminates TLS.
- Demo keys are hard-coded in `llmgate/demo_app.py`; real deployments use
Expand Down
114 changes: 114 additions & 0 deletions e2e/docker_smoke.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
#!/usr/bin/env python3
"""Smoke-test an already built demo image. No registry or real providers.

Usage: python3 e2e/docker_smoke.py llmgate:ci
Requires Docker and an image built from the candidate checkout.
"""
import json
import subprocess
import sys
import time
import urllib.error
import urllib.request


def docker(*args):
return subprocess.check_output(["docker", *args], text=True, timeout=90).strip()


def request(base, path, key=None, body=None):
headers = {}
if key:
headers["Authorization"] = "Bearer " + key
if body is not None:
headers["Content-Type"] = "application/json"
req = urllib.request.Request(base + path, headers=headers,
data=None if body is None else json.dumps(body).encode())
try:
response = urllib.request.urlopen(req, timeout=10)
except urllib.error.HTTPError as error:
response = error
with response:
return response.status, response.headers, response.read().decode()


def check(condition, label):
if not condition:
raise AssertionError(label)
print("PASS " + label, flush=True)


def verify_http(base, fail_primary):
for attempt in range(60):
try:
status, _, text = request(base, "/healthz")
if status == 200 and json.loads(text)["ok"]:
break
except (OSError, ValueError):
pass
time.sleep(0.5)
else:
raise AssertionError("image did not become ready within 30 seconds")
check(True, "published loopback HTTP health answers")
check(request(base, "/v1/models")[0] == 401, "missing bearer denied")
check(request(base, "/v1/models", "wrong-key")[0] == 401, "wrong bearer denied")
status, _, text = request(base, "/v1/models", "demo-key")
check(status == 200 and "gpt-sim" in [m["id"] for m in json.loads(text)["data"]],
"authenticated model discovery works")
body = {"model": "gpt-sim", "messages": [{"role": "user", "content": "image smoke"}]}
status, headers, text = request(base, "/v1/chat/completions", "demo-key", body)
expected = "sim-b" if fail_primary else "sim-a"
check(status == 200 and headers.get("x-gateway-provider") == expected
and bool(json.loads(text)["choices"][0]["message"]["content"]),
"completion served by " + expected)
body["stream"] = True
status, headers, text = request(base, "/v1/chat/completions", "demo-key", body)
check(status == 200 and "text/event-stream" in headers.get("content-type", "")
and "data: {" in text and "data: [DONE]" in text,
"stream delivers SSE frames and terminates")
body.pop("stream")
body["model"] = "missing-model"
check(request(base, "/v1/chat/completions", "demo-key", body)[0] == 404,
"unknown model rejected")
check(request(base, "/admin/usage", "demo-key")[0] == 401, "admin usage denies demo key")
status, _, text = request(base, "/admin/usage", "admin-key")
check(status == 200 and json.loads(text)["keys"]["demo"]["requests"] == 2,
"admin usage records completion and stream")


def smoke(image, fail_primary):
container = docker("run", "--detach", "--rm", "--memory", "256m", "--cpus", "1",
"--pids-limit", "128", "--publish", "127.0.0.1::8000",
"--env", "SIM_A_FAIL=" + str(fail_primary), image)
try:
inspect = json.loads(docker("inspect", container))[0]
check(inspect["Config"]["User"] == "llmgate", "image runs as llmgate, not root")
check(bool(inspect["Config"].get("Healthcheck", {}).get("Test")), "image has a healthcheck")
docker("exec", "--workdir", "/tmp", container, "python", "-c",
"import os, llmgate, actas; import llmgate.config; "
"assert os.getuid() != 0; "
"assert all('/site-packages/' in m.__file__ for m in (llmgate, actas))")
check(True, "installed image imports gateway and vendored Actas")
port = inspect["NetworkSettings"]["Ports"]["8000/tcp"][0]["HostPort"]
base = "http://127.0.0.1:" + port
verify_http(base, fail_primary)
except BaseException:
print(docker("logs", container), file=sys.stderr)
raise
finally:
subprocess.run(["docker", "rm", "--force", container], check=False,
stdout=subprocess.DEVNULL, timeout=30)


def main():
if len(sys.argv) != 2:
raise SystemExit("usage: docker_smoke.py IMAGE")
image = sys.argv[1]
print("image=" + docker("image", "inspect", "--format", "{{.Id}}", image), flush=True)
smoke(image, 0)
smoke(image, 1)
print("PASS image HTTP smoke, healthy and forced-primary-failure modes; simulated only")


if __name__ == "__main__":
main()
Loading