version: '3.8' # Core API - OpenAPI-compatible functions and AI orchestration for Open WebUI # Purpose: Provides OpenAI-compatible API (/v1/chat/completions) and tool functions (web scraping) # Port: 8083 (HTTP API) # Network: ai-dataplane (shared with Open WebUI, Ollama, Qdrant) # # Setup: Create venv before first deployment: # cd /home/jpmschweitzer/Projects/portainer-core/services/core-api # python3 -m venv .venv # source .venv/bin/activate # pip install -r requirements.txt services: core-api: image: python:3.12 container_name: core-api restart: unless-stopped # Hot-reload development mode command: > sh -c " if [ ! -f /venv/bin/activate ]; then echo 'Creating venv and installing dependencies...' && python3 -m venv /venv && /venv/bin/pip install --upgrade pip && /venv/bin/pip install -r /app/requirements.txt; fi && /venv/bin/uvicorn src.main:app --host 0.0.0.0 --port 8083 --reload --reload-dir /app/src " ports: - "8083:8083" environment: # Application - APP_NAME=Core API - APP_VERSION=1.0.0-phase1 - DEBUG=true # Server - HOST=0.0.0.0 - PORT=8083 # Logging - LOG_LEVEL=INFO # Ollama Configuration (AI Orchestration) - OLLAMA_BASE_URL=http://ollama:11434 - OLLAMA_TIMEOUT=300 # Model Configuration - DEFAULT_MODEL=gemma:7b - LIGHTWEIGHT_MODELS=gemma:2b,gemma:7b - HEAVY_MODELS=mistral:7b,gemma2:9b,mixtral:8x7b - CODE_MODELS=codestral:latest,codegemma:latest # Model Aliases (OpenAI → Local) - ALIAS_GPT35=gemma:7b - ALIAS_GPT4=mistral:7b - ALIAS_GPT4_TURBO=mixtral:8x7b - ALIAS_GPT4_CODE=codestral:latest # Web Scraper settings - WEB_SCRAPER_REQUEST_TIMEOUT=30 - WEB_SCRAPER_MAX_REDIRECTS=5 - WEB_SCRAPER_USER_AGENT=Mozilla/5.0 (compatible; CoreAPI/1.0) - WEB_SCRAPER_DEFAULT_MAX_LENGTH=10000 - WEB_SCRAPER_MAX_LINKS_TO_EXTRACT=50 # Python path - PYTHONPATH=/app volumes: # Mount source code for live editing (not .venv - that's container-specific) - /home/jpmschweitzer/Projects/portainer-core/services/core-api:/app # Persist container's venv for fast restarts - /home/jpmschweitzer/docker-data/core-api/venv:/venv # Persist logs - /home/jpmschweitzer/docker-data/core-api/logs:/app/logs networks: - ai-dataplane labels: - "com.centurylinklabs.watchtower.enable=true" healthcheck: test: ["CMD", "curl", "-f", "http://localhost:8083/health"] interval: 30s timeout: 10s retries: 3 start_period: 30s networks: ai-dataplane: external: true