Skip to content

Streamlit RAG with RedisSearch in Docker Compose

Local RAG demo

This example extends the small Streamlit chat demo into a local retrieval-augmented generation stack with file upload, embeddings through LunarGate, Ollama for local models, and RedisSearch for vector retrieval.

Use this example when:

  • you want a local RAG demo with a browser UI
  • you want to upload .txt and .md files and chat over them
  • you want a concrete example of chat plus embeddings in one stack

What it demonstrates

  • Streamlit upload flow for .txt and .md
  • chunking local files into retrieval units
  • embeddings through LunarGate with local Ollama
  • RedisSearch as a local vector store
  • chat answers grounded in retrieved chunks

Services in the stack

  • gateway
  • ollama
  • ollama-pull-models
  • redis
  • streamlit-rag

Run it

Simple local mode:

cp .env.example .env
cp config-simple.yaml.example config.yaml
docker compose up --build

Observability mode with the LunarGate Dashboard on app.lunargate.ai:

cp .env.example .env
cp config-observability.yaml.example config.yaml
export LUNARGATE_GATEWAY_API_KEY="lgw_your_gateway_api_key"
docker compose up --build

Create that gateway API key in the Gateways section of app.lunargate.ai.

On the first run, startup can take a while because ollama-pull-models downloads both required models before the Streamlit app starts.

Open:

http://127.0.0.1:8501

What to inspect

  • app/app.py for chunking, embedding, retrieval, and chat flow
  • docker-compose.yml for the five-service local stack
  • config-simple.yaml.example for separate chat and embeddings routes
  • config-observability.yaml.example for request inspection in the LunarGate Dashboard on app.lunargate.ai plus remote control
  • gateway.Dockerfile for the published-image wrapper that bakes in the local config.yaml

Files that matter

  • .env.example for compose runtime env vars and model names
  • config-simple.yaml.example for the smallest working local setup
  • config-observability.yaml.example for data_sharing and remote control
  • config.yaml for the file that actually gets baked into the gateway image during docker compose build

Why this example matters

This is the first example in the docs set that shows both:

  • POST /v1/embeddings
  • POST /v1/chat/completions

working together in one runnable local app.

That makes it the best starting point if you want to prototype semantic search, knowledge-base chat, or small internal copilots without adding an external vector database first.

Important deployment detail

The gateway service wraps the published ghcr.io/lunargate-ai/gateway:latest image and copies the example-local config.yaml into it during docker compose build.

That wrapper-image pattern is intentional. It is more reliable than bind-mounting a config file when Docker runs on a remote context instead of directly on your machine.

Good companion pages

  • Read HTTP API for the two OpenAI-compatible endpoints used by this stack.
  • Read routing if you want distinct chat and embeddings routes in your own config.