Files
eip4-platform/deploy/README.md
zhengwr 2db44a6231 fix(A10 W4): 内置演示库自洽起栈 + 文档对齐 W1 真验
整栈 docker compose up 对内置空 postgres 真起验证(本地 daemon + PG 15.15),
揪修并文档化两处:

- postgres-init/01-create-schemas.sql(新):首次初始化预建 eip3+flowable schema。
  原空库起 flowable-service 报 "no schema has been selected to create in"——
  platform-app 的 Flyway 会自建 eip3,但 flowable 的 Liquibase 不自建 schema。
- docker-compose.yml:postgres 挂载 postgres-init/;刷新过时头注释
  (W1 Flyway 已含,不再"假定 DB 已置备"自举平台表)。
- README:验证状态改为 2026-06-25 本地真验记录——
  platform-app 在 prod profile + W1 Flyway 启动自建 eip3 落 9 张 sys_* 表、
  readiness UP、nginx 单源反代 /api→401(prod 严格认证链生效);
  flowable-service 空演示库 by-design 无法起(databaseSchemaUpdate=false 红线,
  需预置 Flowable 6.8.1 引擎 DDL),已显式文档化边界。

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-25 15:01:02 +08:00

52 lines
4.6 KiB
Markdown
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
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.
# EIP4 生产部署(A10 MVP:W1 Flyway + W2 容器化 + W3 nginx 单源 + W4 compose)
> 对应设计 `docs/plans/2026-06-25-A10-生产上线工程化-design.md`。本目录是 **MVP 编排骨架**。
> ✅ **平台表(sys_*)由 W1 Flyway 在 platform-app 启动时自建**(含自建 `eip3` schema)——内置演示 postgres 从零即可起平台层,无需先跑 bootstrap。
> ℹ️ **flowable-service 例外**:引擎 `databaseSchemaUpdate=false` 是任务红线(严禁引擎自动改表),故其 `flowable` schema 必须【预置备】Flowable 6.8.1 DDL(生产=客户既有 flowable schema)。空演示库无法起 flowable-service,详见下「验证状态」。
## 拓扑
`nginx`(单源:serve 前端 dist + 反代 `/api`→platform-app、`/flowable`→flowable-service)→ `platform-app:8084` + `flowable-service:8089` → PostgreSQL。
## 一、Docker Compose(推荐)
```bash
# 1) 产后端 jar
mvn -pl platform-app,flowable-service -am package -DskipTests
# 2) 产前端 dist
( cd ../../eip4-web && npm ci && npm run build )
# 3) 配置(强随机密钥 + DB 指向;生产指客户 PG)
cp deploy/.env.example deploy/.env && $EDITOR deploy/.env
# 4) 起栈
docker compose -f deploy/docker-compose.yml --env-file deploy/.env up -d --build
# 健康/日志
docker compose -f deploy/docker-compose.yml ps
docker compose -f deploy/docker-compose.yml logs -f platform-app
```
**生产数据库(D2/D6)**:保真层跑在**客户既有 eip3 库**上,EIP4 只新增平台表。生产请把 `.env` 的 `EIP4_DB_URL` 指向客户 PG,并可删除 compose 内置 `postgres` 服务(仅自测演示用空库)。
**内置演示库 schema(W4)**:`.env.example` 用 `currentSchema=eip3` / `currentSchema=flowable`。platform-app 的 Flyway 会自建 `eip3` 并落平台表;但 flowable 的 Liquibase 不自建 schema,故内置 postgres 经 `deploy/postgres-init/01-create-schemas.sql` 在首次初始化预建 `eip3`+`flowable` 两 schema。生产指客户库时这些 schema 已存在,无需 init 脚本。
**flowable-service 引擎库**:`databaseSchemaUpdate=false`(任务红线)→ 引擎不自建 ACT_/FLW_ 表。空 `flowable` schema 启动会报 `relation "flw_channel_definition" does not exist`。要起 flowable-service 需先把 Flowable 6.8.1 引擎 DDL 灌入 `flowable` schema(生产=客户既有引擎库;演示如需自洽可把对应 create SQL 追加到 `postgres-init/`)。
**密钥(D4)**:`EIP4_AUTH_JWT_SECRET` 等敏感项 `application-prod.yml` 无默认值,缺失即启动失败(fail-safe)。用 `openssl rand -base64 48` 生成。
## 二、systemd 裸 jar(D3 兜底:客户禁 Docker 时)
见 `deploy/systemd/*.service` 头部安装说明:jar→`/opt/eip4/`,env→`/etc/eip4/*.env`(chmod 600),`systemctl enable --now`。前端 dist 用宿主 nginx serve(参考 `deploy/nginx.conf`,upstream 改为 `127.0.0.1:8084/8089`)。
## 三、待办(后续批次,见 A10 design)
- **W5**:PG/Flowable 迁移 runbook 在准生产真跑 + 回退验证(含 flowable 引擎库 DDL 置备)。
- **W6**:性能/并发基线 + nginx upstream 权重灰度切流(eip3↔eip4)。
- **残留收敛**:删除与 `db/migration` 重复的 `bootstrap-*.sql`,把 `ci.sh`/`AiAgentDdlTest`/对拍 fixture 指向 `db/migration`(app 运行态已单源,独立工具仍用 bootstrap)。
## 验证状态(诚实记录,2026-06-25 本地真验)
- ✅ `docker build` 两镜像通过:`platform-app` 727MB / `flowable` 641MB(JRE21 + 非 root + COPY 预构建 jar)。
- ✅ **整栈 `docker compose up` 对内置空 postgres 真起**(本地 Docker daemon + PG 15.15):
- platform-app 在 **prod profile** 下启动,**W1 Flyway 在 Spring Boot 启动时自建 `eip3` schema 并应用 V1-V3**(9 张 sys_* 表,`flyway_schema_history` v1/v2/v3 全 success);`/actuator/health/readiness` = `{"status":"UP"}`。
- nginx 单源验证:`GET /` → 200 SPA;`/api/meta/entities` 经反代到 platform-app → **401**(prod 严格认证链生效,印证 P0 fail-safe 修复在运行态成立)。
- postgres-init 预建 schema 生效:`no schema has been selected` 报错消除。
- ⚠️ **flowable-service 在空演示库无法起**(by design):引擎 `databaseSchemaUpdate=false` 红线 → 不自建表,空 `flowable` schema 报 `flw_channel_definition does not exist`。生产用客户既有引擎库即正常;演示自洽需向 `postgres-init/` 追加 Flowable 6.8.1 DDL。
- ℹ️ 登录 `/api/auth/login` 在空演示库返 401 属预期(无客户 SYS_USER 数据);保真层业务端点同理需客户数据。
- 提示:`docker build` 前需先产 jar(步骤 1);`compose --build` 会自动 build。`.env` 已 gitignore(含密钥,勿入库)。