From 0345a80033accdc5ac211b5af99bd70ad84b5c37 Mon Sep 17 00:00:00 2001 From: "Timothy J. Baek" Date: Sun, 7 Jan 2024 20:21:32 -0800 Subject: [PATCH 1/6] feat: include embedding weight to image --- Dockerfile | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Dockerfile b/Dockerfile index 88cfc6b9..3019c2ea 100644 --- a/Dockerfile +++ b/Dockerfile @@ -28,6 +28,14 @@ WORKDIR /app/backend COPY ./backend/requirements.txt ./requirements.txt RUN pip3 install -r requirements.txt + +RUN MODEL_DIR="/root/.cache/chroma/onnx_models/all-MiniLM-L6-v2" &&\ + ARCHIVE_NAME="onnx.tar.gz" &&\ + mkdir -p $MODEL_DIR &&\ + cd $MODEL_DIR &&\ + wget -O $ARCHIVE_NAME "https://chroma-onnx-models.s3.amazonaws.com/all-MiniLM-L6-v2/$ARCHIVE_NAME" &&\ + tar -xzf $ARCHIVE_NAME + # RUN python -c "from sentence_transformers import SentenceTransformer; model = SentenceTransformer('all-MiniLM-L6-v2')" COPY ./backend . From 87326a31572ba6b5e5dd023cbbbcd996edc86029 Mon Sep 17 00:00:00 2001 From: "Timothy J. Baek" Date: Sun, 7 Jan 2024 20:50:09 -0800 Subject: [PATCH 2/6] fix: docker --- Dockerfile | 19 ++++++++++++------- run.sh | 2 +- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/Dockerfile b/Dockerfile index 3019c2ea..b70c8243 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,12 +4,16 @@ FROM node:alpine as build WORKDIR /app +# wget embedding model weight from alpine (does not exist from slim-buster) +RUN wget "https://chroma-onnx-models.s3.amazonaws.com/all-MiniLM-L6-v2/onnx.tar.gz" + COPY package.json package-lock.json ./ RUN npm ci COPY . . RUN npm run build + FROM python:3.11-slim-bookworm as base ENV ENV=prod @@ -22,6 +26,14 @@ ENV OPENAI_API_KEY "" ENV WEBUI_JWT_SECRET_KEY "SECRET_KEY" WORKDIR /app + +# copy embedding weight from build +COPY --from=build onnx.tar.gz /root/.cache/chroma/onnx_models/all-MiniLM-L6-v2 + +RUN cd /root/.cache/chroma/onnx_models/all-MiniLM-L6-v2 &&\ + tar -xzf onnx.tar.gz + +# copy built frontend files COPY --from=build /app/build /app/build WORKDIR /app/backend @@ -29,13 +41,6 @@ WORKDIR /app/backend COPY ./backend/requirements.txt ./requirements.txt RUN pip3 install -r requirements.txt -RUN MODEL_DIR="/root/.cache/chroma/onnx_models/all-MiniLM-L6-v2" &&\ - ARCHIVE_NAME="onnx.tar.gz" &&\ - mkdir -p $MODEL_DIR &&\ - cd $MODEL_DIR &&\ - wget -O $ARCHIVE_NAME "https://chroma-onnx-models.s3.amazonaws.com/all-MiniLM-L6-v2/$ARCHIVE_NAME" &&\ - tar -xzf $ARCHIVE_NAME - # RUN python -c "from sentence_transformers import SentenceTransformer; model = SentenceTransformer('all-MiniLM-L6-v2')" COPY ./backend . diff --git a/run.sh b/run.sh index 0ada65d1..6e2dc611 100644 --- a/run.sh +++ b/run.sh @@ -1,5 +1,5 @@ +docker build -t ollama-webui . docker stop ollama-webui || true docker rm ollama-webui || true -docker build -t ollama-webui . docker run -d -p 3000:8080 --add-host=host.docker.internal:host-gateway -v ollama-webui:/app/backend/data --name ollama-webui --restart always ollama-webui docker image prune -f \ No newline at end of file From fe587c87f77e22b573c951ae5b8c203a9f019f34 Mon Sep 17 00:00:00 2001 From: "Timothy J. Baek" Date: Sun, 7 Jan 2024 20:52:15 -0800 Subject: [PATCH 3/6] fix: docker --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index b70c8243..dd6ddab0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -28,7 +28,7 @@ ENV WEBUI_JWT_SECRET_KEY "SECRET_KEY" WORKDIR /app # copy embedding weight from build -COPY --from=build onnx.tar.gz /root/.cache/chroma/onnx_models/all-MiniLM-L6-v2 +COPY --from=build /app/onnx.tar.gz /root/.cache/chroma/onnx_models/all-MiniLM-L6-v2 RUN cd /root/.cache/chroma/onnx_models/all-MiniLM-L6-v2 &&\ tar -xzf onnx.tar.gz From 34b0802cac6003bc389bace80b2874d334988e39 Mon Sep 17 00:00:00 2001 From: "Timothy J. Baek" Date: Sun, 7 Jan 2024 20:55:32 -0800 Subject: [PATCH 4/6] fix: docker --- Dockerfile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Dockerfile b/Dockerfile index dd6ddab0..60b2cb25 100644 --- a/Dockerfile +++ b/Dockerfile @@ -28,6 +28,8 @@ ENV WEBUI_JWT_SECRET_KEY "SECRET_KEY" WORKDIR /app # copy embedding weight from build + +RUN mkdir -p /root/.cache/chroma/onnx_models/all-MiniLM-L6-v2 COPY --from=build /app/onnx.tar.gz /root/.cache/chroma/onnx_models/all-MiniLM-L6-v2 RUN cd /root/.cache/chroma/onnx_models/all-MiniLM-L6-v2 &&\ From 706a8d4f8df0bbfb3137ba3add424a6c87920fa0 Mon Sep 17 00:00:00 2001 From: "Timothy J. Baek" Date: Sun, 7 Jan 2024 21:14:20 -0800 Subject: [PATCH 5/6] fix --- Dockerfile | 1 - backend/requirements.txt | 9 ++++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index 60b2cb25..8e81b774 100644 --- a/Dockerfile +++ b/Dockerfile @@ -28,7 +28,6 @@ ENV WEBUI_JWT_SECRET_KEY "SECRET_KEY" WORKDIR /app # copy embedding weight from build - RUN mkdir -p /root/.cache/chroma/onnx_models/all-MiniLM-L6-v2 COPY --from=build /app/onnx.tar.gz /root/.cache/chroma/onnx_models/all-MiniLM-L6-v2 diff --git a/backend/requirements.txt b/backend/requirements.txt index 3d5bb396..e0c2f25a 100644 --- a/backend/requirements.txt +++ b/backend/requirements.txt @@ -16,9 +16,12 @@ aiohttp peewee bcrypt -torch --index-url https://download.pytorch.org/whl/cpu -torchvision --index-url https://download.pytorch.org/whl/cpu -torchaudio --index-url https://download.pytorch.org/whl/cpu +--index-url https://download.pytorch.org/whl/cpu +torch +--index-url https://download.pytorch.org/whl/cpu +torchvision +--index-url https://download.pytorch.org/whl/cpu +torchaudio langchain langchain-community From 02f364bfd9501834c70c834c9d551e8a617df656 Mon Sep 17 00:00:00 2001 From: "Timothy J. Baek" Date: Sun, 7 Jan 2024 21:22:37 -0800 Subject: [PATCH 6/6] fix: dockerfile --- Dockerfile | 2 ++ backend/requirements.txt | 7 ------- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/Dockerfile b/Dockerfile index 8e81b774..64a30753 100644 --- a/Dockerfile +++ b/Dockerfile @@ -40,6 +40,8 @@ COPY --from=build /app/build /app/build WORKDIR /app/backend COPY ./backend/requirements.txt ./requirements.txt + +RUN pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu RUN pip3 install -r requirements.txt # RUN python -c "from sentence_transformers import SentenceTransformer; model = SentenceTransformer('all-MiniLM-L6-v2')" diff --git a/backend/requirements.txt b/backend/requirements.txt index e0c2f25a..06af0efc 100644 --- a/backend/requirements.txt +++ b/backend/requirements.txt @@ -16,13 +16,6 @@ aiohttp peewee bcrypt ---index-url https://download.pytorch.org/whl/cpu -torch ---index-url https://download.pytorch.org/whl/cpu -torchvision ---index-url https://download.pytorch.org/whl/cpu -torchaudio - langchain langchain-community chromadb