Skip to content

Commit bfb02d9

Browse files
committed
+ docker setup
1 parent 77bfdf6 commit bfb02d9

File tree

5 files changed

+175
-0
lines changed

5 files changed

+175
-0
lines changed

.dockerignore

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# Git
2+
.git
3+
.gitignore
4+
5+
# Python
6+
__pycache__
7+
*.pyc
8+
*.pyo
9+
*.pyd
10+
.Python
11+
env
12+
pip-log.txt
13+
pip-delete-this-directory.txt
14+
15+
# Virtual environments
16+
venv/
17+
env/
18+
.venv/
19+
20+
# IDE
21+
.vscode/
22+
.idea/
23+
*.swp
24+
*.swo
25+
26+
# OS
27+
.DS_Store
28+
Thumbs.db
29+
30+
# Logs
31+
*.log
32+
33+
# Docker
34+
Dockerfile*
35+
docker-compose*
36+
37+
# Data (if you don't want to include data directory)
38+
data/
39+
40+
# Pytest
41+
.pytest_cache/
42+
.coverage
43+
htmlcov/

Dockerfile

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
FROM python:3.11-slim
2+
3+
# Set working directory
4+
WORKDIR /app
5+
6+
# Install system dependencies
7+
RUN apt-get update && apt-get install -y \
8+
gcc \
9+
g++ \
10+
&& rm -rf /var/lib/apt/lists/*
11+
12+
# Copy requirements first for better caching
13+
COPY requirements.txt .
14+
15+
# Install Python dependencies
16+
RUN pip install --no-cache-dir -r requirements.txt
17+
18+
# Copy application code
19+
COPY . .
20+
21+
# Expose Streamlit port
22+
EXPOSE 8501
23+
24+
# Set environment variables
25+
ENV STREAMLIT_SERVER_PORT=8501
26+
ENV STREAMLIT_SERVER_ADDRESS=0.0.0.0
27+
28+
# Run the application
29+
CMD ["streamlit", "run", "app.py", "--server.address=0.0.0.0", "--server.port=8501"]

README-Docker.md

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
# Docker Setup for Ragnarok PDF Chat
2+
3+
Simple Docker Compose setup for running the Ragnarok PDF Chat application with external Ollama.
4+
5+
## Prerequisites
6+
7+
- Docker & Docker Compose
8+
- Ollama installed locally
9+
10+
## Quick Start
11+
12+
### 1. Start Ollama with Docker-compatible configuration:
13+
```bash
14+
# Important: Ollama must accept connections from Docker containers
15+
OLLAMA_HOST=0.0.0.0:11434 ollama serve
16+
```
17+
18+
### 2. Build and run the application:
19+
```bash
20+
# Build and start the container
21+
docker-compose up -d --build
22+
23+
# View logs (optional)
24+
docker-compose logs -f app
25+
```
26+
27+
### 3. Access the application:
28+
- **URL:** http://localhost:8501
29+
- The app will automatically connect to your local Ollama instance
30+
- Upload a PDF and start chatting!
31+
32+
## Management Commands
33+
34+
```bash
35+
# Stop the application
36+
docker-compose down
37+
38+
# Restart with rebuild
39+
docker-compose down && docker-compose up -d --build
40+
41+
# View real-time logs
42+
docker-compose logs -f app
43+
44+
# Check container status
45+
docker-compose ps
46+
```
47+
48+
## Requirements
49+
50+
- **Ollama Models:** Download models before using: `ollama pull llama3.2`
51+
- **PDF Files:** The app processes PDF documents for Q&A
52+
- **Memory:** Container uses minimal resources (~500MB)
53+
54+
## Troubleshooting
55+
56+
**Connection Issues:**
57+
```bash
58+
# 1. Verify Ollama is accessible
59+
curl http://localhost:11434/api/version
60+
61+
# 2. Check Ollama is configured correctly
62+
# Must run with: OLLAMA_HOST=0.0.0.0:11434 ollama serve
63+
64+
# 3. Check app logs
65+
docker-compose logs app
66+
```
67+
68+
**Common Solutions:**
69+
- **"No models found"**: Start Ollama with `OLLAMA_HOST=0.0.0.0:11434`
70+
- **"Can't connect"**: Restart both Ollama and the container
71+
- **Port 8501 in use**: Change port in docker-compose.yml: `"8502:8501"`
72+
73+
## Notes
74+
75+
- **Data:** Chat history is stored in memory (lost on restart)
76+
- **Performance:** First model load may take 30+ seconds
77+
- **Compatibility:** Tested with Ollama 0.7.x and Docker Desktop

docker-compose.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
version: '3.8'
2+
3+
services:
4+
# Streamlit application
5+
app:
6+
build: .
7+
container_name: ragnarok-app
8+
ports:
9+
- "8501:8501"
10+
environment:
11+
# Configure Ollama connection (both env vars for compatibility)
12+
- OLLAMA_HOST=http://host.docker.internal:11434
13+
- OLLAMA_BASE_URL=http://host.docker.internal:11434
14+
restart: unless-stopped
15+
volumes:
16+
- ./data:/app/data # For persistent data storage
17+
extra_hosts:
18+
- "host.docker.internal:host-gateway"

docker.env.example

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Ollama Configuration
2+
# Set the base URL for your Ollama instance
3+
OLLAMA_BASE_URL=http://localhost:11434
4+
5+
# Examples for different setups:
6+
# Local Ollama on host: http://host.docker.internal:11434
7+
# Remote Ollama server: http://your-ollama-server:11434
8+
# Docker network Ollama: http://ollama-container:11434

0 commit comments

Comments
 (0)