From 7167e9cd49f014975dfc3aa3845e53e418bd2b27 Mon Sep 17 00:00:00 2001 From: Russ Ferriday Date: Tue, 24 Jun 2025 15:32:20 +0100 Subject: [PATCH] Add minimal Dockerfile and docker-compose.yml for containerized development --- .dockerignore | 10 ++++++++++ .gitignore | 4 ++++ Dockerfile | 28 ++++++++++++++++++++++++++++ README.md | 33 +++++++++++++++++++++++++++++++++ build-multiplatform.sh | 13 +++++++++++++ docker-compose.yml | 20 ++++++++++++++++++++ 6 files changed, 108 insertions(+) create mode 100644 .dockerignore create mode 100644 Dockerfile create mode 100755 build-multiplatform.sh create mode 100644 docker-compose.yml diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 00000000..959c35d6 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,10 @@ +__pycache__/ +*.pyc +*.pyo +*.db +.git +.gitignore +tests/ +database/ +documents/ +uv.lock \ No newline at end of file diff --git a/.gitignore b/.gitignore index c38836d3..de9e3484 100644 --- a/.gitignore +++ b/.gitignore @@ -17,3 +17,7 @@ tests/data/ # environment variables .env + +# dirs we might mount in docker-compose.yml +documents/ +database/ \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..842d79ea --- /dev/null +++ b/Dockerfile @@ -0,0 +1,28 @@ +FROM python:3.11-slim + +# Install uv using pip instead of the shell installer - to avoid platform issues +RUN pip install uv + +# Set working directory +WORKDIR /app + +# Copy project files +COPY . . + +# Install the package +RUN uv pip install --system . + +# Create directories for mounts +RUN mkdir -p /inbound /database /ollama/models + +# Set environment variables +ENV MONITOR_DIRECTORIES="/inbound" +ENV EMBEDDINGS_PROVIDER="ollama" +ENV EMBEDDINGS_MODEL="mxbai-embed-large" +ENV EMBEDDINGS_VECTOR_DIM=1024 + +# Expose port +EXPOSE 8000 + +# Default command +CMD ["uv", "run", "haiku-rag", "serve", "--db", "/database/haiku-rag.db"] \ No newline at end of file diff --git a/README.md b/README.md index 866fdbca..b6476e7b 100644 --- a/README.md +++ b/README.md @@ -192,3 +192,36 @@ async with HaikuRAG("database.db") as client: print(f"Content: {chunk.content}") print(f"From document: {chunk.document_id}") ``` + +## Docker + +``` bash +docker pull topiaruss/haiku-rag:latest +docker compose up +``` + +### docker-compose.yml file + + * When this runs, a documents directory will be created in this directory. You can drag files here to be indexed. + + * A database directory will be created to hold your haiku-rag.db. + + * The compose file mounts your local `~/.ollama/models` directory into which you should pull in the normal way the models you want to use. These will then be accessible inside the running container. + +For production, expect to edit the docker-compose.yml file +to set a permanent location for your models, database, and document directory. + +Consult Docker resources to understand the many possibilities. + + +### build-multiplatform.sh + +This is a simple builder to provide a multi-platform image. +Replace "topiaruss" with your own dockerhub username, create the haiku-rag +image folder, and issue a `docker login` command + +### check (tail) the logs + +```bash +docker compose logs -f +``` \ No newline at end of file diff --git a/build-multiplatform.sh b/build-multiplatform.sh new file mode 100755 index 00000000..e143c404 --- /dev/null +++ b/build-multiplatform.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +# Create a new builder instance for multi-platform builds +docker buildx create --name multiplatform-builder --use --bootstrap + +# Build for both AMD64 and ARM64 platforms +docker buildx build \ + --platform linux/amd64,linux/arm64 \ + --tag topiaruss/haiku-rag:latest \ + --push \ + . + +echo "The Multi-platform build is nowcomplete for linux/amd64 and linux/arm64" \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 00000000..5a78da28 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,20 @@ +services: + haiku-rag: + build: . + image: topiaruss/haiku-rag:latest + ports: + - "8000:8000" + volumes: + # Mount external directory to /inbound for document monitoring + - ./documents:/inbound + # Mount database directory for persistence + - ./database:/database + # Mount ollama models directory (adjust path as needed) + - ~/.ollama/models:/ollama/models + environment: + - MONITOR_DIRECTORIES=/inbound + - EMBEDDINGS_PROVIDER=ollama + - EMBEDDINGS_MODEL=mxbai-embed-large + - EMBEDDINGS_VECTOR_DIM=1024 + - OLLAMA_BASE_URL=http://host.docker.internal:11434 + restart: unless-stopped \ No newline at end of file