LOT 1 - Optimizare script build -Instalare mono comanda

This commit is contained in:
Dezvoltari Evotech 2026-06-27 06:42:02 -07:00
parent 5380c3fc63
commit 42ff22bf85
127 changed files with 16163 additions and 532 deletions

View file

@ -1,6 +1,6 @@
# Gateway (didiAI-gateway)
API gateway for the AI platform: a thin **Nginx reverse proxy** that acts as the single externally exposed entry point for all didiAI internal services (LLM inference, audio transcription, web fact-checking, catalog, embeddings, rerank). Every request except `/health` requires Bearer token authentication enforced via an `nginx map` block. Currently in a **restart loop** because several upstream containers it references do not exist on this host (see "Current status" below).
API gateway for the AI platform: a thin **Nginx reverse proxy** that acts as the single externally exposed entry point for all didiAI internal services (LLM inference, audio transcription, web fact-checking, catalog, embeddings, rerank). Every request except `/health` requires Bearer token authentication enforced via an `nginx map` block. It currently starts cleanly: only the upstreams whose containers exist on this host (`web`, `catalog`) are active; the upstreams for services not deployed here are commented out in `nginx.conf.template` (see "Current status" below).
- **Stack**: Nginx 1.27-alpine, no Python, no custom code (config-only module).
- **URL** (intended): `http://<host>:11000` — listens on a single port, `11000`, mapped 1:1 to the host. No TLS at this layer.
@ -22,36 +22,34 @@ There is no rate limiting, no request body inspection, no JWT/Keycloak — just
All routes from `deploy/nginx.conf.template`:
| Path prefix | Auth | Upstream | Notes |
|-------------|------|----------|-------|
| `GET /health` | none | nginx direct (returns `{"status":"ok","service":"didiAI-gateway"}`) | for healthcheck |
| `/llm/*` | Bearer | `didiAI-llm-api:14011` | SSE streaming: `proxy_buffering off`, `chunked_transfer_encoding on`, HTTP/1.1, `Connection: ''` |
| `/audio/*` | Bearer | `didiAI-audio-api:54300` | `client_body_buffer_size 10M` for large uploads |
| `/web/*` | Bearer | `didiAI-web-api:51100` | plain proxy_pass |
| `/catalog/*` | Bearer | `didiAI-catalog-api:11000` | plain proxy_pass; note: catalog also listens on 11000 internally |
| `/embeddings/*` | Bearer | `didiAI-embeddings-api:14100` | OpenAI-compatible API |
| `/rerank/*` | Bearer | `didiAI-rerank-api:14200` | Cohere/Jina-compatible API |
| `/` (anything else) | none | nginx direct | returns `404 {"error":"not_found","routes":[...]}` listing the valid prefixes |
| Path prefix | Auth | Upstream | Status | Notes |
|-------------|------|----------|--------|-------|
| `GET /health` | none | nginx direct (returns `{"status":"ok","service":"didiAI-gateway"}`) | active | for healthcheck |
| `/web/*` | Bearer | `didiAI-web-api:51100` | active | plain proxy_pass |
| `/catalog/*` | Bearer | `didiAI-catalog-api:11000` | active | plain proxy_pass; note: catalog also listens on 11000 internally |
| `/llm/*` | Bearer | `didiAI-llm-api:14011` | disabled (upstream + location commented) | SSE streaming: `proxy_buffering off`, `chunked_transfer_encoding on`, HTTP/1.1, `Connection: ''` |
| `/audio/*` | Bearer | `didiAI-audio:54300` | disabled (upstream + location commented) | `client_body_buffer_size 10M` for large uploads |
| `/embeddings/*` | Bearer | `didiAI-embeddings-api:14100` | disabled (upstream + location commented) | OpenAI-compatible API |
| `/rerank/*` | Bearer | `didiAI-rerank-api:14200` | disabled (upstream + location commented) | Cohere/Jina-compatible API |
| `/` (anything else) | none | nginx direct | active | returns `404 {"error":"not_found","routes":["/web/","/catalog/","/health"]}` listing the active prefixes |
The disabled routes are kept commented in `nginx.conf.template`; re-enable the matching `upstream` + `location` blocks once those containers run on this host.
Trailing slash on `proxy_pass http://upstream/;` strips the `/<service>/` prefix when forwarding (so `/llm/v1/chat` becomes `/v1/chat` upstream).
## Current status
**BROKEN / restart loop as of 2026-05-01.** `docker logs didiAI-gateway` shows nginx failing to start with:
**RESOLVED — gateway starts cleanly.** The earlier restart loop (`[emerg] host not found in upstream "didiAI-llm-api:14011"`) was caused by nginx resolving all upstream hostnames at config load (not per-request), so any missing upstream container aborted startup.
```
[emerg] host not found in upstream "didiAI-llm-api:14011" in /etc/nginx/nginx.conf:35
```
Fix applied: in `nginx.conf.template` the `upstream` + `location` blocks for the services not deployed on this host are commented out (option 2 below). The gateway now starts with only the active upstreams:
Root cause: the nginx upstreams resolve hostnames at config load (not per-request), so any missing upstream container kills the whole gateway. On this host only **2 of the 6 upstreams** are running:
- Active: `didiAI-web-api` (`/web/`), `didiAI-catalog-api` (`/catalog/`), plus the `/health` and `/` (404) direct locations.
- Commented out (re-enable when their containers run here): `didiAI-llm-api`, `didiAI-audio`, `didiAI-embeddings-api`, `didiAI-rerank-api`.
- Running: `didiAI-catalog-api`, `didiAI-web-api`.
- Missing: `didiAI-llm-api`, `didiAI-audio-api`, `didiAI-embeddings-api`, `didiAI-rerank-api`.
Fix options (pick one before redeploying):
Other ways the same problem could be addressed if you prefer to keep all blocks listed:
1. Start the missing service modules (`llm-inference`, `audio`, `embeddings`, `rerank`) on this host so the names resolve.
2. Edit `nginx.conf.template` and remove (or comment out) the `upstream` blocks + `location` blocks for services not deployed locally.
2. (applied) Comment out the `upstream` + `location` blocks for services not deployed locally.
3. Switch the upstream definitions to lazy-resolution form (`set $upstream "didiAI-llm-api:14011"; proxy_pass http://$upstream/;` plus a `resolver` directive) so missing names fail per-request instead of bringing the whole gateway down.
Investigation commands:
@ -68,7 +66,7 @@ modules/gateway/
├── INDEX.md # This file
└── deploy/
├── docker-compose.yml # nginx:1.27-alpine, port 11000:11000, didi-network network
├── nginx.conf.template # 175 lines: map auth, 6 upstreams, 7 locations + 404 fallback
├── nginx.conf.template # ~169 lines: map auth, 2 active upstreams (4 commented), 3 active locations (/web/, /catalog/, /health) + 404 fallback (4 locations commented)
├── deploy.sh # Bash wrapper: --detach / --down / --logs, fail-fast on missing GATEWAY_API_TOKEN
├── .env.example # Template (only GATEWAY_API_TOKEN)
└── .env # Active config (GATEWAY_API_TOKEN value)
@ -111,7 +109,7 @@ The AI platform mixes two patterns; this gateway is **opt-in aggregation**, not
| didiAI-llm-api | `:14011` | YES (`/llm/`) — required for SSE | LLM router; gateway adds streaming-friendly proxy settings |
| didiAI-embeddings-api | `:14100` | YES (`/embeddings/`) and direct | OpenAI-compatible |
| didiAI-rerank-api | `:14200` | YES (`/rerank/`) and direct | Cohere/Jina-compatible |
| didiAI-audio-api | `:54300` | YES (`/audio/`) — recommended for large uploads | gateway sets a 10 MB body buffer |
| didiAI-audio | `:54300` | YES (`/audio/`) — recommended for large uploads | gateway sets a 10 MB body buffer |
| didiAI-catalog-api | `:11000` | YES (`/catalog/`) | Catalog also listens on 11000 internally — same number as gateway, different network endpoint |
So the gateway aggregates the **inference/IO services** (LLM, embeddings, rerank, audio, web, catalog) under one host:port, while observability/orchestration components (brain, dashboard) stay on their own ports.

