From c64ab6a99fca102a1446554297b35e7207297499 Mon Sep 17 00:00:00 2001 From: scriptos Date: Wed, 27 Nov 2024 21:38:00 +0100 Subject: [PATCH] First tests with the Docker containers --- Dockerfile => Dockerfile.chatbot | 0 Dockerfile.ollama | 9 +++++++++ bin/ollamarama.py | 2 +- bin/requirements.txt | 5 +---- data/config.json | 2 +- docker-compose.yaml | 21 +++++++++++++++++++-- start.sh | 8 ++++++++ 7 files changed, 39 insertions(+), 8 deletions(-) rename Dockerfile => Dockerfile.chatbot (100%) create mode 100644 Dockerfile.ollama create mode 100644 start.sh diff --git a/Dockerfile b/Dockerfile.chatbot similarity index 100% rename from Dockerfile rename to Dockerfile.chatbot diff --git a/Dockerfile.ollama b/Dockerfile.ollama new file mode 100644 index 0000000..6d843fd --- /dev/null +++ b/Dockerfile.ollama @@ -0,0 +1,9 @@ +FROM ollama/ollama + +RUN ollama pull llama3.1:8b-instruct-q5_K_M + +COPY start.sh /start.sh +RUN chmod +x /start.sh + +# Standardbefehl zum Starten des Servers +CMD ["/start.sh"] \ No newline at end of file diff --git a/bin/ollamarama.py b/bin/ollamarama.py index 9f85fc0..2332ef5 100644 --- a/bin/ollamarama.py +++ b/bin/ollamarama.py @@ -215,4 +215,4 @@ class ollamarama: if __name__ == "__main__": ollamarama = ollamarama() - asyncio.run(ollamarama.main()) + asyncio.run(ollamarama.main()) \ No newline at end of file diff --git a/bin/requirements.txt b/bin/requirements.txt index c9b83b0..2d7b956 100644 --- a/bin/requirements.txt +++ b/bin/requirements.txt @@ -1,6 +1,3 @@ matrix-nio requests -markdown -asyncio -datetime -json \ No newline at end of file +markdown \ No newline at end of file diff --git a/data/config.json b/data/config.json index aa900b0..47d5764 100644 --- a/data/config.json +++ b/data/config.json @@ -19,7 +19,7 @@ }, "ollama": { - "api_base": "http://localhost:11434", + "api_base": "http://ollama:11434", "options": { "temperature": 0.8, diff --git a/docker-compose.yaml b/docker-compose.yaml index 2040a66..d68bc18 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -1,16 +1,33 @@ services: + ollama: + hostname: ollama + container_name: ollama + build: + context: . + dockerfile: Dockerfile.ollama + image: ollama/ollama + container_name: ollama + ports: + - "11434:11434" + volumes: + - ./data/ollama/history:/root/.ollama + - ./data/ollama/models:/usr/share/ollama + restart: unless-stopped + matrix-chatbot: container_name: matrix-chatbot hostname: matrix-chatbot build: context: . - dockerfile: Dockerfile + dockerfile: Dockerfile.chatbot networks: dockernet: ipv4_address: 172.16.0.50 + depends_on: + - ollama volumes: - - ./data/config.json:/app/config.json:ro + - ./data/chatbot/config.json:/app/config.json:ro restart: unless-stopped networks: diff --git a/start.sh b/start.sh new file mode 100644 index 0000000..9423dae --- /dev/null +++ b/start.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +# Modelle installieren +ollama pull llama3.1:8b-instruct-q5_K_M +ollama pull llama3.2 + +# Server starten +ollama serve \ No newline at end of file