Files
portainer-core/stacks/core-api.yml
T

117 lines
3.0 KiB
YAML

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: docker-dataplane (shared infrastructure network)
#
# 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
# Production mode with workers
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
--workers 1
"
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
# Uptime Kuma Configuration
- KUMA_URL=http://uptime-kuma:3001
- KUMA_USERNAME=${KUMA_USERNAME}
- KUMA_PASSWORD=${KUMA_PASSWORD}
# 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:
- docker-dataplane
deploy:
resources:
limits:
cpus: '2.0'
memory: 2G
reservations:
memory: 512M
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:
docker-dataplane:
external: true
name: docker-dataplane