Skip to content

Commit 05c0450

Browse files
feat(docker): aggiunge container all-in-one con Ollama, Qdrant, API REST e frontend SPA
Implementa immagine Docker completa con tutti i componenti integrati: Ollama con nomic-embed-text precaricato, Qdrant embedded, FastAPI per REST API e MCP SSE, frontend Alpine.js per drag-and-drop. Autenticazione GitHub OAuth opzionale con whitelist utenti in YAML. Include workflow GitHub Actions per build automatica multi-architettura e push su GHCR con variante Tika per PDF.
1 parent 6511b18 commit 05c0450

26 files changed

+3481
-7
lines changed

.env.example

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Ragify Environment Configuration
2+
# Copy this file to .env and fill in your values
3+
4+
# GitHub OAuth (required for authentication)
5+
# Create an OAuth App at: https://github.com/settings/developers
6+
# Set callback URL to: http://localhost:8080/auth/callback
7+
GITHUB_CLIENT_ID=your_github_client_id
8+
GITHUB_CLIENT_SECRET=your_github_client_secret
9+
10+
# Base URL (used for OAuth callbacks)
11+
# Change this if accessing from a different host/port
12+
BASE_URL=http://localhost:8080
13+
14+
# Ports (optional, defaults shown)
15+
API_PORT=8080
16+
MCP_PORT=6666
17+
18+
# Ollama model (optional, default: nomic-embed-text)
19+
OLLAMA_MODEL=nomic-embed-text
20+
21+
# Webhook URL for notifications (optional)
22+
# WEBHOOK_URL=https://your-webhook-endpoint.com/ragify

