api-server/docs/architecture/local-engineering-test-environment.md
wangdl cca5adde7c
All checks were successful
Deploy API Server / build-and-unit (push) Successful in 39s
Deploy API Server / current-integration (push) Successful in 33s
Deploy API Server / backward-compat (push) Successful in 1s
Deploy API Server / deploy (push) Successful in 1m4s
docs: M-MEMBER-01-CLOSE-05A 测试环境固化与 Migration 证据
- 修复 ts-node seed 命令(compiler-options -> compilerOptions)
- 添加本地工程测试环境文档
- 添加 M-MEMBER-01 Migration 验证证据
2026-06-27 13:04:59 +08:00

94 lines
1.9 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 本地工程测试环境
> M-MEMBER-01-CLOSE-05A 固化测试环境
> 生成时间2026-06-27
> 禁止写入真实密码和密钥
---
## 环境基线
```text
操作系统: macOS 26.5.1 (Darwin)
Node.js v26.0.0
npm 11.12.1
MySQL mysql:8.0 (Docker, 8.0.46)
Redis redis:7-alpine (Docker, 7.4.9)
Prisma 5.22.0
API HEAD 87317e0
数据库名称zhixi_prod
Redis DB 16 个数据库可用
API 地址: http://127.0.0.1:3000
Admin 地址http://127.0.0.1:5174
iOS API http://127.0.0.1:3000/api (Debug)
```
## 启动方式
### 基础设施Docker
```bash
cd api-server
docker compose -f docker-compose.local.yml up -d
# 验证
docker ps --format 'table {{.Names}}\t{{.Status}}'
```
| 服务 | 容器名 | 端口 |
|------|--------|------|
| MySQL | zhixi-mysql | 127.0.0.1:3306 |
| Redis | zhixi-redis | 127.0.0.1:6379 |
| Qdrant | zhixi-qdrant | 127.0.0.1:6333 |
### 应用进程
```bash
# API Server
cd api-server
npm run build
node dist/src/main.js
# Worker (BullMQ)
node dist/src/worker.main.js
# RAG Worker
cd rag-worker
python3 -u main.py
# Admin 前端
cd admin-projects
npm run dev
```
### 环境变量
复制 `api-server/.env.local``.env`。包含本地 Docker 连接串和 AI=mock 模式。
### 生产数据同步
```bash
# SSH 到生产服务器 dump → 本地 import
ssh -i devops-projects/PJPZ/zhixi.pem ubuntu@120.53.227.155 \
"docker exec mysql mysqldump -uroot -p... --single-transaction zhixi_prod | gzip" \
| gunzip | docker exec -i zhixi-mysql mysql -uroot -p... zhixi_prod
```
## 测试命令
```bash
cd api-server
npm run test:unit # 单元测试(全 mock
npm run test:e2e # E2E 测试(全 mock
npm run test:integration # 集成测试(需要 MySQL + Redis
```
## Docker 镜像拉取
国内网络使用 DaoCloud 镜像:
```bash
docker pull docker.m.daocloud.io/library/mysql:8.0
docker tag docker.m.daocloud.io/library/mysql:8.0 mysql:8.0
```