Skip to content

Running RAGit using docker

AdaptAware edited this page Dec 8, 2024 · 2 revisions

Deployment Steps

This documentation provides instructions for deploying a standalone RAGIT application using Docker.

Create the docker-compose file

  • Create a new directory in any location you prefer where you will store all necessary files for deployment.

  • Under this directory create a file named docker-compose.yaml with the following content:

version: "3.8"

services:
    frontend:
      image: adaptaware/ragit:1.0
      environment:
        - OPENAI_API_KEY=${OPENAI_API_KEY}
        - SERVICE_PORT=${INTERNAL_FRONT_END_PORT}
        - RAG_COLLECTION=${RAG_COLLECTION}
        - VECTOR_DB_PROVIDER=${VECTOR_DB_PROVIDER}
      volumes:
        - ${SHARED_DIR}:/root/ragit-data
      ports:
        - "${EXTERNAL_FRONT_END_PORT}:${INTERNAL_FRONT_END_PORT}"
    backend:
        image: adaptaware/ragit-back-end:1.0
        environment:
            - OPENAI_API_KEY=${OPENAI_API_KEY}
            - POSTGRES_DB=${POSTGRES_DB}
            - POSTGRES_USER=${POSTGRES_USER}
            - POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
            - POSTGRES_PORT=${POSTGRES_PORT}
            - POSTGRES_HOST=${POSTGRES_HOST}
            - VECTOR_DB_PROVIDER=${VECTOR_DB_PROVIDER}
        volumes:
            - ${SHARED_DIR}:/root/ragit-data
        stdin_open: true  # Keep stdin open even if not attached
        tty: true         # Allocate a pseudo-TTY
    db_host:
      image: postgres:latest
      environment:
        - POSTGRES_DB=${POSTGRES_DB}
        - POSTGRES_USER=${POSTGRES_USER}
        - POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
        - POSTGRES_PORT=${POSTGRES_PORT}
        - POSTGRES_HOST=${POSTGRES_HOST}
      volumes:
        - pgdata:/var/lib/postgresql/data
volumes:
  pgdata:

Specify the Environment Variables

  • In the directory containing docker-compose.yaml, create a file named .env with the following content:

    OPENAI_API_KEY=<valid-api-key>
    BIND_ADDRESS=0.0.0.0
    EXTERNAL_FRONT_END_PORT=13133
    INTERNAL_FRONT_END_PORT=13131
    VECTOR_DB_PROVIDER=CHROMA
    SHARED_DIR=<your-home-directory>/ragit-data
    RAG_COLLECTION=<collection-name>
    

    In the above content replace <valid-api-key> with a valid API key and the <collection-name> with a valid collection name (following the above example the collection name would be stories).

  • Customize Variables:

    • Replace valid-api-key with your actual OpenAI API key.
    • Substitute <your-home-directory> with the full path to your home directory.
    • Set collection-name to your specific RAG collection name (e.g., stories).

Create Shared Directory

Under the HOME directory create a ragit-data directory where the data for all the collections will exist.

The structure should be as follows:

 <HOME-DIR>
 └── ragit-data
     └── <your-collection-name>
         └── documents
  • Note: Replace your-collection-name with your actual RAG collection name.

The directory name documents must always exist under the collection and this is where you are placing all the documents that will consist the RAG Collection. Documents can be nested and the directory structure of the documents directory is completely up to the user of RAGit to decide (again the only restriction is to be under the documents directory as seen above.

Running the Service

Navigate to your deployment directory (where docker-compose.yaml is located) and execute the following:

Start the database

 ```bash
 docker-compose up -d db_host
 ```

Start the backend processor

 ```bash
 docker-compose run backend
 ```

From another CLI window start the front end

  • Navigate to your deployment directory (where docker-compose.yaml is located) and execute the following command to launch your Dockerized front end:

    docker-compose up -d frontend

Access the service

Your RAGIT front end should now be operational and accessible locally through the specified external port as follows:

localhost:13133

or remotely

<ip-address>:13133

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 -f $(docker images -q)
docker compose down -v

Clone this wiki locally