.github/workflows/release.yml

Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
name: Build and Release
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*' # Trigger on version tags (v1.0.0, v1.2.3, etc.)
7+
8+
env:
9+
REGISTRY: ghcr.io
10+
IMAGE_NAME: ${{ github.repository }}
11+
12+
jobs:
13+
build-and-push:
14+
runs-on: ubuntu-latest
15+
permissions:
16+
contents: write # For creating releases
17+
packages: write # For pushing to GHCR
18+
19+
strategy:
20+
matrix:
21+
include:
22+
- dockerfile: Dockerfile
23+
suffix: ""
24+
- dockerfile: Dockerfile.tika
25+
suffix: "-tika"
26+
27+
steps:
28+
- name: Checkout repository
29+
uses: actions/checkout@v4
30+
31+
- name: Set up QEMU
32+
uses: docker/setup-qemu-action@v3
33+
34+
- name: Set up Docker Buildx
35+
uses: docker/setup-buildx-action@v3
36+
37+
- name: Log in to GitHub Container Registry
38+
uses: docker/login-action@v3
39+
with:
40+
registry: ${{ env.REGISTRY }}
41+
username: ${{ github.actor }}
42+
password: ${{ secrets.GITHUB_TOKEN }}
43+
44+
- name: Extract version from tag
45+
id: version
46+
run: |
47+
VERSION=${GITHUB_REF#refs/tags/v}
48+
echo "version=$VERSION" >> $GITHUB_OUTPUT
49+
echo "Building version: $VERSION"
50+
51+
- name: Extract metadata for Docker
52+
id: meta
53+
uses: docker/metadata-action@v5
54+
with:
55+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
56+
tags: |
57+
type=semver,pattern={{version}},suffix=${{ matrix.suffix }}
58+
type=semver,pattern={{major}}.{{minor}},suffix=${{ matrix.suffix }}
59+
type=raw,value=latest,suffix=${{ matrix.suffix }},enable=${{ matrix.suffix == '' }}
60+
61+
- name: Build and push Docker image
62+
uses: docker/build-push-action@v5
63+
with:
64+
context: .
65+
file: ${{ matrix.dockerfile }}
66+
platforms: linux/amd64,linux/arm64
67+
push: true
68+
tags: ${{ steps.meta.outputs.tags }}
69+
labels: ${{ steps.meta.outputs.labels }}
70+
cache-from: type=gha
71+
cache-to: type=gha,mode=max
72+
73+
create-release:
74+
needs: build-and-push
75+
runs-on: ubuntu-latest
76+
permissions:
77+
contents: write
78+
79+
steps:
80+
- name: Checkout repository
81+
uses: actions/checkout@v4
82+
83+
- name: Extract version from tag
84+
id: version
85+
run: |
86+
VERSION=${GITHUB_REF#refs/tags/v}
87+
echo "version=$VERSION" >> $GITHUB_OUTPUT
88+
89+
- name: Create GitHub Release
90+
uses: softprops/action-gh-release@v1
91+
with:
92+
name: Ragify v${{ steps.version.outputs.version }}
93+
generate_release_notes: true
94+
body: |
95+
## Docker Images
96+
97+
Pull the image from GitHub Container Registry:
98+
99+
```bash
100+
# Standard image
101+
docker pull ghcr.io/${{ github.repository }}:${{ steps.version.outputs.version }}
102+
103+
# With Apache Tika (PDF/Office support)
104+
docker pull ghcr.io/${{ github.repository }}:${{ steps.version.outputs.version }}-tika
105+
```
106+
107+
## Quick Start
108+
109+
```bash
110+
# Run without authentication
111+
docker run -d -p 8080:8080 ghcr.io/${{ github.repository }}:latest
112+
113+
# Run with GitHub OAuth
114+
docker run -d -p 8080:8080 \
115+
-v ragify_data:/data \
116+
-v ./users.yaml:/config/users.yaml:ro \
117+
-e AUTH_CONFIG=/config/users.yaml \
118+
-e GITHUB_CLIENT_ID=your_client_id \
119+
-e GITHUB_CLIENT_SECRET=your_client_secret \
120+
ghcr.io/${{ github.repository }}:latest
121+
```
122+
123+
See [README](https://github.com/${{ github.repository }}#readme) for full documentation.
124+
env:
125+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,9 @@ all_docs_urls.txt
4040
html_urls.txt
4141
markdown_urls.txt
4242
.mcp.json
43+
44+
# Docker/Container
45+
.env
46+
users.yaml
47+
!docker/users.yaml.example
48+
!.env.example

Dockerfile

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
# Ragify All-in-One Container
2+
# Multi-stage build for Docker/Podman
3+
4+
# ============================================
5+
# Stage 1: Builder - Install Python dependencies
6+
# ============================================
7+
FROM python:3.12-slim AS builder
8+
9+
WORKDIR /build
10+
11+
# Install build dependencies
12+
RUN apt-get update && apt-get install -y --no-install-recommends \
13+
build-essential \
14+
&& rm -rf /var/lib/apt/lists/*
15+
16+
# Create virtual environment and install dependencies
17+
COPY requirements.txt .
18+
RUN python -m venv /opt/venv
19+
ENV PATH="/opt/venv/bin:$PATH"
20+
RUN pip install --no-cache-dir --upgrade pip && \
21+
pip install --no-cache-dir -r requirements.txt
22+
23+
# ============================================
24+
# Stage 2: Runtime - Final image
25+
# ============================================
26+
FROM python:3.12-slim
27+
28+
LABEL maintainer="Ragify"
29+
LABEL description="All-in-one RAG documentation search with Ollama, Qdrant, and MCP"
30+
LABEL version="1.0.0"
31+
32+
# Install runtime dependencies
33+
RUN apt-get update && apt-get install -y --no-install-recommends \
34+
tini \
35+
curl \
36+
ca-certificates \
37+
&& rm -rf /var/lib/apt/lists/*
38+
39+
# Install Ollama
40+
RUN curl -fsSL https://ollama.ai/install.sh | sh
41+
42+
# Install Qdrant (standalone binary)
43+
RUN curl -L https://github.com/qdrant/qdrant/releases/download/v1.12.4/qdrant-x86_64-unknown-linux-musl.tar.gz | \
44+
tar xz -C /usr/local/bin
45+
46+
# Copy virtual environment from builder
47+
COPY --from=builder /opt/venv /opt/venv
48+
ENV PATH="/opt/venv/bin:$PATH"
49+
50+
# Set working directory
51+
WORKDIR /app
52+
53+
# Copy application code
54+
COPY lib/ ./lib/
55+
COPY api/ ./api/
56+
COPY frontend/ ./frontend/
57+
COPY src/ ./src/
58+
COPY ragify.py .
59+
COPY mcp_server.py .
60+
COPY config.yaml .
61+
COPY docker/ ./docker/
62+
63+
# Make scripts executable
64+
RUN chmod +x /app/docker/*.sh
65+
66+
# Pre-pull default Ollama model (makes container larger but faster startup)
67+
# This runs ollama serve temporarily to pull the model
68+
RUN ollama serve & \
69+
sleep 5 && \
70+
ollama pull nomic-embed-text && \
71+
pkill ollama || true
72+
73+
# Create data directory for Qdrant
74+
RUN mkdir -p /data/qdrant
75+
76+
# Environment variables with defaults
77+
ENV PYTHONUNBUFFERED=1 \
78+
PYTHONDONTWRITEBYTECODE=1 \
79+
# API Configuration
80+
API_PORT=8080 \
81+
MCP_PORT=6666 \
82+
# Ollama (internal)
83+
OLLAMA_URL=http://localhost:11434 \
84+
OLLAMA_MODEL=nomic-embed-text \
85+
# Qdrant (internal)
86+
QDRANT_URL=http://localhost:6333 \
87+
QDRANT_PATH=/data/qdrant \
88+
# Auth (must be provided)
89+
AUTH_CONFIG="" \
90+
GITHUB_CLIENT_ID="" \
91+
GITHUB_CLIENT_SECRET="" \
92+
BASE_URL=http://localhost:8080
93+
94+
# Volumes
95+
VOLUME ["/data"]
96+
97+
# Expose ports
98+
EXPOSE 8080 6666
99+
100+
# Health check
101+
HEALTHCHECK --interval=30s --timeout=10s --start-period=60s --retries=3 \
102+
CMD /app/docker/healthcheck.sh
103+
104+
# Use tini as init
105+
ENTRYPOINT ["/usr/bin/tini", "--"]
106+
107+
# Run entrypoint script
108+
CMD ["/app/docker/entrypoint.sh"]

Dockerfile.tika

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
# Ragify All-in-One Container with Apache Tika
2+
# Includes Java for PDF/Office document extraction
3+
4+
# ============================================
5+
# Stage 1: Builder - Install Python dependencies
6+
# ============================================
7+
FROM python:3.12-slim AS builder
8+
9+
WORKDIR /build
10+
11+
# Install build dependencies
12+
RUN apt-get update && apt-get install -y --no-install-recommends \
13+
build-essential \
14+
&& rm -rf /var/lib/apt/lists/*
15+
16+
# Create virtual environment and install dependencies
17+
COPY requirements.txt .
18+
RUN python -m venv /opt/venv
19+
ENV PATH="/opt/venv/bin:$PATH"
20+
RUN pip install --no-cache-dir --upgrade pip && \
21+
pip install --no-cache-dir -r requirements.txt
22+
23+
# ============================================
24+
# Stage 2: Runtime - Final image with Java/Tika
25+
# ============================================
26+
FROM python:3.12-slim
27+
28+
LABEL maintainer="Ragify"
29+
LABEL description="All-in-one RAG documentation search with Ollama, Qdrant, MCP, and Apache Tika"
30+
LABEL version="1.0.0-tika"
31+
32+
# Install runtime dependencies including Java for Tika
33+
RUN apt-get update && apt-get install -y --no-install-recommends \
34+
tini \
35+
curl \
36+
ca-certificates \
37+
openjdk-17-jre-headless \
38+
&& rm -rf /var/lib/apt/lists/*
39+
40+
# Set Java environment
41+
ENV JAVA_HOME=/usr/lib/jvm/java-17-openjdk-amd64
42+
43+
# Install Ollama
44+
RUN curl -fsSL https://ollama.ai/install.sh | sh
45+
46+
# Install Qdrant (standalone binary)
47+
RUN curl -L https://github.com/qdrant/qdrant/releases/download/v1.12.4/qdrant-x86_64-unknown-linux-musl.tar.gz | \
48+
tar xz -C /usr/local/bin
49+
50+
# Copy virtual environment from builder
51+
COPY --from=builder /opt/venv /opt/venv
52+
ENV PATH="/opt/venv/bin:$PATH"
53+
54+
# Set working directory
55+
WORKDIR /app
56+
57+
# Copy application code
58+
COPY lib/ ./lib/
59+
COPY api/ ./api/
60+
COPY frontend/ ./frontend/
61+
COPY src/ ./src/
62+
COPY ragify.py .
63+
COPY mcp_server.py .
64+
COPY config.yaml .
65+
COPY docker/ ./docker/
66+
67+
# Make scripts executable
68+
RUN chmod +x /app/docker/*.sh
69+
70+
# Pre-pull default Ollama model
71+
RUN ollama serve & \
72+
sleep 5 && \
73+
ollama pull nomic-embed-text && \
74+
pkill ollama || true
75+
76+
# Create data directory for Qdrant
77+
RUN mkdir -p /data/qdrant
78+
79+
# Environment variables with defaults
80+
ENV PYTHONUNBUFFERED=1 \
81+
PYTHONDONTWRITEBYTECODE=1 \
82+
# API Configuration
83+
API_PORT=8080 \
84+
MCP_PORT=6666 \
85+
# Ollama (internal)
86+
OLLAMA_URL=http://localhost:11434 \
87+
OLLAMA_MODEL=nomic-embed-text \
88+
# Qdrant (internal)
89+
QDRANT_URL=http://localhost:6333 \
90+
QDRANT_PATH=/data/qdrant \
91+
# Auth (must be provided)
92+
AUTH_CONFIG="" \
93+
GITHUB_CLIENT_ID="" \
94+
GITHUB_CLIENT_SECRET="" \
95+
BASE_URL=http://localhost:8080 \
96+
# Tika
97+
TIKA_ENABLED=true
98+
99+
# Volumes
100+
VOLUME ["/data"]
101+
102+
# Expose ports
103+
EXPOSE 8080 6666
104+
105+
# Health check
106+
HEALTHCHECK --interval=30s --timeout=10s --start-period=60s --retries=3 \
107+
CMD /app/docker/healthcheck.sh
108+
109+
# Use tini as init
110+
ENTRYPOINT ["/usr/bin/tini", "--"]
111+
112+
# Run entrypoint script
113+
CMD ["/app/docker/entrypoint.sh"]

0 commit comments

Comments
 (0)