commit 4a8a51d3cc166c86fbd8faca75e813a310500d6b Author: ghost Date: Sun May 31 00:51:56 2026 +0200 Initial commit. diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..9fae90d --- /dev/null +++ b/.env.example @@ -0,0 +1,5 @@ +# --- MODEL SELECTION --- +MODEL_LIST=ministral-3:3b + +# --- NETZWORK --- +DNS_SERVER=8.8.8.8 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..87f466b --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +.env +storage/ +logs/ diff --git a/compose.amd.yaml b/compose.amd.yaml new file mode 100644 index 0000000..a6457c4 --- /dev/null +++ b/compose.amd.yaml @@ -0,0 +1,11 @@ +services: + ollama: + shm_size: '8gb' + devices: + - /dev/dri:/dev/dri + - /dev/kfd:/dev/kfd + environment: + # For AMD (Navi 31): 11.0.0 | For APUs: 10.3.0 + - HSA_OVERRIDE_GFX_VERSION=11.0.0 + #- OLLAMA_VULKAN=1 # only activate on problems with default (rocm) + - OLLAMA_FLASH_ATTENTION=1 diff --git a/compose.nvidia.yaml b/compose.nvidia.yaml new file mode 100644 index 0000000..d68fd7f --- /dev/null +++ b/compose.nvidia.yaml @@ -0,0 +1,12 @@ +services: + ollama: + shm_size: '8gb' + deploy: + resources: + reservations: + devices: + - driver: nvidia + count: 1 + capabilities: [gpu] + environment: + - NVIDIA_VISIBLE_DEVICES=all diff --git a/compose.yaml b/compose.yaml new file mode 100755 index 0000000..9018de3 --- /dev/null +++ b/compose.yaml @@ -0,0 +1,49 @@ +services: + # --- LLM ENGINE --- + ollama: + build: ./providers/llm/ollama + container_name: ollama + restart: always + volumes: + - ./storage/ollama_models:/root/.ollama + environment: + - MODEL_LIST=${MODEL_LIST:-ministral-3:3b} + ports: + - "11434:11434" # only required for external access + dns: + - ${DNS_SERVER:-1.1.1.1} + networks: + - net.ghost.openclaw + + # --- SEARCH ENGINE --- + #searxng: + # image: docker.io/searxng/searxng:latest + # container_name: searxng + # restart: always + # volumes: + # - ./providers/search/engine/settings.yml:/etc/searxng/settings.yml:ro + # networks: + # - net.ghost.openclaw + + # --- CORE AGENT --- + #agent: + # build: + # context: . + # dockerfile: core/agent/docker/Containerfile + # container_name: openclaw-agent + # depends_on: + # - ollama + # - searxng + # environment: + # - OLLAMA_HOST=http://ollama:11434 + # - SEARXNG_URL=http://searxng:8080 + # - MCP_SEARXNG_PATH=/app/mcp-bridge/dist/index.js + # volumes: + # - ./storage/workspace:/app/workspace:rw + # - ./storage/knowledge:/app/knowledge:ro + # networks: + # - net.ghost.openclaw + +networks: + net.ghost.openclaw: + driver: bridge diff --git a/providers/llm/ollama/Containerfile b/providers/llm/ollama/Containerfile new file mode 100755 index 0000000..9f1c082 --- /dev/null +++ b/providers/llm/ollama/Containerfile @@ -0,0 +1,4 @@ +FROM docker.io/ollama/ollama:latest +COPY entrypoint.sh /entrypoint.sh +RUN chmod +x /entrypoint.sh +ENTRYPOINT ["/entrypoint.sh"] diff --git a/providers/llm/ollama/entrypoint.sh b/providers/llm/ollama/entrypoint.sh new file mode 100755 index 0000000..2defd1c --- /dev/null +++ b/providers/llm/ollama/entrypoint.sh @@ -0,0 +1,59 @@ +#!/bin/bash + +# --- FUNKTION: Signal-Handling --- +# Diese Funktion wird aufgerufen, wenn der Container gestoppt werden soll (SIGTERM/SIGINT) +cleanup() { + echo "--- Abbruchsignal empfangen! Beende Ollama sauber... ---" + kill "$OLLAMA_PID" 2>/dev/null + wait "$OLLAMA_PID" 2>/dev/null + exit 0 +} + +# Registriere die Cleanup-Funktion für SIGTERM (Stop) und SIGINT (Strg+C) +trap cleanup SIGTERM SIGINT + +# --- SCHRITT 1: Ollama Server starten --- +echo "--- Starte Ollama Server im Hintergrund ---" +ollama serve & +OLLAMA_PID=$! + +# --- SCHRITT 2: Health-Check (Warten bis der Server bereit ist) --- +echo "--- Warte auf Ollama Server (TCP Check) ---" +MAX_RETRIES=30 +COUNT=0 +# Wir nutzen den Bash-eigenen TCP-Check (benötigt kein curl!) +until (exec 3<>/dev/tcp/localhost/11434) &>/dev/null || [ $COUNT -eq $MAX_RETRIES ]; do + sleep 2 + COUNT=$((COUNT + 1)) + echo "Warte auf Server... ($COUNT/$MAX_RETRIES)" +done + +# Schließe den Test-Socket sauber +exec 3>&- 2>/dev/null || true + +if [ $COUNT -eq $MAX_RETRIES ]; then + echo "FEHLER: Ollama Server ist nach 60 Sekunden nicht bereit." + exit 1 +fi + +echo "--- Ollama Server ist online! ---" + +# --- SCHRITT 3: Modelle herunterladen --- +if [ -z "$MODEL_LIST" ]; then + echo "WARNUNG: Keine Modelle in MODEL_LIST definiert." +else + IFS=',' read -ra MODELS <<< "$MODEL_LIST" + echo "--- Modell-Check gestartet ---" + + for model in "${MODELS[@]}"; do + model=$(echo "$model" | xargs) # Leerzeichen entfernen + echo "Prüfe Modell: $model" + # Pull ausführen. Wenn es schon da ist, geht das extrem schnell. + ollama pull "$model" + done + echo "--- Alle Modelle sind bereit ---" +fi + +# --- SCHRITT 4: Hauptprozess halten --- +# Wir warten auf den Ollama-Prozess. Wenn er stirbt, endet auch das Skript. +wait $OLLAMA_PID diff --git a/run.sh b/run.sh new file mode 100755 index 0000000..4836c00 --- /dev/null +++ b/run.sh @@ -0,0 +1,13 @@ +#!/bin/bash +# run.sh + +if [ "$1" == "amd" ]; then + podman-compose -f compose.yaml -f compose.amd.yaml up -d --build +elif [ "$1" == "nvidia" ]; then + podman-compose -f compose.yaml -f compose.nvidia.yaml up -d --build +elif [ "$1" == "cpu" ]; then + podman-compose up -d --build +else + echo "Please select Hardware: ./run.sh [amd|nvidia|cpu]" + podman-compose up -d --build +fi