diff --git a/packages/llm/ollama/Dockerfile.open-webui b/packages/llm/ollama/Dockerfile.open-webui index bcf89d0c8..4397cda3d 100644 --- a/packages/llm/ollama/Dockerfile.open-webui +++ b/packages/llm/ollama/Dockerfile.open-webui @@ -5,5 +5,11 @@ ARG BASE_IMAGE FROM ${BASE_IMAGE} -CMD /start_ollama && \ - docker run -it --rm --network=host --add-host=host.docker.internal:host-gateway ghcr.io/open-webui/open-webui:main \ No newline at end of file +COPY start_ollama_openwebui / + +# ENTRYPOINT /start_ollama && \ +# /start_open_webui && \ +# /stop_open_webui_upon_exit & \ +# /bin/bash + +ENTRYPOINT ["/start_ollama_openwebui"] \ No newline at end of file diff --git a/packages/llm/ollama/config.py b/packages/llm/ollama/config.py index 07b6efeb9..a8a64243f 100644 --- a/packages/llm/ollama/config.py +++ b/packages/llm/ollama/config.py @@ -14,7 +14,7 @@ open_webui['name'] = 'ollama:open-webui' open_webui['dockerfile'] = 'Dockerfile.open-webui' -open_webui['depends'] = ['ollama:main'] +open_webui['depends'] = ['ollama:main', 'docker'] del open_webui['alias'] diff --git a/packages/llm/ollama/start_ollama_openwebui b/packages/llm/ollama/start_ollama_openwebui new file mode 100755 index 000000000..9c4c17921 --- /dev/null +++ b/packages/llm/ollama/start_ollama_openwebui @@ -0,0 +1,43 @@ +#!/usr/bin/env bash +: "${OLLAMA_LOGS:=/data/logs/ollama.log}" +: "${OPEN_WEBUI_PORT:=8080}" +: "${OPEN_WEBUI_LOGS:=/data/logs/openw-webui.log}" + + +stop_container_openwebui() { + echo ">>> docker stop open-webui " + docker stop open-webui + exit +} + +trap "stop_container_openwebui; echo '[start] SIGTERM received'; exit" TERM + +### Ollama server + +printf "\n >>>>>>> Starting ollama server\n\n" + +/bin/bash -c "/bin/ollama serve &> $OLLAMA_LOGS" & + +timeout 5 tail -f $OLLAMA_LOGS + +printf "\nOLLAMA_MODELS ${OLLAMA_MODELS}\n" +printf "OLLAMA_LOGS ${OLLAMA_LOGS}\n" + +printf "\nollama server is now started, and you can run commands here like 'ollama run llama3'\n\n" + +### Open WebUI + +server_url="http://$(hostname -I | cut -d' ' -f1):${OPEN_WEBUI_PORT}" + +printf "\n >>>>>>> Starting Open WebUI\n\n" + +echo "/bin/bash -c \"docker run --rm --network=host -e OLLAMA_BASE_URL=http://127.0.0.1:11434 -e DOCS_DIR=/data/documents -v /home/jetson/jetson-containers_tokknv/data/documents/:/data/documents/ --name open-webui ghcr.io/open-webui/open-webui:dev &> $OPEN_WEBUI_LOGS\" &" +/bin/bash -c "docker run --rm --network=host -e OLLAMA_BASE_URL=http://127.0.0.1:11434 -e DOCS_DIR=/data/documents -v /home/jetson/jetson-containers_tokknv/data/documents/:/data/documents/ --name open-webui ghcr.io/open-webui/open-webui:dev &> $OPEN_WEBUI_LOGS" & + +timeout 5 tail -f $OPEN_WEBUI_LOGS + +printf "\nOpen WebUI is now started\n\n" +printf "Open WebUI URL: $server_url \n" +printf "Open WebUI logs: ${OPEN_WEBUI_LOGS}\n\n" + +/bin/bash; stop_container_openwebui \ No newline at end of file