2026-08-27 14:53:22 +08:00
|
|
|
|
# 端口配置说明(模块化架构)
|
2026-02-14 17:15:22 +08:00
|
|
|
|
|
2026-09-01 18:05:18 +08:00
|
|
|
|
> 文档定位:**模块化部署下的端口与环境变量配置补充说明**。
|
|
|
|
|
|
> 当前部署主题入口见 [../DEPLOYMENT.md](../DEPLOYMENT.md),详细 Linux 部署步骤见 [LINUX_SETUP.md](LINUX_SETUP.md)。
|
2026-09-02 18:18:42 +08:00
|
|
|
|
> 本文只补充环境变量、端口配置项与 direct run / compose 的映射;端口规划与对外暴露方式以 [DEPLOY_PORT.md](./DEPLOY_PORT.md) 为准。
|
2026-02-14 17:15:22 +08:00
|
|
|
|
|
2026-09-02 18:18:42 +08:00
|
|
|
|
当前配置中主要需要区分:
|
2026-02-14 17:15:22 +08:00
|
|
|
|
|
2026-09-02 18:18:42 +08:00
|
|
|
|
- **moldinsight API 端口**
|
2026-08-27 14:53:22 +08:00
|
|
|
|
- **inventory API 端口**
|
2026-09-02 18:18:42 +08:00
|
|
|
|
- **数据库 / Redis / 对象存储端口**
|
2026-08-27 14:53:22 +08:00
|
|
|
|
- **前端访问地址**
|
2026-02-14 17:15:22 +08:00
|
|
|
|
|
2026-08-27 14:53:22 +08:00
|
|
|
|
---
|
2026-02-14 17:15:22 +08:00
|
|
|
|
|
2026-08-27 14:53:22 +08:00
|
|
|
|
## 1. 当前主配置位置
|
|
|
|
|
|
|
|
|
|
|
|
对于 Docker Compose 部署,当前主要端口配置来源于:
|
|
|
|
|
|
|
2026-09-24 15:28:13 +08:00
|
|
|
|
- [docker-compose.yml](../../docker-compose.yml)(unified,默认入口)
|
|
|
|
|
|
- [docker-compose.moldinsight.yml](../../docker-compose.moldinsight.yml)
|
|
|
|
|
|
- [docker-compose.inventory.yml](../../docker-compose.inventory.yml)
|
2026-08-27 14:53:22 +08:00
|
|
|
|
- `.env` / `deploy/.env.example`
|
|
|
|
|
|
|
2026-09-24 15:28:13 +08:00
|
|
|
|
注意:这些 compose 文件仅负责项目应用容器,不负责 PostgreSQL / Redis / 对象存储容器。
|
2026-08-27 14:53:22 +08:00
|
|
|
|
|
|
|
|
|
|
核心环境变量:
|
|
|
|
|
|
|
|
|
|
|
|
```env
|
2026-08-31 18:01:34 +08:00
|
|
|
|
FRONTEND_PORT=80
|
|
|
|
|
|
BACKEND_PORT=8000
|
2026-08-27 14:53:22 +08:00
|
|
|
|
MOLDINSIGHT_PORT=8000
|
|
|
|
|
|
INVENTORY_PORT=8001
|
2026-02-14 17:15:22 +08:00
|
|
|
|
```
|
|
|
|
|
|
|
2026-08-27 14:53:22 +08:00
|
|
|
|
其余基础设施通常为:
|
2026-02-14 17:15:22 +08:00
|
|
|
|
|
2026-08-27 14:53:22 +08:00
|
|
|
|
```env
|
|
|
|
|
|
DB_PORT=5432
|
|
|
|
|
|
REDIS_PORT=6379
|
|
|
|
|
|
```
|
2026-02-14 17:15:22 +08:00
|
|
|
|
|
2026-08-27 14:53:22 +08:00
|
|
|
|
对象存储常见端口(由服务器既有服务提供):
|
2026-02-14 17:15:22 +08:00
|
|
|
|
|
2026-08-27 14:53:22 +08:00
|
|
|
|
```env
|
|
|
|
|
|
RUSTFS_ENDPOINT=http://localhost:9000
|
2026-02-14 17:15:22 +08:00
|
|
|
|
```
|
|
|
|
|
|
|
2026-08-27 14:53:22 +08:00
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
|
|
## 2. 各端口的含义
|
|
|
|
|
|
|
|
|
|
|
|
| 变量 / 端口 | 用途 |
|
|
|
|
|
|
|---|---|
|
2026-08-31 18:01:34 +08:00
|
|
|
|
| `FRONTEND_PORT` | 前端 Nginx 宿主机暴露端口 |
|
|
|
|
|
|
| `BACKEND_PORT` | unified backend 宿主机暴露端口 |
|
2026-09-02 18:18:42 +08:00
|
|
|
|
| `MOLDINSIGHT_PORT` | moldinsight-only 独立部署端口 |
|
2026-08-31 18:01:34 +08:00
|
|
|
|
| `INVENTORY_PORT` | inventory-only 独立部署端口 |
|
2026-08-27 14:53:22 +08:00
|
|
|
|
| `DB_PORT` | PostgreSQL 端口 |
|
|
|
|
|
|
| `REDIS_PORT` | Redis 端口 |
|
|
|
|
|
|
| `9000` | MinIO/RustFS S3 兼容 API |
|
|
|
|
|
|
| `9001` | MinIO 控制台 |
|
|
|
|
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
|
|
## 3. 推荐配置方式
|
|
|
|
|
|
|
2026-09-02 18:18:42 +08:00
|
|
|
|
### 3.1 moldinsight-only
|
2026-08-27 14:53:22 +08:00
|
|
|
|
|
|
|
|
|
|
```env
|
|
|
|
|
|
MOLDINSIGHT_PORT=8000
|
|
|
|
|
|
DB_PORT=5432
|
|
|
|
|
|
REDIS_PORT=6379
|
2026-02-14 17:15:22 +08:00
|
|
|
|
```
|
|
|
|
|
|
|
2026-08-27 14:53:22 +08:00
|
|
|
|
### 3.2 inventory-only
|
2026-02-14 17:15:22 +08:00
|
|
|
|
|
2026-08-27 14:53:22 +08:00
|
|
|
|
```env
|
|
|
|
|
|
INVENTORY_PORT=8001
|
|
|
|
|
|
DB_PORT=5432
|
|
|
|
|
|
REDIS_PORT=6379
|
2026-02-14 17:15:22 +08:00
|
|
|
|
```
|
|
|
|
|
|
|
2026-08-27 14:53:22 +08:00
|
|
|
|
### 3.3 full / 模块同时部署
|
|
|
|
|
|
|
|
|
|
|
|
```env
|
|
|
|
|
|
MOLDINSIGHT_PORT=8000
|
|
|
|
|
|
INVENTORY_PORT=8001
|
|
|
|
|
|
DB_PORT=5432
|
|
|
|
|
|
REDIS_PORT=6379
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
2026-09-02 18:18:42 +08:00
|
|
|
|
## 4. direct run 与 Compose 的映射
|
2026-08-27 14:53:22 +08:00
|
|
|
|
|
2026-09-02 18:18:42 +08:00
|
|
|
|
通过直接运行或 Docker Compose 部署时,端口含义保持一致,但映射方式不同。
|
2026-08-27 14:53:22 +08:00
|
|
|
|
|
2026-09-02 18:18:42 +08:00
|
|
|
|
### direct run
|
2026-08-27 14:53:22 +08:00
|
|
|
|
|
2026-09-02 18:18:42 +08:00
|
|
|
|
moldinsight:
|
2026-08-27 14:53:22 +08:00
|
|
|
|
|
2026-02-14 17:15:22 +08:00
|
|
|
|
```bash
|
2026-08-27 14:53:22 +08:00
|
|
|
|
uvicorn src.entrypoints.moldinsight:app --port 8000
|
2026-02-14 17:15:22 +08:00
|
|
|
|
```
|
|
|
|
|
|
|
2026-08-27 14:53:22 +08:00
|
|
|
|
inventory:
|
|
|
|
|
|
|
2026-02-14 17:15:22 +08:00
|
|
|
|
```bash
|
2026-08-27 14:53:22 +08:00
|
|
|
|
uvicorn src.entrypoints.inventory:app --port 8001
|
2026-02-14 17:15:22 +08:00
|
|
|
|
```
|
|
|
|
|
|
|
2026-08-27 14:53:22 +08:00
|
|
|
|
### Docker Compose
|
|
|
|
|
|
|
|
|
|
|
|
Compose 通过端口映射暴露服务:
|
|
|
|
|
|
|
2026-09-02 18:18:42 +08:00
|
|
|
|
- moldinsight → `${MOLDINSIGHT_PORT}:8000`
|
2026-08-27 14:53:22 +08:00
|
|
|
|
- inventory → `${INVENTORY_PORT}:8001`
|
|
|
|
|
|
|
|
|
|
|
|
当前实际定义见:
|
2026-09-24 15:28:13 +08:00
|
|
|
|
- [docker-compose.yml](../../docker-compose.yml)(unified / moldinsight-only)
|
|
|
|
|
|
- [docker-compose.inventory.yml](../../docker-compose.inventory.yml)(inventory-only 的 `INVENTORY_PORT`)
|
2026-08-27 14:53:22 +08:00
|
|
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
2026-09-02 18:18:42 +08:00
|
|
|
|
## 5. 与前端配置的关系
|
2026-08-27 14:53:22 +08:00
|
|
|
|
|
|
|
|
|
|
前端是否使用 unified / split deployment,会影响前端 API 地址配置。
|
|
|
|
|
|
|
|
|
|
|
|
### unified
|
|
|
|
|
|
- 一个 API 基地址
|
|
|
|
|
|
|
|
|
|
|
|
### split
|
2026-09-02 18:18:42 +08:00
|
|
|
|
- moldinsight 与 inventory 各自基地址
|
2026-08-27 14:53:22 +08:00
|
|
|
|
|
|
|
|
|
|
因此,修改后端端口后,可能还需要同步:
|
2026-02-14 17:15:22 +08:00
|
|
|
|
|
2026-08-27 14:53:22 +08:00
|
|
|
|
- 前端 `.env`
|
|
|
|
|
|
- Nginx 反向代理
|
|
|
|
|
|
- 浏览器访问地址
|
2026-02-14 17:15:22 +08:00
|
|
|
|
|
2026-08-27 14:53:22 +08:00
|
|
|
|
---
|
2026-02-14 17:15:22 +08:00
|
|
|
|
|
2026-09-02 18:18:42 +08:00
|
|
|
|
## 6. 推荐实践
|
2026-02-14 17:15:22 +08:00
|
|
|
|
|
2026-08-27 14:53:22 +08:00
|
|
|
|
1. **本地开发**
|
2026-09-02 18:18:42 +08:00
|
|
|
|
- moldinsight:8000
|
2026-08-27 14:53:22 +08:00
|
|
|
|
- inventory:8001
|
2026-02-14 17:15:22 +08:00
|
|
|
|
|
2026-08-27 14:53:22 +08:00
|
|
|
|
2. **服务器部署**
|
|
|
|
|
|
- 外网只暴露 80/443
|
|
|
|
|
|
- Nginx 反代到 8000 / 8001
|
2026-02-14 17:15:22 +08:00
|
|
|
|
|
2026-09-02 18:18:42 +08:00
|
|
|
|
3. 修改端口后,同步检查 `.env`、Compose 端口映射、前端环境变量与反向代理配置
|
2026-02-14 17:15:22 +08:00
|
|
|
|
|
2026-08-27 14:53:22 +08:00
|
|
|
|
---
|
2026-02-14 17:15:22 +08:00
|
|
|
|
|
2026-09-02 18:18:42 +08:00
|
|
|
|
## 7. 关联文档
|
2026-02-14 17:15:22 +08:00
|
|
|
|
|
2026-08-27 14:53:22 +08:00
|
|
|
|
- [LINUX_SETUP.md](./LINUX_SETUP.md)
|
|
|
|
|
|
- [DEPLOY_PORT.md](./DEPLOY_PORT.md)
|
2026-09-01 18:05:18 +08:00
|
|
|
|
- [archive/BACKEND_MODULARIZATION_BLUEPRINT.md](../archive/BACKEND_MODULARIZATION_BLUEPRINT.md)
|
2026-08-27 14:53:22 +08:00
|
|
|
|
- [README.md](../../README.md)
|