View file

@ -5,20 +5,25 @@ Nginx reverse proxy that serves as the **single entry point** for all didiAI ser
## Prerequisites
- All global prerequisites (see main [README.md](../../README.md))
- Docker network `deploy_default` (shared with other modules)
- Docker network `didi-network` (shared with other modules)
- At least one backend service running (llm-inference, audio, web, catalog-api)
## Routes
| Route | Upstream | Description |
|-------|----------|-------------|
| `/health` | (nginx direct) | Health check, no auth required |
| `/llm/` | `didiAI-llm-api:14011` | LLM Inference API (SSE streaming enabled) |
| `/audio/` | `didiAI-audio-api:54300` | Audio Transcription API (10M body buffer) |
| `/web/` | `didiAI-web-api:51100` | Web Fact-checking API |
| `/catalog/` | `didiAI-catalog-api:11000` | Catalog API (service discovery) |
| `/embeddings/` | `didiAI-embeddings-api:14100` | Embeddings API (OpenAI-compatible) |
| `/rerank/` | `didiAI-rerank-api:14200` | Rerank API (Cohere/Jina-compatible) |
Only the routes whose upstream containers exist on this host are active. The
others are present in `nginx.conf.template` but commented out (upstream + location
blocks), because nginx resolves upstream hostnames at config load and a missing
name aborts startup.
| Route | Upstream | Status | Description |
|-------|----------|--------|-------------|
| `/health` | (nginx direct) | active | Health check, no auth required |
| `/web/` | `didiAI-web-api:51100` | active | Web Fact-checking API |
| `/catalog/` | `didiAI-catalog-api:11000` | active | Catalog API (service discovery) |
| `/llm/` | `didiAI-llm-api:14011` | disabled (upstream commented) | LLM Inference API (SSE streaming) — re-enable when deployed |
| `/audio/` | `didiAI-audio:54300` | disabled (upstream commented) | Audio Transcription API (10M body buffer) — re-enable when deployed |
| `/embeddings/` | `didiAI-embeddings-api:14100` | disabled (upstream commented) | Embeddings API (OpenAI-compatible) — re-enable when deployed |
| `/rerank/` | `didiAI-rerank-api:14200` | disabled (upstream commented) | Rerank API (Cohere/Jina-compatible) — re-enable when deployed |
## Authentication
@ -53,7 +58,7 @@ docker compose up -d
# Test
curl http://localhost:11000/health
curl -H "Authorization: Bearer <token>" http://localhost:11000/llm/health
curl -H "Authorization: Bearer <token>" http://localhost:11000/catalog/health
```
## Port
@ -78,10 +83,11 @@ Client
v
Gateway (nginx :11000) ---> Bearer token check
|
+-- /llm/ --> didiAI-llm-api:14011 (SSE streaming)
+-- /audio/ --> didiAI-audio-api:54300 (large uploads)
+-- /web/ --> didiAI-web-api:51100
+-- /catalog/ --> didiAI-catalog-api:11000
+-- /embeddings/ --> didiAI-embeddings-api:14100
+-- /rerank/ --> didiAI-rerank-api:14200
+-- /web/ --> didiAI-web-api:51100 (active)
+-- /catalog/ --> didiAI-catalog-api:11000 (active)
|
+-- /llm/ --> didiAI-llm-api:14011 (disabled — upstream commented)
+-- /audio/ --> didiAI-audio:54300 (disabled — upstream commented)
+-- /embeddings/ --> didiAI-embeddings-api:14100 (disabled — upstream commented)
+-- /rerank/ --> didiAI-rerank-api:14200 (disabled — upstream commented)
```

View file

@ -18,7 +18,7 @@
# Naming Convention: didiAI-{module}-{service}
#
# Network:
# Uses deploy_default network (shared with other modules)
# Uses didi-network network (shared with other modules)
networks:
didi-network: