This commit is contained in:
2026-09-02 18:18:42 +08:00
parent 5e531ffe1e
commit 4fbff0761a
18 changed files with 239 additions and 111 deletions
+21 -24
View File
@@ -2,19 +2,19 @@
> 文档定位:**当前部署下的端口规划补充说明**。
> 部署入口与当前推荐方案见 [../DEPLOYMENT.md](../DEPLOYMENT.md),Linux 部署步骤见 [LINUX_SETUP.md](LINUX_SETUP.md)。
> 本文档描述的是 **当前模块化部署模式** 下的端口规划,不再以历史单体 `src.main:app` 作为默认前提。
> 本文档负责 **当前模块化部署模式** 下的端口暴露、端口规划与 Nginx / 防火墙层面的补充说明,不再以历史单体 `src.main:app` 作为默认前提。
当前推荐部署对象:
- frontend(Nginx,同域入口)
- unified backend
- gemold Celery worker(无 HTTP 端口)
- moldinsight Celery worker(无 HTTP 端口)
以下基础设施默认由服务器现有服务提供,不在本项目 compose 中重复部署:
- PostgreSQL
- Redis
- MinIO / RustFS(gemold 需要)
- MinIO / RustFS(moldinsight 需要)
---
@@ -24,7 +24,7 @@
|---|---:|---|
| frontend | 80 | 前端 Nginx,同域入口 |
| unified backend | 8000 | 当前推荐统一后端 |
| gemold API | 8000 | 模具分析独立部署时使用 |
| moldinsight API | 8000 | 模具分析独立部署时使用 |
| inventory API | 8001 | 进销存独立部署时使用 |
| PostgreSQL | 5432 | 共享数据库 |
| Redis | 6379 | 共享队列/缓存 |
@@ -37,7 +37,7 @@
## 2. 三种部署模式下的端口
### 2.1 gemold-only
### 2.1 moldinsight-only
- 对外开放:`8000`
- 依赖:PostgreSQL、Redis、MinIO/RustFS
@@ -51,16 +51,13 @@
### 2.3 unified
两种常见实现:
当前推荐由 unified backend 提供单一后端入口:
1. **统一网关模式**
- 外部只开放 80/443
- 网关转发到 gemold / inventory
2. **统一应用组合模式**
- 统一后端监听单一端口
- 后续组合层重构完成后更适合采用
- 对外开放:`8000`(或由前置 Nginx / 网关统一暴露 80/443)
- 依赖:PostgreSQL、Redis、MinIO / RustFS
- 配套:moldinsight Celery worker 不直接暴露 HTTP 端口
当前阶段,如果需要统一对外,更推荐**网关统一**而不是继续依赖历史单体入口。
在生产环境中,仍推荐通过同域 Nginx / 网关统一对外暴露 80/443,再反代到 unified backend。
---
@@ -73,7 +70,7 @@
- `FRONTEND_PORT` → frontend Nginx 外部端口
- `BACKEND_PORT` → unified backend 外部端口
- `MOLDINSIGHT_PORT` → gemold-only 独立部署端口
- `MOLDINSIGHT_PORT` → moldinsight-only 独立部署端口
- `INVENTORY_PORT` → inventory-only 独立部署端口
示例:
@@ -85,14 +82,14 @@ INVENTORY_PORT=8001
对应 compose 行为:
- gemold:`${MOLDINSIGHT_PORT:-8000}:8000`
- moldinsight:`${MOLDINSIGHT_PORT:-8000}:8000`
- inventory:`${INVENTORY_PORT:-8001}:8001`
---
## 4. 直接运行时的端口约定
### gemold-only
### moldinsight-only
```bash
uvicorn src.entrypoints.moldinsight:app --host 0.0.0.0 --port 8000
@@ -105,7 +102,7 @@ uvicorn src.entrypoints.inventory:app --host 0.0.0.0 --port 8001
```
如果改端口:
- gemold 改 `--port`
- moldinsight 改 `--port`
- inventory 改 `--port`
- 同步更新 Nginx / 防火墙 / 前端 base URL
@@ -125,7 +122,7 @@ VITE_API_BASE_URL=https://api.example.com
### split 模式
```env
VITE_AUTH_API_BASE_URL=https://auth.example.com
VITE_MOLDINSIGHT_API_BASE_URL=https://gemold.example.com
VITE_MOLDINSIGHT_API_BASE_URL=https://moldinsight.example.com
VITE_INVENTORY_API_BASE_URL=https://inventory.example.com
```
@@ -136,12 +133,12 @@ VITE_INVENTORY_API_BASE_URL=https://inventory.example.com
## 6. Nginx 示例
### gemold-only
### moldinsight-only
```nginx
server {
listen 80;
server_name gemold.example.com;
server_name moldinsight.example.com;
location / {
proxy_pass http://127.0.0.1:8000;
@@ -177,7 +174,7 @@ server {
如果不通过 Nginx 统一入口而是直接暴露服务端口,则应显式开放:
```bash
# gemold
# moldinsight
sudo ufw allow 8000/tcp
# inventory
@@ -205,6 +202,6 @@ curl http://127.0.0.1:8001/health
在当前模块化架构下:
- gemold 与 inventory 应视为**两个独立后端模块**
- 端口应按模块分配,而不是继续沿用单体“一个后端一个端口”的思路
- unified 更适合通过**组合层或网关**实现,而不是继续让历史单体入口承载全部语义
- moldinsight 与 inventory 应视为两个独立后端模块
- `unified` 是当前推荐部署模式,由 unified backend 提供单一后端入口
- 端口应按模块与部署模式清晰分配;生产环境通常通过同域 Nginx / 网关统一对外暴露 80/443