chore: add Otari local development base

This commit is contained in:
wlx committed 2026-08-20 13:14:03 +08:00
1 parent 06cfbbacc3
commit a4c93ff1a7
8 files changed
+134 -1

No files matched your search

+11
View File
@@ -0,0 +1,11 @@
OTARI_IMAGE=mzdotai/otari:v0.4.0
OTARI_PORT=8000
OTARI_SECRET_KEY=replace-with-a-long-random-secret
POSTGRES_PORT=5433
POSTGRES_USER=otari
POSTGRES_PASSWORD=replace-with-a-long-random-password
POSTGRES_DB=otari
OPENAI_API_KEY=
ANTHROPIC_API_KEY=
+57
View File
@@ -0,0 +1,57 @@
# Otari 本地基座
这是 D2 的本地开发基座,使用 Otari `v0.4.0` 和 PostgreSQL。它只负责为后续 MOYI 控制面提供可复现的网关与用量基础,不替代 MOYI 用户端或管理端。
## 目录
- `docker-compose.yml`:Otari 与 PostgreSQL 服务、持久化卷和健康检查。
- `config.yml.example`:本地网关配置模板。
- `.env.example`:端口、数据库和密钥变量模板。
- `service_account.json.example`:Vertex AI 配置占位文件,不包含真实凭证。
## 启动
PowerShell:
```powershell
cd infra/otari
Copy-Item .env.example .env
Copy-Item config.yml.example config.yml
Copy-Item service_account.json.example service_account.json
```
编辑 `.env` 和 `config.yml`,至少替换:
- `OTARI_SECRET_KEY`
- `POSTGRES_PASSWORD`
- `master_key`
- 一个真实供应商 Key,或先保持空值只启动管理界面
启动服务:
```powershell
docker compose up -d
docker compose ps
Invoke-WebRequest http://localhost:8000/health
```
预期健康响应:`{"status":"healthy"}`。首次启动后打开 `http://localhost:8000/`,使用 `master_key` 进入 Otari 管理界面。
## 停止与数据
```powershell
docker compose down
```
不要使用 `docker compose down -v`,除非明确要删除本地数据库。PostgreSQL 数据保存在 Docker 卷 `moyi-otari_otari_postgres_data` 中。
## 安全边界
- `.env`、`config.yml` 和 `service_account.json` 不提交到 Git。
- `master_key` 用于网关管理接口,不能作为普通用户调用 Key。
- 供应商 Key 只通过本地环境变量或 Otari 管理界面配置。
- 生产部署必须固定镜像 digest,并重新审计 Otari 及其依赖许可证。
## 版本依据
本节点按 Otari `v0.4.0` 的官方发布说明和官方 Compose/config 示例建立。正式联调前仍需用固定 digest 验证镜像内容和 API 行为。
+13
View File
@@ -0,0 +1,13 @@
database_url: "postgresql://otari:change-me@postgres:5432/otari"
host: "0.0.0.0"
port: 8000
master_key: "change-me-in-local-config"
enable_metrics: true
providers:
openai:
api_key: ""
api_base: "https://api.openai.com/v1"
model_discovery: false
aliases: {}
+46
View File
@@ -0,0 +1,46 @@
name: moyi-otari
services:
otari:
image: ${OTARI_IMAGE:-mzdotai/otari:v0.4.0}
restart: unless-stopped
ports:
- "${OTARI_PORT:-8000}:8000"
volumes:
- ./config.yml:/app/config.yml:ro
- ./service_account.json:/app/service_account.json:ro
environment:
OTARI_CONFIG_PATH: /app/config.yml
OTARI_SECRET_KEY: ${OTARI_SECRET_KEY:?Set OTARI_SECRET_KEY in infra/otari/.env}
OPENAI_API_KEY: ${OPENAI_API_KEY:-}
ANTHROPIC_API_KEY: ${ANTHROPIC_API_KEY:-}
command: ["otari", "serve", "--config", "/app/config.yml"]
depends_on:
postgres:
condition: service_healthy
healthcheck:
test: ["CMD", "python", "-c", "import urllib.request; urllib.request.urlopen('http://localhost:8000/health')"]
interval: 10s
timeout: 5s
retries: 12
start_period: 15s
postgres:
image: postgres:16-alpine
restart: unless-stopped
ports:
- "${POSTGRES_PORT:-5433}:5432"
environment:
POSTGRES_USER: ${POSTGRES_USER:-otari}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:?Set POSTGRES_PASSWORD in infra/otari/.env}
POSTGRES_DB: ${POSTGRES_DB:-otari}
volumes:
- otari_postgres_data:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U $${POSTGRES_USER} -d $${POSTGRES_DB}"]
interval: 10s
timeout: 5s
retries: 10
volumes:
otari_postgres_data:
+1
View File
@@ -0,0 +1 @@
{}