mirror of
https://github.com/zebrajr/localGPT.git
synced 2025-12-06 00:20:19 +01:00
Merge pull request #853 from PromtEngineer/devin/1737063744-docker-setup-fix
Fix Docker container SQLite database path issue (#849)
This commit is contained in:
commit
a3402f4274
|
|
@ -16,8 +16,8 @@ RUN pip install --no-cache-dir -r requirements.txt
|
|||
COPY backend/ ./backend/
|
||||
COPY rag_system/ ./rag_system/
|
||||
|
||||
# Create necessary directories
|
||||
RUN mkdir -p shared_uploads logs
|
||||
# Create necessary directories and initialize database
|
||||
RUN mkdir -p shared_uploads logs backend
|
||||
|
||||
# Expose port
|
||||
EXPOSE 8000
|
||||
|
|
@ -28,4 +28,4 @@ HEALTHCHECK --interval=30s --timeout=10s --start-period=30s --retries=3 \
|
|||
|
||||
# Run the backend server
|
||||
WORKDIR /app/backend
|
||||
CMD ["python", "server.py"]
|
||||
CMD ["python", "server.py"]
|
||||
|
|
@ -5,7 +5,7 @@ from datetime import datetime
|
|||
from typing import List, Dict, Optional, Tuple
|
||||
|
||||
class ChatDatabase:
|
||||
def __init__(self, db_path: str = "backend/chat_data.db"):
|
||||
def __init__(self, db_path: str = "/app/backend/chat_data.db"):
|
||||
self.db_path = db_path
|
||||
self.init_database()
|
||||
|
||||
|
|
@ -681,4 +681,4 @@ if __name__ == "__main__":
|
|||
stats = db.get_stats()
|
||||
print(f"📊 Stats: {stats}")
|
||||
|
||||
print("✅ Database test completed!")
|
||||
print("✅ Database test completed!")
|
||||
|
|
@ -1,9 +1,12 @@
|
|||
import requests
|
||||
import json
|
||||
from typing import List, Dict
|
||||
import os
|
||||
from typing import List, Dict, Optional
|
||||
|
||||
class OllamaClient:
|
||||
def __init__(self, base_url: str = "http://localhost:11434"):
|
||||
def __init__(self, base_url: Optional[str] = None):
|
||||
if base_url is None:
|
||||
base_url = os.getenv("OLLAMA_HOST", "http://localhost:11434")
|
||||
self.base_url = base_url
|
||||
self.api_url = f"{base_url}/api"
|
||||
|
||||
|
|
@ -196,4 +199,4 @@ def main():
|
|||
print(f"AI: {response}")
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
main()
|
||||
37
backend/test_ollama_connectivity.py
Normal file
37
backend/test_ollama_connectivity.py
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
import os
|
||||
import sys
|
||||
|
||||
def test_ollama_connectivity():
|
||||
"""Test Ollama connectivity from within Docker container"""
|
||||
print("🧪 Testing Ollama Connectivity")
|
||||
print("=" * 40)
|
||||
|
||||
ollama_host = os.getenv('OLLAMA_HOST', 'Not set')
|
||||
print(f"OLLAMA_HOST environment variable: {ollama_host}")
|
||||
|
||||
try:
|
||||
from ollama_client import OllamaClient
|
||||
client = OllamaClient()
|
||||
print(f"OllamaClient base_url: {client.base_url}")
|
||||
|
||||
is_running = client.is_ollama_running()
|
||||
print(f"Ollama running: {is_running}")
|
||||
|
||||
if is_running:
|
||||
models = client.list_models()
|
||||
print(f"Available models: {models}")
|
||||
print("✅ Ollama connectivity test passed!")
|
||||
return True
|
||||
else:
|
||||
print("❌ Ollama connectivity test failed!")
|
||||
return False
|
||||
|
||||
except Exception as e:
|
||||
print(f"❌ Error testing Ollama connectivity: {e}")
|
||||
return False
|
||||
|
||||
if __name__ == "__main__":
|
||||
success = test_ollama_connectivity()
|
||||
sys.exit(0 if success else 1)
|
||||
|
|
@ -56,8 +56,9 @@ services:
|
|||
environment:
|
||||
- NODE_ENV=production
|
||||
- RAG_API_URL=http://rag-api:8001
|
||||
- OLLAMA_HOST=${OLLAMA_HOST:-http://172.18.0.1:11434}
|
||||
volumes:
|
||||
- ./backend/chat_data.db:/app/backend/chat_data.db
|
||||
- ./backend:/app/backend
|
||||
- ./shared_uploads:/app/shared_uploads
|
||||
depends_on:
|
||||
rag-api:
|
||||
|
|
@ -100,4 +101,4 @@ volumes:
|
|||
|
||||
networks:
|
||||
rag-network:
|
||||
driver: bridge
|
||||
driver: bridge
|
||||
|
|
@ -1,6 +1,7 @@
|
|||
# Docker environment configuration
|
||||
# Set this to use local Ollama instance running on host
|
||||
OLLAMA_HOST=http://host.docker.internal:11434
|
||||
# Note: Using Docker gateway IP instead of host.docker.internal for Linux compatibility
|
||||
OLLAMA_HOST=http://172.18.0.1:11434
|
||||
|
||||
# Alternative: Use containerized Ollama (uncomment and run with --profile with-ollama)
|
||||
# OLLAMA_HOST=http://ollama:11434
|
||||
|
|
@ -8,4 +9,4 @@ OLLAMA_HOST=http://host.docker.internal:11434
|
|||
# Other configuration
|
||||
NODE_ENV=production
|
||||
NEXT_PUBLIC_API_URL=http://localhost:8000
|
||||
RAG_API_URL=http://rag-api:8001
|
||||
RAG_API_URL=http://rag-api:8001
|
||||
Loading…
Reference in New Issue
Block a user