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
44.47k stars 9.98k forks source link

[Bug] Docker database pgvector connectivity issue on Lobchat files section #4134

Closed BILAL324 closed 1 month ago

BILAL324 commented 1 month ago

📦 Environment

Docker

📌 Version

latest

💻 Operating System

Ubuntu

🌐 Browser

Chrome

🐛 Bug Description

WhatsApp Image 2024-09-25 at 3 38 53 PM

the Postgresql database pgvector should list the database or if empty should show that but it just keep sending get request and get the response of permission denied I checked in the docker container of the application the database is accessible properly as you can see in img but showing error on frontend

WhatsApp Image 2024-09-25 at 4 10 50 PM

WhatsApp Image 2024-09-25 at 4 12 11 PM

📷 Recurrence Steps

i thing there is an issue in the image file so build that igain with the connectivity and all other testings and then push it

🚦 Expected Behavior

the Postgresql database should list the database or if empty should show that but it just keep sending get request and get the response of permission denied even in the docke container of the application the database is accessible properly

📝 Additional Information

No response

lobehubbot commented 1 month ago

👀 @BILAL324

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 1 month ago

Hey @BILAL324, I'm here to assist you with any bugs, questions, or contributions you have. Let's squash those bugs together! 🤖

I found a similar closed issue that might help you resolve the Docker database pgvector connectivity issue. The issue was related to the configuration of the DATABASE_URL environment variable and Docker network setup [1].

To resolve the issue, follow these steps:

  1. Create a Docker network:

    docker network create pg
  2. Run the PostgreSQL container with the pgvector plugin:

    docker run --name my-postgres --network pg -e POSTGRES_PASSWORD=mysecretpassword -p 5432:5432 -d pgvector/pgvector:pg16
  3. Create a file named lobe-chat.env to store environment variables:

    # Website domain
    APP_URL=https://your-prod-domain.com
    
    # DB required environment variables
    KEY_VAULTS_SECRET=jgwsK28dspyVQoIf8/M3IIHl1h6LYYceSYNXeLpy6uk=
    # Postgres database connection string
    DATABASE_URL=postgres://postgres:mysecretpassword@my-postgres:5432/postgres
    
    # NEXT_AUTH related
    NEXT_AUTH_SECRET=3904039cd41ea1bdf6c93db0db96e250
    NEXT_AUTH_SSO_PROVIDERS=auth0
    NEXTAUTH_URL=https://your-prod-domain.com/api/auth
    AUTH0_CLIENT_ID=xxxxxx
    AUTH0_CLIENT_SECRET=cSX_xxxxx
    AUTH0_ISSUER=https://lobe-chat-demo.us.auth0.com
    
    # S3 related
    S3_ACCESS_KEY_ID=xxxxxxxxxx
    S3_SECRET_ACCESS_KEY=xxxxxxxxxx
    S3_ENDPOINT=https://xxxxxxxxxx.r2.cloudflarestorage.com
    S3_BUCKET=lobechat
    S3_PUBLIC_DOMAIN=https://s3-for-lobechat.your-domain.com
  4. Start the lobe-chat-database Docker image:

    docker run -it -d -p 3210:3210 --network pg --env-file lobe-chat.env --name lobe-chat-database lobehub/lobe-chat-database
  5. Check the logs to ensure the container started successfully:

    docker logs -f lobe-chat-database

Additionally, ensure that the DATABASE_URL is correctly pointing to the PostgreSQL container (my-postgres) and that the network (pg) is properly set up to allow communication between the containers [2][3].

For a more streamlined setup, you can use the provided docker-compose.yml configuration:

services:
  postgresql:
    image: pgvector/pgvector:pg16
    container_name: lobe-postgres
    ports:
      - '5432:5432'
    volumes:
      - './data:/var/lib/postgresql/data'
    environment:
      - 'POSTGRES_DB=lobe'
      - 'POSTGRES_PASSWORD=uWNZugjBqixf8dxC'
    healthcheck:
      test: ['CMD-SHELL', 'pg_isready -U postgres']
      interval: 5s
      timeout: 5s
      retries: 5
    restart: always

  minio:
    image: minio/minio
    container_name: lobe-minio
    ports:
      - '9000:9000'
      - '9001:9001'
    volumes:
      - './s3_data:/etc/minio/data'
    environment:
      - 'MINIO_ROOT_USER=YOUR_MINIO_USER'
      - 'MINIO_ROOT_PASSWORD=YOUR_MINIO_PASSWORD'
      - 'MINIO_DOMAIN=lobe-s3-api.example.com'
      - 'MINIO_API_CORS_ALLOW_ORIGIN=https://lobe.example.com'
    restart: always
    command: >
      server /etc/minio/data --address ":9000" --console-address ":9001"

  logto:
    image: svhd/logto
    container_name: lobe-logto
    ports:
      - '3001:3001'
      - '3002:3002'
    depends_on:
      postgresql:
        condition: service_healthy
    environment:
      - 'TRUST_PROXY_HEADER=1'
      - 'DB_URL=postgresql://postgres:uWNZugjBqixf8dxC@postgresql:5432/logto'
      - 'ENDPOINT=https://lobe-auth-api.example.com'
      - 'ADMIN_ENDPOINT=https://lobe-auth-ui.example.com'
    entrypoint: ['sh', '-c', 'npm run cli db seed -- --swe && npm start']

  lobe:
    image: lobehub/lobe-chat-database
    container_name: lobe-database
    ports:
      - '3210:3210'
    depends_on:
      - postgresql
      - minio
      - logto
    env_file:
      - .env
    restart: always

volumes:
  data:
    driver: local
  s3_data:
    driver: local

Ensure that the environment variables in the .env file are correctly configured [4][5].

For more detailed instructions, refer to the LobeChat Server Database Deployment Guide [6].

To continue talking to Dosu, mention @dosu.

arvinxx commented 1 month ago

I think it's not the lobe-chat-database image's issue. It's impossible to list image in the LobeChat frontend. You should check the connection at the container level.

Please check your docker image log, I think it's an issue with your db like missing the pgvector plugin