InternLM / MindSearch

🔍 An LLM-based Multi-agent Framework of Web Search Engine (like Perplexity.ai Pro and SearchGPT)
https://mindsearch.netlify.app/
Apache License 2.0
5.07k stars 512 forks source link

Optimize Docker Setup, Resolve CORS Issues, and Fix Dependency Conflicts #170

Closed lcolok closed 2 months ago

lcolok commented 2 months ago

Optimize Docker Setup, Resolve CORS Issues, and Fix Dependency Conflicts

Key Changes

  1. Optimized the frontend Dockerfile for better caching and faster builds:

    • Separated package installation from source code copying
    • Added concise comments explaining the structure's benefits
  2. Implemented a development-mode solution for CORS issues:

    • Restructured frontend.dockerfile to use npm start (vite --host --mode dev)
    • Configured Vite dev server in the frontend container to proxy API requests
    • Updated vite.config.ts to handle /solve endpoint proxying, allowing direct communication between containers
  3. Fixed a dependency conflict in the backend:

    • Downgraded griffe to version 0.48.0 in backend.dockerfile
  4. Updated README to reflect these changes:

    • Added explanation of the current CORS handling in development
    • Noted limitations and future considerations for production environments

Detailed Description

The frontend Dockerfile restructuring now utilizes Vite's development mode, allowing the frontend container to communicate with the backend container directly through http://backend:8002. This approach, combined with Vite's proxy service, effectively resolves CORS issues in the development environment.

We would like to acknowledge that this CORS resolution method was implemented based on the guidance provided in the frontend documentation. The documentation's suggestion to use Vite's proxy configuration in vite.config.ts was instrumental in resolving the CORS issues.

The griffe version downgrade addresses the issue reported in #166. We appreciate the community's contribution in identifying this problem.

These changes aim to improve the development experience, build efficiency, and resolve compatibility issues while providing a robust solution for CORS issues in the development environment. Future work will focus on implementing a production-ready approach to handle cross-origin requests.


优化 Docker 配置、解决跨域问题并修复依赖冲突

主要变更

  1. 优化前端 Dockerfile 以提高缓存利用率和构建速度:

    • 将包安装与源代码复制分离
    • 添加简洁的注释说明结构的优势
  2. 为跨域问题实现了开发模式解决方案

    • 重构 frontend.dockerfile 以使用 npm start(vite --host --mode dev)
    • 在前端容器中配置 Vite 开发服务器以代理 API 请求
    • 更新 vite.config.ts 以处理 /solve 端点的代理,实现容器间的直接通信
  3. 修复后端的依赖冲突

    • backend.dockerfile 中将 griffe 降级到 0.48.0 版本
  4. 更新 README 以反映这些变更:

    • 添加了对当前开发环境中跨域处理的解释
    • 注明了生产环境的限制和未来考虑事项

详细描述

前端 Dockerfile 的重构现在利用 Vite 的开发模式,允许前端容器通过 http://backend:8002 直接与后端容器通信。这种方法结合 Vite 的代理服务,有效解决了开发环境中的跨域问题。

我们要特别感谢前端文档中提供的指导。文档中建议在 vite.config.ts 中使用 Vite 的代理配置的方法对解决跨域问题起到了关键作用。

griffe 版本的降级解决了 #166 中报告的问题。我们感谢社区在识别这个问题上的贡献。

这些改动旨在改善开发体验、提高构建效率并解决兼容性问题,同时为开发环境中的跨域问题提供了稳健的解决方案。未来的工作将集中在实现适用于生产环境的跨源请求处理方法。