EPA-009 Deployment Infrastructure
EAOS 部署分阶段推进,先静态站,后生产后端。
Stage 0: GitHub Pages
- Source: GitHub Actions
- Build command:
node scripts/doctor.mjs - Output:
dist - Base path:
/eduai-platform
Stage 0.5: zhaotongxue.vip Production Static Zone
- Source: local verified release from this repository
- Build command:
BASE_PATH=/eduai SITE_URL=https://zhaotongxue.vip/eduai node scripts/doctor.mjs - Deploy command:
npm run deploy:zhaotongxue - Output:
/var/www/eduai-platform/current/eduai - Public URL:
https://zhaotongxue.vip/eduai/ - Offline class shortcut:
https://zhaotongxue.vip/offline/?code=邀请码redirects to/eduai/offline/ - Nginx snippet:
deploy/nginx/eaos-platform-locations.conf
Stage 1: Backend Preview
建议使用:
- API: Node.js service or Next.js server runtime
- Database: PostgreSQL
- ORM: Prisma
- File storage: Object storage
- Secrets: hosting platform secret manager
当前仓库已提供 apps/api/ 零依赖 Node API 原型,用于本地验证论坛、积分流水、学习产品和兑换订单流程。它默认使用 .cache/api-data.json,生产版必须替换为 PostgreSQL。
静态站后台 /admin/ 可以填写本地 API 地址 http://127.0.0.1:8787,切换到 API 模式验证前后端联通。
zhaotongxue.vip 的 API 原型预览独立于静态部署启用:
npm run deploy:zhaotongxue:api
该脚本会:
- 先运行
node apps/api/test.mjs。 - 检查远程服务器是否已有 Node.js 运行时。
- 同步
apps/api/到/var/www/eduai-platform/api。 - 创建 systemd 服务
eaos-api,默认监听127.0.0.1:8787。 - 把数据文件放在
/var/www/eduai-platform/runtime/api-data.json,避免切换静态 release 时丢状态。 - 上传
deploy/nginx/eaos-platform-api-locations.conf,仅在 API 服务部署成功后启用/api/反代。 - 验证
https://zhaotongxue.vip/api/health。
生产站前端只会在 /api/health 可用时自动进入同域 API 模式;如果 API 未启用,页面继续使用本地演示数据。
本地运行:
node apps/api/server.mjs
本地测试:
node apps/api/test.mjs
Stage 2: Production
生产版至少需要:
- 独立数据库
- 备份和恢复
- 日志与监控
- 管理后台权限
- 支付与积分规则审计
- 域名、备案或合规发布流程