AstroResearch/docker-compose.yml
Asfmq cec4b8cf7b feat: Docker 容器化、Cookie 鉴权、Coordinator 编排、FTS5 搜索与 P1-P3 全面收尾
Docker 容器化部署
  - 提供 Mode A (Alpine musl, ~23MB) 和 Mode B (Distroless glibc, ~87MB)
    两种镜像,Docker Compose 一键启动
  - build.rs 支持 SKIP_DASHBOARD_BUILD 跳过前端构建
  - 国内镜像加速 (npm/apt/apk) 通过 USE_MIRRORS build-arg 控制

  安全:Cookie-Based 鉴权系统
  - HttpOnly/SameSite=Strict Cookie 会话管理(24h 过期自动清理)
  - 登录/登出/验证接口 + 中间件注入
  - 前端登录页面 + 退出按钮
  - 三层 CORS:localhost 鉴权 / 全放通 bookmarklet / 受保护路由
  - 书签脚本 fetch 添加 credentials:'include'

  Coordinator 模式 (P2)
  - 4 个 meta-tool (delegate_task/check_task/task_stop/synthesize)
  - WorkerPool + Semaphore 并发控制 + 超时保护
  - 前端协调者模式开关

  Hook 系统:UserPromptSubmit 事件 (P2)
  - 第 13 个生命周期事件,fire-and-forget 审计

  FTS5 全文搜索 (P3)
  - agent_sessions_fts + agent_messages_fts 虚拟表
  - search_history Agent 工具 + /api/search/history HTTP 接口
  - 前端防抖搜索框 + 仅当前会话筛选

  工具加载优化 (P3)
  - defer_loading 延迟加载 (7 个重型工具)
  - is_readonly 只读标记 (9 个查询工具)
  - classifier_summary 工具目录供 LLM 按需判断

  模型回退策略 (P3)
  - LLM_FALLBACK_MODEL 优先回退 + LLM_FALLBACK_CHAIN 链式轮换
  - LlmClient model 改为 Arc<RwLock> 支持运行时切换
  - 连续 3 次过载后自动切换

  压缩记忆桥接 (P3)
  - 压缩丢弃消息 → 子代理提取持久记忆 (extract_memories_from_compaction)

  git2 依赖修复
  - 切换到 vendored-libgit2,消除 OpenSSL 系统依赖
2026-06-23 20:22:06 +08:00

106 lines
2.9 KiB
YAML

# =============================================================================
# AstroResearch Docker Compose 部署
# =============================================================================
#
# 快速启动 (Mode A — 推荐):
# 1. cp .env.example .env # 编辑填入 API Key
# 2. docker compose up -d # 启动服务
# 3. open http://localhost:8000
#
# 使用 Mode B (进程内 Obscura):
# 1. 先克隆 Obscura: mkdir -p libs && git clone https://github.com/h4ckf0r0day/obscura libs/obscura
# 2. 构建: docker compose build astroresearch-all
# 3. 启动: docker compose up -d astroresearch-all
#
# 查看日志: docker compose logs -f
# 停止: docker compose down
# 重建镜像: docker compose build --no-cache
# =============================================================================
services:
# ─── Mode A: Alpine 小镜像 + 外部 Obscura (推荐日常使用) ──────────────────
astroresearch:
build:
context: .
image: astroresearch:latest
container_name: astroresearch
restart: unless-stopped
ports:
- "${PORT:-8000}:8000"
env_file:
- .env
environment:
- DATABASE_URL=sqlite:///app/library/astro_research.db
- LIBRARY_DIR=/app/library
- SKILLS_DIR=/app/skills
- LOG_DIR=/app/logs
- LOG_FORMAT=json
- LOG_OUTPUTS=stdout
- PORT=8000
volumes:
- ./library:/app/library
- ./logs:/app/logs
- ./skills:/app/skills:ro
# Mode A: 外部 obscura 反爬浏览器 (bind-mount 避免打进镜像)
- ./bin:/app/bin:ro
# 资源限制 (可选)
# deploy:
# resources:
# limits:
# memory: 2G
# reservations:
# memory: 128M
healthcheck:
test: ["CMD", "wget", "-q", "--spider", "http://localhost:8000/"]
interval: 30s
timeout: 10s
retries: 3
start_period: 15s
# ─── Mode B: Distroless 全功能单体 (Obscura/V8/BoringSSL 编译在内) ──────
astroresearch-all:
build:
context: .
dockerfile: Dockerfile.modeB
image: astroresearch-all:latest
container_name: astroresearch-all
restart: unless-stopped
# 默认不随 `docker compose up` 启动, 需显式指定
profiles:
- full
ports:
- "${PORT:-8000}:8000"
env_file:
- .env
environment:
- DATABASE_URL=sqlite:///app/library/astro_research.db
- LIBRARY_DIR=/app/library
- SKILLS_DIR=/app/skills
- LOG_DIR=/app/logs
- LOG_FORMAT=json
- LOG_OUTPUTS=stdout
- PORT=8000
volumes:
- ./library:/app/library
- ./logs:/app/logs
- ./skills:/app/skills:ro
# 注: Mode B 无需 ./bin:/app/bin (Obscura 已编译进二进制)
# 资源限制 (可选)
# deploy:
# resources:
# limits:
# memory: 2G
# reservations:
# memory: 128M