Unify Wiki and Studio application and simplify deployment
Unified application CI and deployment / verify-and-release (pull_request) Waiting to run
python CI and deployment / verify-and-deploy (pull_request) Successful in 1m12s

This commit is contained in:
2026-11-04 03:41:16 +08:00
parent 80d23f0e3d
commit 6654a1456b
101 changed files with 304 additions and 1776 deletions
+5 -5
View File
@@ -9,15 +9,15 @@
## 依赖层与源码层
- Wiki 的根 Dockerfile 是实际 CI 入口,`apps/waterfall-wiki/Dockerfile` 是对应副本,两者的功能内容保持同步;根文件额外保留镜像生命周期标签。
- Web 应用安装前只复制自身清单、锁文件、workspace 配置和品牌包清单,满足 `workspace:*` 依赖发现。完整品牌包在安装后复制;颜色、Logo 或品牌脚本变化仍会重新编译应用,但不会仅因此重新下载依赖。
- 统一 Web 应用安装前只复制自身清单、锁文件、workspace 配置和品牌包清单,满足 `workspace:*` 依赖发现。完整品牌包在安装后复制;颜色、Logo 或品牌脚本变化仍会重新编译应用,但不会仅因此重新下载依赖。
- Python 从 `pyproject.toml` 读取固定运行依赖与构建后端要求,在独立依赖阶段安装。源码阶段安装当前包并运行单测,最终镜像仅继承系统运行环境并复制已验证的虚拟环境,不携带应用源码目录和测试目录。虚拟环境仍包含 pip 和构建后端,未声称完全剥离构建工具。
- 品牌检查镜像只用于 CI。其 Python 图片校验依赖安装放在品牌源码之前,避免源码变化重新下载这些依赖。
- 不因共享包缓存命中而漏掉消费者:品牌变更需触发 Wiki/Studio PR 检查和 main 发布。根忽略规则变化也触发相关检查。
- 品牌包只作为 workspace 依赖随 Web 应用构建,不提供独立 Dockerfile、镜像构建工作流或常驻服务。专用品牌检查已停止自动运行,保留测试脚本供明确需要时在远程执行。
- 不因共享包缓存命中而漏掉消费者:品牌变更需触发 统一应用 PR 检查和 main 发布。根忽略规则变化也触发相关检查。
## 验证与限制
构建、打包与产物验证只在已确认的 `ces-control` runner 执行。Python PR 运行镜像构建和单测,但只有 main push 才会发布 latest 标签。Web PR 与品牌检查沿用现有远程 Docker 验证流程。
构建、打包与产物验证只在已确认的 `ces-control` runner 执行。Python PR 运行镜像构建和单测,但只有 main push 才会发布 latest 标签。Web PR 沿用现有远程 Docker 验证流程,不再单独构建品牌检查镜像。
本次没有升级 Docker builder,也没有承诺消除 legacy builder 的镜像层提交耗时;缓存层调整后的实际收益需比较后续 CI 日志。源码变化仍需构建,持久测试环境和按影响范围选择测试属于后续 CI 调整。
本次没有升级 Docker builder,也没有承诺消除 legacy builder 的镜像层提交耗时;缓存层调整后的实际收益需比较后续 CI 日志。源码变化仍需构建,当前采用持久测试基础设施;本次应用合并仍保留完整集成验证,按影响范围选择测试留作后续优化。
本机不新增 Dev Containers/Tilt 启动方式;这类方案需要单独确认本地运行和编译授权。
+4 -8
View File
@@ -1,20 +1,16 @@
# PROMPT monorepo
- `apps/waterfall-wiki`: existing Pages Router application, media library, PostgreSQL, object storage and video processing worker. `/wiki/Namespace:slug` has matching `/api/wiki/Namespace:slug` Markdown; `/api/wiki-index` discovers pages. Existing `/p/slug` has `/api/wiki-post/slug` and alternate metadata. Main/File/Category/Template/Draft/Help are public content types, not permission boundaries. Categories cross namespaces; template pages currently describe reusable structures rather than a transclusion engine.
- `apps/studio`: independent Next.js + TypeScript + Tailwind Pages Router. Add ideas in `src/content/ideas.ts`, open `/ideas/slug`, export Markdown or versioned JSON, or print to PDF. Add custom React pages under `src/pages` when a composition needs bespoke rendering.
- `apps/waterfall-wiki/src/studio`: merged editor modules in the shared Pages Router application. Add ideas in `src/content/ideas.ts`, open `/ideas/slug`, export Markdown or versioned JSON, or print to PDF. Add custom React pages under `src/pages` when a composition needs bespoke rendering.
- `apps/python`: install with `pip install -e apps/python`. Run `prompt-export idea.json --output ./output --font /path/to/cjk.ttf [--video]`. Generates 1080×1440 PNGs and an optional silent MP4 (4 seconds per slide), requiring FFmpeg. JSON describes standard slides; arbitrary React animations need a separate browser recording pipeline. Python Docker image includes CJK fonts and FFmpeg.
## Development
Node 24, pnpm 11.25.0, Python 3.12+. `pnpm install`; `pnpm dev:waterfall-wiki`; `pnpm dev:studio`. Do not use local preview for acceptance; see root AGENTS.md. Each JS application owns its frozen pnpm lockfile. Production Docker builds install each project independently.
Node 24, pnpm 11.25.0, Python 3.12+. `pnpm install`; `pnpm dev:waterfall-wiki`; Do not use local preview for acceptance; see root AGENTS.md. Each JS application owns its frozen pnpm lockfile. Production Docker builds install each project independently.
## Releases
Three path-filtered Gitea workflows run on ces-control. Changes to one app trigger that app only. Workspace configuration changes intentionally verify both JS applications. Documentation changes do not deploy. Each workflow can be manually dispatched for recovery after a failed release. All app content, including Markdown, triggers its workflow.
Wiki keeps `/opt/prompt`, port 18131 and existing persistent volumes. Studio uses its own Compose project, `/opt/prompt-studio`, port 18134, and verifies its AI index before recording the release; port 18134 is bound to loopback so access goes through Wiki authentication. Python publishes `prompt-python:<sha>` and the local `latest` alias, used on demand rather than running an empty daemon. No Python network port is exposed. Root Dockerfile is Wiki's build entry; `apps/waterfall-wiki/Dockerfile` mirrors it for discovery.
CI uses root build context and application-scoped COPY instructions. Wiki runs its existing Docker integration suite before deploying. The former Web-only release path is retired because its source-copy and image assumptions predated the monorepo. No `down -v` is used in production.
当前以 [统一部署流程](unified-deployment.md) 为准。Wiki 和 Studio 已合并为一个 Next.js 应用,`.gitea/workflows/app.yml` 负责候选验证与 main 发布。品牌只作为内部源码包,Python 保留独立工具镜像流程。生产 PostgreSQL/S3 长期运行,日常应用发布不会重建基础服务。
## Explore 页面与轻量图片
@@ -22,7 +18,7 @@ CI uses root build context and application-scoped COPY instructions. Wiki runs i
`/api/preview` 只接受本站静态栅格图或媒体 ID,限制四档尺寸,输出 WebP:列表目标最多 100 KB、详情目标最多 220 KB。原图按需下载。服务端预览使用并发限制、请求合并、磁盘缓存和 ETag;缓存数量有限并定期清理。SVG 图标不经过栅格化。
Studio 部署到同一 Docker 网络,通过 `http://8.211.154.134:18131/studio` 访问,不依赖额外公网端口。直连端口 `127.0.0.1:18134/studio` 仅服务器本机可用;公网访问统一经过 Wiki 登录保护。
Studio 部署到同一 Docker 网络,已合并到同一 Web 容器,编辑器使用 `/graphic`、`/infinite_canvas`,历史 `/studio` 路径兼容保留,不再部署 18134 服务。
Docker 在单独的依赖下载层执行 `pnpm fetch`,再离线安装。源码变化复用依赖层,包脚本变化复用已下载的包。CI 不清理 Docker 缓存,不使用 `--no-cache`。
+35
View File
@@ -0,0 +1,35 @@
# 统一应用的 CI/CD
## 范围
Wiki 与 Studio 合并为 `apps/waterfall-wiki` 内一个 Next.js Pages Router 应用。编辑器组件与内容在 `src/studio`;原生页面为 `/graphic`、`/infinite_canvas`,历史 `/studio/layouts/*`、`/studio/template-layout` 等继续存在。旧 `/studio/api/*` 通过同应用 rewrite 进入 `pages/api/studio-ui`,保留既有 API 地址与权限边界。没有第二个 Next.js 服务或 18134 新部署。
品牌包只作为 workspace 源码依赖,不独立构建、测试或部署。Python workflow 保留。`codex/unified-web` 包含未合并 PR #46 的缓存改动作为依赖,评审时必须包含完整差异;不得先合并已失效的旧品牌检查配置。
## main 更新后
1. `.gitea/workflows/app.yml` 按应用、品牌、脚本、Docker/Compose 配置路径筛选 main push(含 PR 合并)。文档修改不会部署。
2. runner checkout 本次提交,逐文件检查 Shell 语法与内容约定。
3. 构建 integration 与 runtime 两个目标。Next.js 的类型检查、单元测试、生产编译、冒烟测试只在共享 build 阶段执行;runtime 复用这一层,不再次编译。运行镜像同供 Web 与 worker 使用。
4. 在锁保护下使用 `prompt-ci-shared` 测试槽位。首次创建专用 PostgreSQL/S3,此后 `--no-recreate` 复用。停止上一轮测试应用,确认数据库容器属于该测试项目后重置测试数据库。本轮使用 `ci-<run_id>` 对象 bucket。
5. 启动候选 Web/worker,迁移测试数据库,执行接口、账户、画布、编辑器及浏览器集成验证。失败则停止发布。退出时停止测试应用并删除本轮 bucket,保留基础容器和卷。
6. 生产部署先验证 `/etc/prompt.env` 和既有 `prompt` 基础服务,绝不自动生成新凭据或重建 PostgreSQL/S3。检查是否被更新的 main 取代并获取部署锁。
7. 停止应用写入,备份数据库,执行迁移及已有内容初始化,使用 `--no-deps` 更新 Web/worker。
8. 检查健康、账户、已有内容和完整线上验收。验收处于部署脚本回滚边界内;失败尝试恢复数据库备份和上一版应用。
9. 验收通过后更新 current 和成功记录,停止有明确 Compose 所属标签的旧 Studio 容器(保留旧镜像)。上传验收证据;上传成功后删除 runner 临时报告。镜像盘点清理不在发布关键路径执行。
PR 运行同一候选构建与测试,但部署步骤只允许 main push。首次应用合并保留完整远程验证;尚未按改动选择浏览器用例,不能宣称已消除全部重复测试。发布不自动取消进行中的任务,以免中断数据库迁移;过期版本由部署脚本检查跳过。
## 基础设施初始化与维护
生产首次安装或明确升级基础镜像时,管理员单独配置 `/etc/prompt.env`,执行 `bash scripts/init-infra.sh`。日常发布只检查基础服务;既有 `prompt_postgres_data`、`prompt_objects`、`prompt_auth_data` 卷名与凭据不变,不执行生产 `down -v`。
持久测试凭据仅保存在 `/var/lib/prompt-ci/credentials.env`,创建时权限受 umask 077 限制;不打印或提交。测试基础设施只使用 `prompt-ci-shared` Compose 项目、随机绑定端口和自己的卷,绝不复用生产数据。runner 必须能写入 `/var/lib/prompt-ci` 和 `/var/lock`;当前确认的 runner 为 root host executor,变更运行身份时需重新配置目录权限。
镜像维护继续提供 `wiki-image-lifecycle.py preview/apply`,需在确认无协作构建的维护窗口执行。数据库备份及既有内容导入暂保留在部署流程;这部分尚未按 schema 或内容变更跳过。
## 回滚与验收
首次迁移前保留旧 Studio 容器、镜像及 `/opt/prompt-studio` 元数据。新版本验收失败发生在旧 Studio 停止之前,可恢复旧 Web/worker。若首次迁移成功后人工回滚到双应用版本,还必须重新启动保留的旧 Studio 容器;不能只回滚 Web 镜像。
构建及浏览器验证只在 ces-control 执行。本地只能做语法、引用及差异检查;实际通过状态以 PR 对应提交的远程 CI 为准。PR 等待用户手动合并,不自动部署或合并。