Basic docker container building & example for running haiku.rag in docker compose
This commit is contained in:
parent
5763f89438
commit
48dbf5ff59
9 changed files with 248 additions and 1 deletions
47
docker/.dockerignore
Normal file
47
docker/.dockerignore
Normal file
|
|
@ -0,0 +1,47 @@
|
||||||
|
# Python
|
||||||
|
__pycache__/
|
||||||
|
*.py[cod]
|
||||||
|
*$py.class
|
||||||
|
*.so
|
||||||
|
.Python
|
||||||
|
build/
|
||||||
|
develop-eggs/
|
||||||
|
dist/
|
||||||
|
downloads/
|
||||||
|
eggs/
|
||||||
|
.eggs/
|
||||||
|
lib/
|
||||||
|
lib64/
|
||||||
|
parts/
|
||||||
|
sdist/
|
||||||
|
var/
|
||||||
|
wheels/
|
||||||
|
*.egg-info/
|
||||||
|
.installed.cfg
|
||||||
|
*.egg
|
||||||
|
.venv/
|
||||||
|
venv/
|
||||||
|
|
||||||
|
# Data
|
||||||
|
*.lancedb/
|
||||||
|
data/
|
||||||
|
docs/
|
||||||
|
|
||||||
|
# IDE
|
||||||
|
.vscode/
|
||||||
|
.idea/
|
||||||
|
*.swp
|
||||||
|
*.swo
|
||||||
|
*~
|
||||||
|
|
||||||
|
# OS
|
||||||
|
.DS_Store
|
||||||
|
Thumbs.db
|
||||||
|
|
||||||
|
# Git
|
||||||
|
.git/
|
||||||
|
.gitignore
|
||||||
|
|
||||||
|
# Examples
|
||||||
|
examples/docker/data/
|
||||||
|
examples/docker/docs/
|
||||||
34
docker/Dockerfile
Normal file
34
docker/Dockerfile
Normal file
|
|
@ -0,0 +1,34 @@
|
||||||
|
# Use Python 3.12 slim image
|
||||||
|
FROM python:3.12-slim
|
||||||
|
|
||||||
|
# Set working directory
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
# Install system dependencies required for building Python packages
|
||||||
|
RUN apt-get update && apt-get install -y \
|
||||||
|
build-essential \
|
||||||
|
curl \
|
||||||
|
git \
|
||||||
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
|
# Install uv for fast Python package management
|
||||||
|
RUN curl -LsSf https://astral.sh/uv/install.sh | sh
|
||||||
|
ENV PATH="/root/.local/bin:$PATH"
|
||||||
|
|
||||||
|
# Copy project files
|
||||||
|
COPY . /app
|
||||||
|
|
||||||
|
# Install haiku.rag with all extras in development mode
|
||||||
|
RUN uv pip install --system -e ".[voyageai,mxbai,a2a]"
|
||||||
|
|
||||||
|
# Create data directory for the database
|
||||||
|
RUN mkdir -p /data
|
||||||
|
|
||||||
|
# Default database path
|
||||||
|
ENV HAIKU_RAG_DB_PATH=/data/haiku.rag.lancedb
|
||||||
|
|
||||||
|
# Expose ports for MCP and A2A
|
||||||
|
EXPOSE 8000 8001
|
||||||
|
|
||||||
|
# Default command runs all services (monitoring, MCP, A2A)
|
||||||
|
CMD ["haiku-rag", "serve", "--monitor", "--mcp", "--mcp-port", "8001", "--a2a", "--a2a-host", "0.0.0.0", "--a2a-port", "8000", "--db", "/data/haiku.rag.lancedb"]
|
||||||
27
docker/README.md
Normal file
27
docker/README.md
Normal file
|
|
@ -0,0 +1,27 @@
|
||||||
|
# haiku.rag Docker Image
|
||||||
|
|
||||||
|
Dockerfile for building haiku.rag with all extras (voyageai, mxbai, a2a).
|
||||||
|
|
||||||
|
## Building
|
||||||
|
|
||||||
|
```bash
|
||||||
|
docker build -f docker/Dockerfile -t haiku-rag .
|
||||||
|
```
|
||||||
|
|
||||||
|
## Running
|
||||||
|
|
||||||
|
```bash
|
||||||
|
docker run -p 8000:8000 -p 8001:8001 \
|
||||||
|
-v $(pwd)/data:/data \
|
||||||
|
-e EMBEDDINGS_PROVIDER=ollama \
|
||||||
|
-e EMBEDDINGS_MODEL=nomic-embed-text \
|
||||||
|
-e QA_PROVIDER=ollama \
|
||||||
|
-e QA_MODEL=qwen3\
|
||||||
|
haiku-rag
|
||||||
|
```
|
||||||
|
|
||||||
|
Note: The environment variables above override the defaults. See [Configuration docs](https://ggozad.github.io/haiku.rag/configuration/) for all options.
|
||||||
|
|
||||||
|
## Docker Compose
|
||||||
|
|
||||||
|
See `examples/docker/` for a complete setup example.
|
||||||
|
|
@ -2,6 +2,17 @@
|
||||||
|
|
||||||
This directory contains example scripts demonstrating various features of haiku.rag.
|
This directory contains example scripts demonstrating various features of haiku.rag.
|
||||||
|
|
||||||
|
## Docker Example
|
||||||
|
|
||||||
|
**Directory:** `docker/`
|
||||||
|
|
||||||
|
Complete Docker setup for running haiku.rag with all services:
|
||||||
|
- File monitoring for automatic document indexing
|
||||||
|
- MCP server for AI assistant integration
|
||||||
|
- A2A agent for conversational interactions
|
||||||
|
|
||||||
|
See `docker/README.md` for setup instructions.
|
||||||
|
|
||||||
## A2A Security Examples
|
## A2A Security Examples
|
||||||
|
|
||||||
**Directory:** `a2a-security/`
|
**Directory:** `a2a-security/`
|
||||||
|
|
|
||||||
16
examples/docker/.env.example
Normal file
16
examples/docker/.env.example
Normal file
|
|
@ -0,0 +1,16 @@
|
||||||
|
# Database
|
||||||
|
HAIKU_RAG_DB_PATH=/data/haiku.rag.lancedb
|
||||||
|
|
||||||
|
# File monitoring
|
||||||
|
MONITOR_DIRECTORIES=/docs
|
||||||
|
|
||||||
|
# Default: Ollama on host
|
||||||
|
EMBEDDINGS_PROVIDER=ollama
|
||||||
|
EMBEDDINGS_MODEL=nomic-embed-text
|
||||||
|
QA_PROVIDER=ollama
|
||||||
|
QA_MODEL=qwen3
|
||||||
|
OLLAMA_BASE_URL=http://host.docker.internal:11434
|
||||||
|
|
||||||
|
# For other providers, see: https://ggozad.github.io/haiku.rag/configuration/
|
||||||
|
|
||||||
|
ENV=production
|
||||||
8
examples/docker/.gitignore
vendored
Normal file
8
examples/docker/.gitignore
vendored
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
# Data directory
|
||||||
|
data/
|
||||||
|
|
||||||
|
# Documents directory
|
||||||
|
docs/
|
||||||
|
|
||||||
|
# Environment file with secrets
|
||||||
|
.env
|
||||||
44
examples/docker/README.md
Normal file
44
examples/docker/README.md
Normal file
|
|
@ -0,0 +1,44 @@
|
||||||
|
# haiku.rag Docker Compose Example
|
||||||
|
|
||||||
|
Run haiku.rag with file monitoring, MCP server, and A2A agent.
|
||||||
|
|
||||||
|
## Quick Start
|
||||||
|
|
||||||
|
```bash
|
||||||
|
mkdir -p data docs
|
||||||
|
cp .env.example .env # Edit if needed
|
||||||
|
docker compose up -d
|
||||||
|
```
|
||||||
|
|
||||||
|
Place documents in `docs/` for automatic indexing.
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Search
|
||||||
|
docker compose exec haiku-rag haiku-rag search "your query"
|
||||||
|
|
||||||
|
# Ask questions
|
||||||
|
docker compose exec haiku-rag haiku-rag ask "What is haiku.rag?"
|
||||||
|
|
||||||
|
# A2A interactive client
|
||||||
|
docker compose exec haiku-rag haiku-rag a2aclient --url http://localhost:8000
|
||||||
|
```
|
||||||
|
|
||||||
|
## Ports
|
||||||
|
|
||||||
|
- `8000` - A2A agent
|
||||||
|
- `8001` - MCP server
|
||||||
|
|
||||||
|
## Configuration
|
||||||
|
|
||||||
|
Edit `.env` or `docker-compose.yml` to configure providers. See the [Configuration documentation](https://ggozad.github.io/haiku.rag/configuration/) for all options.
|
||||||
|
|
||||||
|
Default setup uses Ollama on the host (`host.docker.internal:11434`).
|
||||||
|
|
||||||
|
## Documentation
|
||||||
|
|
||||||
|
- [Configuration](https://ggozad.github.io/haiku.rag/configuration/)
|
||||||
|
- [CLI Commands](https://ggozad.github.io/haiku.rag/cli/)
|
||||||
|
- [MCP Server](https://ggozad.github.io/haiku.rag/mcp/)
|
||||||
|
- [A2A Agent](https://ggozad.github.io/haiku.rag/a2a/)
|
||||||
60
examples/docker/docker-compose.yml
Normal file
60
examples/docker/docker-compose.yml
Normal file
|
|
@ -0,0 +1,60 @@
|
||||||
|
services:
|
||||||
|
haiku-rag:
|
||||||
|
build:
|
||||||
|
context: ../..
|
||||||
|
dockerfile: docker/Dockerfile
|
||||||
|
container_name: haiku-rag
|
||||||
|
ports:
|
||||||
|
- "8000:8000" # A2A server
|
||||||
|
- "8001:8001" # MCP server
|
||||||
|
volumes:
|
||||||
|
- ./data:/data # Persist database
|
||||||
|
- ./docs:/docs # Mount documents directory for monitoring
|
||||||
|
environment:
|
||||||
|
# Database
|
||||||
|
- HAIKU_RAG_DB_PATH=/data/haiku.rag.lancedb
|
||||||
|
|
||||||
|
# File monitoring
|
||||||
|
- MONITOR_DIRECTORIES=/docs
|
||||||
|
|
||||||
|
# Set the Ollama base url for Ollama defaults
|
||||||
|
- OLLAMA_BASE_URL=http://host.docker.internal:11434
|
||||||
|
|
||||||
|
# Embeddings provider (choose one)
|
||||||
|
# For OpenAI:
|
||||||
|
# - EMBEDDINGS_PROVIDER=openai
|
||||||
|
# - EMBEDDINGS_MODEL=text-embedding-3-small
|
||||||
|
# - OPENAI_API_KEY=your-key-here
|
||||||
|
|
||||||
|
# For VoyageAI:
|
||||||
|
# - EMBEDDINGS_PROVIDER=voyageai
|
||||||
|
# - EMBEDDINGS_MODEL=voyage-3
|
||||||
|
# - VOYAGE_API_KEY=your-key-here
|
||||||
|
|
||||||
|
# QA provider (uses Pydantic AI)
|
||||||
|
# - QA_PROVIDER=ollama
|
||||||
|
|
||||||
|
# For OpenAI:
|
||||||
|
# - QA_PROVIDER=openai
|
||||||
|
# - QA_MODEL=gpt-4o-mini
|
||||||
|
# - OPENAI_API_KEY=your-key-here
|
||||||
|
|
||||||
|
# Reranking (optional)
|
||||||
|
# - RERANKING_PROVIDER=mxbai
|
||||||
|
# - RERANKING_MODEL=mixedbread-ai/mxbai-rerank-large-v1
|
||||||
|
# - RERANKING_BASE_URL=http://host.docker.internal:11434
|
||||||
|
|
||||||
|
# Research agent (optional, defaults to QA provider/model)
|
||||||
|
# - RESEARCH_PROVIDER=openai
|
||||||
|
# - RESEARCH_MODEL=gpt-4o
|
||||||
|
|
||||||
|
# Environment
|
||||||
|
- ENV=production
|
||||||
|
|
||||||
|
restart: unless-stopped
|
||||||
|
healthcheck:
|
||||||
|
test: ["CMD", "curl", "-f", "http://localhost:8000/health"]
|
||||||
|
interval: 30s
|
||||||
|
timeout: 10s
|
||||||
|
retries: 3
|
||||||
|
start_period: 40s
|
||||||
|
|
@ -50,7 +50,7 @@ requires = ["hatchling"]
|
||||||
build-backend = "hatchling.build"
|
build-backend = "hatchling.build"
|
||||||
|
|
||||||
[tool.hatch.build]
|
[tool.hatch.build]
|
||||||
exclude = ["/docs", "/examples", "/tests", "/.github"]
|
exclude = ["/docs", "/examples", "/tests", "/docker", "/.github"]
|
||||||
|
|
||||||
[tool.hatch.build.targets.wheel]
|
[tool.hatch.build.targets.wheel]
|
||||||
packages = ["src/haiku"]
|
packages = ["src/haiku"]
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue