lobehub / lobe-chat

🤯 Lobe Chat - an open-source, modern-design AI chat framework. Supports Multi AI Providers( OpenAI / Claude 3 / Gemini / Ollama / Azure / DeepSeek), Knowledge Base (file upload / knowledge management / RAG ), Multi-Modals (Vision/TTS) and plugin system. One-click FREE deployment of your private ChatGPT/ Claude application.
https://chat-preview.lobehub.com
Other
41.19k stars 9.37k forks source link

[Bug] 本地部署数据库版本时无法正常使用S3存储 #4040

Open jdassd opened 2 days ago

jdassd commented 2 days ago

📦 Environment

Docker

📌 Version

v1.19

💻 Operating System

Ubuntu

🌐 Browser

Chrome

🐛 Bug Description

有一个BUG 3781 反馈 存储桶本地设置和阿里云都不能连接到OSS报错的问题 image 这个错误是说S3_ENDPOINT为不合标准的url地址 但实际填入的内容是标准的

后来凑巧经过1Panel面板查看容器参数时发现 参数后面多了#号,以及原本应该注释掉的中文 怀疑文档模板的文案是有问题的

在环境配置.env文件中去掉后即可正常导入参数

📷 Recurrence Steps

No response

🚦 Expected Behavior

No response

📝 Additional Information

No response

lobehubbot commented 2 days ago

👀 @jdassd

Thank you for raising an issue. We will investigate into the matter and get back to you as soon as possible. Please make sure you have given us as much context as possible.\ 非常感谢您提交 issue。我们会尽快调查此事,并尽快回复您。 请确保您已经提供了尽可能多的背景信息。

dosubot[bot] commented 2 days ago

Hey @jdassd! 👋 I'm here to help you with any bugs, questions, or contributions you have. Let's tackle this issue together!

I found a similar discussion that might be relevant to your issue: 数据库服务端部署时对接阿里云oss服务上传文件出错,求解决!!!, which is still open [1].

To resolve the "Invalid url" errors for the S3_ENDPOINT and S3_PUBLIC_DOMAIN environment variables in your Next.js application when deploying locally using Docker on Ubuntu, ensure that the URLs provided for these variables are correctly formatted and accessible.

Here is an example of how these environment variables should be set in your .env file:

# S3 相关
S3_ACCESS_KEY_ID=xxxxxxxxxx
S3_SECRET_ACCESS_KEY=xxxxxxxxxx
S3_ENDPOINT=http://localhost:9000 # 用于 S3 API 访问的域名
S3_BUCKET=lobechat
S3_PUBLIC_DOMAIN=http://localhost:9000 # 用于外网访问 S3 的公共域名,需配置 CORS
# S3_REGION=ap-chengdu # 如果需要指定地域

Make sure that:

  1. S3_ENDPOINT is a valid URL that points to your S3-compatible storage service.
  2. S3_PUBLIC_DOMAIN is a valid URL that is publicly accessible and correctly configured for CORS.

If the URLs are correct and you are still encountering issues, double-check the following:

Additionally, ensure that the environment variables are correctly set in your Docker Compose configuration. Here is an example snippet from the docker-compose.yml:

services:
  lobe:
    environment:
      - 'S3_ENDPOINT=http://localhost:9000'
      - 'S3_BUCKET=lobechat'
      - 'S3_PUBLIC_DOMAIN=http://localhost:9000'
      - 'S3_ENABLE_PATH_STYLE=1'
    env_file:
      - .env
    restart: always

Make sure these environment variables are populated with the correct values when building and running your Docker container.

If you continue to face issues, you might want to test the URLs directly in a browser or using a tool like curl to ensure they are valid and accessible. Additionally, ensure that your MinIO service is running and properly configured as described in the LobeChat documentation:

  1. Open http://localhost:9001 to access the MinIO WebUI.
  2. Create a bucket that matches the S3_BUCKET field in your .env file.
  3. Configure the necessary policies and access keys in MinIO.

Restart your Docker services after making these changes:

docker compose up -d

If you see the following logs in the container, it indicates that it has started successfully:

[Database] Start to migration...
✅ database migration pass.
-------------------------------------
  ▲ Next.js 14.x.x
  - Local:        http://localhost:3210
  - Network:      http://0.0.0.0:3210

 ✓ Starting...
 ✓ Ready in 95ms

By following these steps, you should be able to resolve the "Invalid url" errors for the S3_ENDPOINT and S3_PUBLIC_DOMAIN environment variables [2][3][4].

To continue talking to Dosu, mention @dosu.

Zoumachuan commented 2 days ago

是这样的,这个env文件除了#后面的注释会变成url的一部分,openaikey的拼写也有问题,希望能修改一下

lobehubbot commented 2 days ago

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


It’s like this. In addition to the comments after # in this env file, it will become part of the URL. There is also a problem with the spelling of openaikey. I hope it can be modified.

BiFangKNT commented 1 day ago

是这样的,这个env文件除了#后面的注释会变成url的一部分,openaikey的拼写也有问题,希望能修改一下

是这样的。我很早之前就提出过教程有问题,一直没改。 #3826 #3909

lobehubbot commented 1 day ago

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


It’s like this. In addition to the comments after # in this env file, it will become part of the url. There is also a problem with the spelling of openaikey. I hope it can be modified.

That's it. I pointed out that there was a problem with the tutorial a long time ago, but it has not been changed. #3826 #3909