Files
DDDMicroFrontend/doc/思路整理.md
2025-10-04 00:08:33 +08:00

51 lines
1.6 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

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.

## 遇到的问题
尝试将app-product 模块进行集群部署上线的时候我们会编写dockerfile对项目进行docker build打包
dockerfile 其中命令:
```bash
RUN npx vite build --base=/app-product/
```
正常流程是:
vite build 会使用项目中的 vite.config.ts进行前端项目的构建产生 dist 文件夹基于nginx提供给用户访问
但这时候,我们在 vite.config.ts 使用自己开发的插件 vite-plugin-nacos 将前端注册到服务中心
因为和服务中心链接后,插件会一直保持心跳导致无法断开,此时 `vite build` 已经 产生 dist了但是因为心跳阻塞了docker build 的后续执行,导致项目无法打包成镜像,也就无法开展后续流程进行集群部署。
## 新的改变!!
所有微前端都不需要进行服务注册,因为前端由浏览器访问,注册实例毫无意义,无法保持心跳,就无法检查服务的健康!
## 新的架构
<!-- 在 实现 **新的改变** 之前,需要熟悉现有系统的架构和设计,如下:
外网:
main-app是整个项目的入口和壳应用
网关traefik
内网:
app-product 商品模块
app-shared 共享模块 -->
局域网
所有模块之间,通过 配置发现 来获取 所依赖 远程模块 的 实际网址
外网
模块通过 网关 反向代理来访问 所依赖 远程模块
## 新的架构带来的新的问题
局域网模块 之间通过 配置发现也会和服务注册一样和Nacos集群保持链接导致 vite build 无法退出。。。。
## 如何解决??