RAGIT on Docker - codingismycraft/ragit GitHub Wiki

Prerequisites for Running the RAGIT Application with Docker

Before proceeding with these instructions to start the RAGIT application using Docker, ensure you have the following software installed on your system:

  • Git
  • Docker
  • Docker Compose

Installation Instructions

Installation Instructions for Linux

  1. Install Git:

    sudo apt-get update
    sudo apt-get install git
    
  2. Install Docker:

    sudo apt update
    sudo apt install apt-transport-https ca-certificates curl software-properties-common
    curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
    sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu focal stable"
    apt-cache policy docker-ce
    sudo apt install docker-ce
    sudo usermod -aG docker ${USER}
    su - ${USER}
    sudo usermod -aG docker <your-user-name>
    
  3. Install Docker Compose:

    sudo curl -L "https://github.com/docker/compose/releases/download/1.26.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
    sudo chmod +x /usr/local/bin/docker-compose
    

Installation Instructions for Microsoft Windows

  1. Install Git:

    Download and install Git from the official Git website.

  2. Install Docker Desktop:

    Download and install Docker Desktop from the Docker official website. Docker Compose is included with Docker Desktop.

Installation Instructions for Apple macOS

  1. Install Git:

    Git is often pre-installed on macOS. You can check by running:

    git --version
    

    If it is not installed, you can install it via Homebrew:

    /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
    brew install git
    
  2. Install Docker and Docker Compose:

    Option 1: Directly from Docker's Website

    1. Download Docker Desktop:

      • Visit the Docker Desktop for Mac webpage.
      • Click on the "Mac with Apple Chip" button if you have an Apple Silicon chip (e.g., M1, M1 Pro, etc.) or "Mac with Intel chip" for Intel-based Macs.
    2. Install Docker Desktop:

      • Once the download is complete, open the .dmg file.
      • Drag the Docker icon to your Applications folder.
      • Open Docker from the Applications folder or use Spotlight to find it and open it.
    3. Run Docker Desktop:

      • The Docker whale icon should appear in the menu bar, indicating Docker is running.

    Option 2: Using Homebrew (Package Manager)

    1. Ensure Homebrew is Installed:

      • If you don't have Homebrew installed, you can install it by running:

        /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
        
    2. Install Docker:

      • Open a terminal and run:

        brew install --cask docker
        
    3. Run Docker Desktop:

      • Open Docker from the Applications folder or use Spotlight to find it and open it.
      • You might be asked for your password to grant Docker the necessary permissions.
  3. Install Docker Compose:

    Docker Compose is typically bundled with Docker Desktop for Mac, so you should have Docker Compose installed already. You can verify this by running:

    docker-compose --version
    
  4. Post-installation Steps:

    1. Add Docker to PATH: Docker Desktop should automatically add Docker binaries to your PATH, but if not, you can manually add them. Add the following line to your ~/.zshrc or ~/.bash_profile file (depending on your shell):

      export PATH="/Applications/Docker.app/Contents/Resources/bin:$PATH"
      

      After adding, make sure to reload your shell configuration by running:

      source ~/.zshrc  # or source ~/.bash_profile
      
    2. Verify Docker Installation: Run the following commands to ensure Docker and Docker Compose are installed correctly:

      docker --version
      docker-compose --version
      

Clone the RAGIT Repository

Change to any directory you like to become the root for the RAGIT repository and clone it using the following command:

git clone https://github.com/codingismycraft/ragit.git

Creating the RAGIT Document Directory

The RAGIT document directory is a shared folder between your host and guest machine, containing the RAG collections.

See also

Execute the following command to create the base directory:

mkdir ~/ragit-data
sudo chmod -R 777 ~/ragit-data

Creating a Playground Collection Called Stories

From the root directory of the RAGIT repository, run the following commands:

mkdir -p ~/ragit-data/stories/documents
cp -R ragit/ragit/libs/testing_data/ ~/ragit-data/stories/documents

Create the .env File

Inside the RAGIT directory (where you have cloned the RAGIT repository) at the top level, create a file named .env with the following content:

OPENAI_API_KEY=<valid-openai-key>
POSTGRES_DB=postgres
POSTGRES_USER=postgres
POSTGRES_PASSWORD=mypassword
POSTGRES_PORT=5432
POSTGRES_HOST=db_host
EXTERNAL_FRONT_END_PORT=13133
INTERNAL_FRONT_END_PORT=8789
VECTOR_DB_PROVIDER=<CHROMA or MILVUS>
SHARED_DIR=<path-to-shared-directory>
RAG_COLLECTION=<your-rag-collection-name>

Specifying the shared directory

The SHARED_DIR is pointing to the directory that holds the data collection and is shared accros the host and the guest machine; you should provide it as a full linux path; see the following example:

SHARED_DIR=/home/john/ragit-data

Specifying a valid OPENAI key

Replace <valid-openai-key> with a valid OpenAI key and <path-to-shared-directory> with the directory you have created in the previous step (~/ragit-data). Also, provide a valid collection name for the placeholder <your-rag-collection-name>, for example stories.

Specifying the vector database provider

The currently supported values for the vector database provider are MILVUS and CHROMA.

If you are running under MacOS you should use the CHROMA since there is a bug with Milvus that does not allow it to run under the docker.

Specifying the RAG collection name

The RAG collection name is the name of the sub-directory that holds the documents that will be used for the vectorized database and the RAG pipeline.

Start the RAGIT Relational Database

docker compose up -d db_host

Run RAGIT's Backend

docker compose run backend

The above command will build the backend and start a REPL command line utility that allows you to interact with the RAGIT collections. The available commands in the REPL are as follows:

Show Help:

image

List Available RAG Collections:

Running the command list or l will show all available RAG Collections (for now we only have one, the stories collection we have created in the previous step):

image

Show the Stats for a RAG Collection:

Running the command stats <collection-name> or s <collection-name> will show the statistics for the stories collection:

image

Process All the Non-Processed Documents:

To process the available documents, use the command process <collection-name> or p <collection-name>:

image

Run RAGIT Frontend

From the root directory of RAGIT (where the docker compose file and the .env files exist), execute the following command:

docker compose up -d frontend

After completing the above command and assuming that in your .env file you are specifying:

EXTERNAL_FRONT_END_PORT=13133
RAG_COLLECTION=stories

You should be able to access the frontend of RAGIT using the following URL in your browser:

http://localhost:13133/login

image

After creating a user, you will be able to start using the frontend of the application by entering your questions in the text box as shown in the following screenshot:

image

Clean Up

If you need to start fresh with the Docker installation, you can run the following commands:

docker stop $(docker ps -aq); docker rm $(docker ps -aq); docker image rm $(docker images -q)
docker-compose down -v