Some checks failed
verify / verify (push) Has been cancelled
The backend can now be inspected through a loopback-only gateway while the database-aware API remains on the internal data network. A governed synthetic demo proves readiness, pgvector retrieval, reranking, and citation output through real HTTP without invoking cloud models. Constraint: The previously exposed Bailian key is compromised and cannot be used for live validation Constraint: The API must be locally reachable while retaining no internet egress Rejected: Attach the API directly to the ingress network | a real socket test proved that configuration still had egress Rejected: Publish a port from the internal-only network | Docker Desktop did not expose the host port Confidence: high Scope-risk: moderate Reversibility: clean Directive: Keep model and database credentials out of the gateway; do not relax the fixed demo identity/profile filters Tested: make verify; 63 pytest tests; strict mypy; Ruff; Secret scan; Compose config; three backend image builds; API/DB/gateway healthy; migration exit 0; Swagger browser check; live/ready/meta/status/search HTTP; 20/20/20 index; API egress ENETUNREACH; empty gateway mounts and business environment Not-tested: Live Bailian calls require a newly rotated key; full generated-answer flow and React UI are not implemented
231 lines
6.2 KiB
YAML
231 lines
6.2 KiB
YAML
name: geological-rag
|
|
|
|
x-runtime-config: &runtime-config
|
|
APP_ENV: ${APP_ENV:-development}
|
|
APP_NAME: ${APP_NAME:-geological-rag}
|
|
POSTGRES_HOST: db
|
|
POSTGRES_PORT: "5432"
|
|
POSTGRES_DB: ${POSTGRES_DB:-geological_rag}
|
|
POSTGRES_USER: ${POSTGRES_APP_USER:-geological_rag_app}
|
|
POSTGRES_PASSWORD_FILE: /run/secrets/postgres_app_password
|
|
UPLOAD_ROOT: ${UPLOAD_ROOT:-/data/uploads}
|
|
MAX_UPLOAD_MB: "${MAX_UPLOAD_MB:-100}"
|
|
|
|
x-rag-config: &rag-config
|
|
DASHSCOPE_API_KEY_FILE: /run/secrets/bailian_api_key
|
|
BAILIAN_OPENAI_BASE_URL: "${BAILIAN_OPENAI_BASE_URL:-}"
|
|
BAILIAN_NATIVE_BASE_URL: "${BAILIAN_NATIVE_BASE_URL:-}"
|
|
BAILIAN_RERANK_BASE_URL: "${BAILIAN_RERANK_BASE_URL:-}"
|
|
EMBEDDING_MODEL: ${EMBEDDING_MODEL:-text-embedding-v4}
|
|
EMBEDDING_DIMENSION: "${EMBEDDING_DIMENSION:-1024}"
|
|
RERANK_MODEL: ${RERANK_MODEL:-qwen3-rerank}
|
|
LLM_MODEL: ${LLM_MODEL:-deepseek-v4-flash}
|
|
CHUNK_TARGET_TOKENS: "${CHUNK_TARGET_TOKENS:-512}"
|
|
CHUNK_MAX_TOKENS: "${CHUNK_MAX_TOKENS:-800}"
|
|
CHUNK_OVERLAP_TOKENS: "${CHUNK_OVERLAP_TOKENS:-64}"
|
|
VECTOR_TOP_K: "${VECTOR_TOP_K:-50}"
|
|
RERANK_TOP_N: "${RERANK_TOP_N:-10}"
|
|
CONTEXT_TOP_N: "${CONTEXT_TOP_N:-8}"
|
|
MAX_CONTEXT_TOKENS: "${MAX_CONTEXT_TOKENS:-10000}"
|
|
MODEL_TIMEOUT_SECONDS: "${MODEL_TIMEOUT_SECONDS:-90}"
|
|
MODEL_MAX_RETRIES: "${MODEL_MAX_RETRIES:-3}"
|
|
MODEL_MAX_CONCURRENCY: "${MODEL_MAX_CONCURRENCY:-4}"
|
|
|
|
services:
|
|
db:
|
|
image: pgvector/pgvector:0.8.2-pg17@sha256:feb68f4f15446397d8cac7f4fe48fe4586de83160d1fc48b46283312d1a33966
|
|
environment:
|
|
POSTGRES_DB: ${POSTGRES_DB:-geological_rag}
|
|
POSTGRES_USER: ${POSTGRES_BOOTSTRAP_USER:-postgres}
|
|
POSTGRES_PASSWORD_FILE: /run/secrets/postgres_bootstrap_password
|
|
POSTGRES_MIGRATOR_USER: ${POSTGRES_MIGRATOR_USER:-geological_rag_migrator}
|
|
POSTGRES_MIGRATOR_PASSWORD_FILE: /run/secrets/postgres_migrator_password
|
|
POSTGRES_APP_USER: ${POSTGRES_APP_USER:-geological_rag_app}
|
|
POSTGRES_APP_PASSWORD_FILE: /run/secrets/postgres_app_password
|
|
secrets:
|
|
- postgres_bootstrap_password
|
|
- postgres_migrator_password
|
|
- postgres_app_password
|
|
volumes:
|
|
- postgres_data:/var/lib/postgresql/data
|
|
- ./ops/postgres/init:/docker-entrypoint-initdb.d:ro
|
|
healthcheck:
|
|
test:
|
|
- CMD-SHELL
|
|
- >-
|
|
pg_isready -h 127.0.0.1 -p 5432 -U $$POSTGRES_USER -d $$POSTGRES_DB
|
|
&& test -f $$PGDATA/.rag-bootstrap-complete
|
|
interval: 5s
|
|
timeout: 3s
|
|
retries: 20
|
|
networks:
|
|
- data
|
|
restart: unless-stopped
|
|
|
|
migrate:
|
|
build:
|
|
context: ./backend
|
|
command: ["alembic", "upgrade", "head"]
|
|
depends_on:
|
|
db:
|
|
condition: service_healthy
|
|
environment:
|
|
POSTGRES_HOST: db
|
|
POSTGRES_PORT: "5432"
|
|
POSTGRES_DB: ${POSTGRES_DB:-geological_rag}
|
|
POSTGRES_USER: ${POSTGRES_MIGRATOR_USER:-geological_rag_migrator}
|
|
POSTGRES_PASSWORD_FILE: /run/secrets/postgres_migrator_password
|
|
secrets:
|
|
- postgres_migrator_password
|
|
networks:
|
|
- data
|
|
restart: "no"
|
|
|
|
api:
|
|
build:
|
|
context: ./backend
|
|
command: ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000"]
|
|
depends_on:
|
|
db:
|
|
condition: service_healthy
|
|
migrate:
|
|
condition: service_completed_successfully
|
|
environment: *runtime-config
|
|
secrets:
|
|
- postgres_app_password
|
|
networks:
|
|
- data
|
|
healthcheck:
|
|
test:
|
|
- CMD
|
|
- python
|
|
- -c
|
|
- >-
|
|
import urllib.request;
|
|
urllib.request.urlopen('http://127.0.0.1:8000/health/ready', timeout=2)
|
|
interval: 10s
|
|
timeout: 3s
|
|
retries: 5
|
|
start_period: 5s
|
|
init: true
|
|
read_only: true
|
|
tmpfs:
|
|
- /tmp
|
|
security_opt:
|
|
- no-new-privileges:true
|
|
cap_drop:
|
|
- ALL
|
|
restart: unless-stopped
|
|
|
|
gateway:
|
|
build:
|
|
context: ./backend
|
|
command: ["uvicorn", "app.gateway:app", "--host", "0.0.0.0", "--port", "8000"]
|
|
depends_on:
|
|
api:
|
|
condition: service_healthy
|
|
ports:
|
|
- "127.0.0.1:8000:8000"
|
|
networks:
|
|
- edge
|
|
- data
|
|
healthcheck:
|
|
test:
|
|
- CMD
|
|
- python
|
|
- -c
|
|
- >-
|
|
import urllib.request;
|
|
urllib.request.urlopen('http://127.0.0.1:8000/health/ready', timeout=2)
|
|
interval: 10s
|
|
timeout: 3s
|
|
retries: 5
|
|
start_period: 5s
|
|
init: true
|
|
read_only: true
|
|
tmpfs:
|
|
- /tmp
|
|
security_opt:
|
|
- no-new-privileges:true
|
|
cap_drop:
|
|
- ALL
|
|
restart: unless-stopped
|
|
|
|
provider-smoke:
|
|
build:
|
|
context: ./backend
|
|
command: ["python", "-m", "app.tools.provider_smoke"]
|
|
profiles: ["tools"]
|
|
environment: *rag-config
|
|
secrets:
|
|
- bailian_api_key
|
|
networks:
|
|
- egress
|
|
restart: "no"
|
|
|
|
seed-demo:
|
|
build:
|
|
context: ./backend
|
|
command: ["python", "-m", "app.tools.seed_demo"]
|
|
profiles: ["tools"]
|
|
depends_on:
|
|
migrate:
|
|
condition: service_completed_successfully
|
|
environment:
|
|
<<: [*runtime-config, *rag-config]
|
|
DEMO_PROVIDER_MODE: bailian
|
|
DEMO_DOCUMENTS_PATH: /demo/demo_documents.jsonl
|
|
DEMO_QUERIES_PATH: /demo/demo_queries.jsonl
|
|
secrets:
|
|
- postgres_app_password
|
|
- bailian_api_key
|
|
networks:
|
|
- data
|
|
- egress
|
|
volumes:
|
|
- ./data/samples/public:/demo:ro
|
|
restart: "no"
|
|
|
|
seed-demo-offline:
|
|
build:
|
|
context: ./backend
|
|
command: ["python", "-m", "app.tools.seed_demo"]
|
|
profiles: ["tools"]
|
|
depends_on:
|
|
migrate:
|
|
condition: service_completed_successfully
|
|
environment:
|
|
<<: *runtime-config
|
|
DEMO_PROVIDER_MODE: fake
|
|
DEMO_DOCUMENTS_PATH: /demo/demo_documents.jsonl
|
|
DEMO_QUERIES_PATH: /demo/demo_queries.jsonl
|
|
secrets:
|
|
- postgres_app_password
|
|
networks:
|
|
- data
|
|
volumes:
|
|
- ./data/samples/public:/demo:ro
|
|
restart: "no"
|
|
|
|
volumes:
|
|
postgres_data:
|
|
|
|
networks:
|
|
edge:
|
|
driver: bridge
|
|
data:
|
|
driver: bridge
|
|
internal: true
|
|
egress:
|
|
driver: bridge
|
|
|
|
secrets:
|
|
postgres_bootstrap_password:
|
|
file: ./secrets/postgres_bootstrap_password
|
|
postgres_migrator_password:
|
|
file: ./secrets/postgres_migrator_password
|
|
postgres_app_password:
|
|
file: ./secrets/postgres_app_password
|
|
bailian_api_key:
|
|
file: ./secrets/bailian_api_key
|