diff --git a/Dockerfile b/Dockerfile index 88cfc6b9..64a30753 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,12 +26,24 @@ ENV OPENAI_API_KEY "" 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 &&\ + tar -xzf onnx.tar.gz + +# copy built frontend files 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')" COPY ./backend . diff --git a/backend/requirements.txt b/backend/requirements.txt index 3d5bb396..06af0efc 100644 --- a/backend/requirements.txt +++ b/backend/requirements.txt @@ -16,10 +16,6 @@ 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 - langchain langchain-community chromadb 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