haiku.rag-slim docker image

This commit is contained in:
Yiorgis Gozadinos 2025-11-17 14:14:53 +02:00
parent 2f0811da28
commit a31fcad6b0
No known key found for this signature in database
4 changed files with 135 additions and 1 deletions

View file

@ -0,0 +1,57 @@
name: Build & publish Docker slim image
on:
workflow_run:
workflows: ["Build & publish haiku.rag-slim to pypi"]
types:
- completed
workflow_dispatch:
jobs:
docker:
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'success' || github.event_name == 'workflow_dispatch' }}
permissions:
contents: read
packages: write
steps:
- name: Free disk space
uses: jlumbroso/free-disk-space@main
with:
tool-cache: false
android: true
dotnet: true
haskell: true
large-packages: true
docker-images: true
swap-storage: true
- uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract version from pyproject.toml
id: version
run: |
VERSION=$(grep -oP '^version = "\K[^"]+' haiku_rag_slim/pyproject.toml)
echo "version=$VERSION" >> $GITHUB_OUTPUT
- name: Build and push Docker slim image
uses: docker/build-push-action@v6
with:
context: .
file: docker/Dockerfile.slim
platforms: linux/amd64,linux/arm64
push: true
tags: |
ghcr.io/ggozad/haiku.rag-slim:${{ steps.version.outputs.version }}
ghcr.io/ggozad/haiku.rag-slim:latest
cache-from: type=gha
cache-to: type=gha,mode=max

View file

@ -37,4 +37,4 @@ ENV PATH="/app/.venv/bin:$PATH"
EXPOSE 8001
# Run all services (monitoring, MCP)
CMD ["python", "-m", "haiku.rag.cli", "serve", "--monitor", "--mcp", "--mcp-port", "8001", "--db", "/data/haiku.rag.lancedb"]
CMD ["python", "-m", "haiku.rag.cli", "--config", "/app/haiku.rag.yaml", "serve", "--monitor", "--mcp", "--mcp-port", "8001", "--db", "/data/haiku.rag.lancedb"]

39
docker/Dockerfile.slim Normal file
View file

@ -0,0 +1,39 @@
# syntax=docker/dockerfile:1
FROM ghcr.io/astral-sh/uv:python3.13-bookworm-slim AS builder
WORKDIR /app
# Enable bytecode compilation for faster startup
ENV UV_COMPILE_BYTECODE=1 \
UV_LINK_MODE=copy
# Install dependencies into a venv
# Install only haiku.rag-slim (no docling extra - use docling-serve instead)
COPY pyproject.toml uv.lock ./
COPY haiku_rag_slim/pyproject.toml haiku_rag_slim/README.md haiku_rag_slim/LICENSE haiku_rag_slim/
RUN --mount=type=cache,target=/root/.cache/uv \
uv sync --frozen --no-install-project --no-dev --package haiku.rag-slim
# Install the project itself
COPY haiku_rag_slim haiku_rag_slim/
COPY README.md LICENSE ./
RUN --mount=type=cache,target=/root/.cache/uv \
uv sync --frozen --no-editable --no-dev --package haiku.rag-slim
# Final layer
FROM python:3.13-slim
WORKDIR /app
COPY --from=builder /app/.venv /app/.venv
COPY --from=builder /app /app
# Set default data directory
RUN mkdir -p /data
ENV DEFAULT_DATA_DIR=/data
ENV PATH="/app/.venv/bin:$PATH"
# Expose port for MCP server
EXPOSE 8001
# Run all services (monitoring, MCP)
CMD ["python", "-m", "haiku.rag.cli", "--config", "/app/haiku.rag.yaml", "serve", "--monitor", "--mcp", "--mcp-port", "8001", "--db", "/data/haiku.rag.lancedb"]

38
scripts/build-docker-images.sh Executable file
View file

@ -0,0 +1,38 @@
#!/bin/bash
set -e
# Extract version from pyproject.toml
VERSION=$(awk -F'"' '/^version =/ {print $2}' haiku_rag_slim/pyproject.toml)
if [ -z "$VERSION" ]; then
echo "Error: Could not extract version from haiku_rag_slim/pyproject.toml"
exit 1
fi
echo "Building Docker images for version: $VERSION"
echo ""
# Build slim image (haiku.rag-slim)
echo "Building slim image (haiku.rag-slim)..."
docker buildx build \
--platform linux/amd64,linux/arm64 \
--tag ghcr.io/ggozad/haiku.rag-slim:latest \
--tag ghcr.io/ggozad/haiku.rag-slim:$VERSION \
--file docker/Dockerfile.slim \
--push \
.
echo "✓ Slim image built and pushed"
echo ""
# Build full image (haiku.rag)
echo "Building full image (haiku.rag)..."
docker buildx build \
--platform linux/amd64,linux/arm64 \
--tag ghcr.io/ggozad/haiku.rag:latest \
--tag ghcr.io/ggozad/haiku.rag:$VERSION \
--file docker/Dockerfile \
--push \
.
echo "✓ Full image built and pushed"