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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# syntax=docker/dockerfile:1
|
| 2 |
+
# Initialize device type args
|
| 3 |
+
# use build args in the docker build command with --build-arg="BUILDARG=true"
|
| 4 |
+
ARG USE_CUDA=false
|
| 5 |
+
ARG USE_OLLAMA=false
|
| 6 |
+
# Tested with cu117 for CUDA 11 and cu121 for CUDA 12 (default)
|
| 7 |
+
ARG USE_CUDA_VER=cu128
|
| 8 |
+
# any sentence transformer model; models to use can be found at https://huggingface.co/models?library=sentence-transformers
|
| 9 |
+
# Leaderboard: https://huggingface.co/spaces/mteb/leaderboard
|
| 10 |
+
# for better performance and multilangauge support use "intfloat/multilingual-e5-large" (~2.5GB) or "intfloat/multilingual-e5-base" (~1.5GB)
|
| 11 |
+
# IMPORTANT: If you change the embedding model (sentence-transformers/all-MiniLM-L6-v2) and vice versa, you aren't able to use RAG Chat with your previous documents loaded in the WebUI! You need to re-embed them.
|
| 12 |
+
ARG USE_EMBEDDING_MODEL=sentence-transformers/all-MiniLM-L6-v2
|
| 13 |
+
ARG USE_RERANKING_MODEL=""
|
| 14 |
+
|
| 15 |
+
# Tiktoken encoding name; models to use can be found at https://huggingface.co/models?library=tiktoken
|
| 16 |
+
ARG USE_TIKTOKEN_ENCODING_NAME="cl100k_base"
|
| 17 |
+
|
| 18 |
+
ARG BUILD_HASH=dev-build
|
| 19 |
+
# Override at your own risk - non-root configurations are untested
|
| 20 |
+
ARG UID=0
|
| 21 |
+
ARG GID=0
|
| 22 |
+
|
| 23 |
+
######## WebUI frontend ########
|
| 24 |
+
FROM --platform=$BUILDPLATFORM node:22-alpine3.20 AS build
|
| 25 |
+
ARG BUILD_HASH
|
| 26 |
+
|
| 27 |
+
WORKDIR /app
|
| 28 |
+
|
| 29 |
+
# to store git revision in build
|
| 30 |
+
RUN apk add --no-cache git
|
| 31 |
+
|
| 32 |
+
COPY package.json package-lock.json ./
|
| 33 |
+
RUN npm ci --force
|
| 34 |
+
|
| 35 |
+
COPY . .
|
| 36 |
+
ENV APP_BUILD_HASH=${BUILD_HASH}
|
| 37 |
+
RUN npm run build
|
| 38 |
+
|
| 39 |
+
######## WebUI backend ########
|
| 40 |
+
FROM python:3.11-slim-bookworm AS base
|
| 41 |
+
|
| 42 |
+
# Use args
|
| 43 |
+
ARG USE_CUDA
|
| 44 |
+
ARG USE_OLLAMA
|
| 45 |
+
ARG USE_CUDA_VER
|
| 46 |
+
ARG USE_EMBEDDING_MODEL
|
| 47 |
+
ARG USE_RERANKING_MODEL
|
| 48 |
+
ARG UID
|
| 49 |
+
ARG GID
|
| 50 |
+
|
| 51 |
+
## Basis ##
|
| 52 |
+
ENV ENV=prod \
|
| 53 |
+
PORT=8080 \
|
| 54 |
+
# pass build args to the build
|
| 55 |
+
USE_OLLAMA_DOCKER=${USE_OLLAMA} \
|
| 56 |
+
USE_CUDA_DOCKER=${USE_CUDA} \
|
| 57 |
+
USE_CUDA_DOCKER_VER=${USE_CUDA_VER} \
|
| 58 |
+
USE_EMBEDDING_MODEL_DOCKER=${USE_EMBEDDING_MODEL} \
|
| 59 |
+
USE_RERANKING_MODEL_DOCKER=${USE_RERANKING_MODEL}
|
| 60 |
+
|
| 61 |
+
## Basis URL Config ##
|
| 62 |
+
ENV OLLAMA_BASE_URL="/ollama" \
|
| 63 |
+
OPENAI_API_BASE_URL=""
|
| 64 |
+
|
| 65 |
+
## API Key and Security Config ##
|
| 66 |
+
ENV OPENAI_API_KEY="" \
|
| 67 |
+
WEBUI_SECRET_KEY="" \
|
| 68 |
+
SCARF_NO_ANALYTICS=true \
|
| 69 |
+
DO_NOT_TRACK=true \
|
| 70 |
+
ANONYMIZED_TELEMETRY=false
|
| 71 |
+
|
| 72 |
+
#### Other models #########################################################
|
| 73 |
+
## whisper TTS model settings ##
|
| 74 |
+
ENV WHISPER_MODEL="base" \
|
| 75 |
+
WHISPER_MODEL_DIR="/app/backend/data/cache/whisper/models"
|
| 76 |
+
|
| 77 |
+
## RAG Embedding model settings ##
|
| 78 |
+
ENV RAG_EMBEDDING_MODEL="$USE_EMBEDDING_MODEL_DOCKER" \
|
| 79 |
+
RAG_RERANKING_MODEL="$USE_RERANKING_MODEL_DOCKER" \
|
| 80 |
+
SENTENCE_TRANSFORMERS_HOME="/app/backend/data/cache/embedding/models"
|
| 81 |
+
|
| 82 |
+
## Tiktoken model settings ##
|
| 83 |
+
ENV TIKTOKEN_ENCODING_NAME="cl100k_base" \
|
| 84 |
+
TIKTOKEN_CACHE_DIR="/app/backend/data/cache/tiktoken"
|
| 85 |
+
|
| 86 |
+
## Hugging Face download cache ##
|
| 87 |
+
ENV HF_HOME="/app/backend/data/cache/embedding/models"
|
| 88 |
+
|
| 89 |
+
## Torch Extensions ##
|
| 90 |
+
# ENV TORCH_EXTENSIONS_DIR="/.cache/torch_extensions"
|
| 91 |
+
|
| 92 |
+
#### Other models ##########################################################
|
| 93 |
+
|
| 94 |
+
WORKDIR /app/backend
|
| 95 |
+
|
| 96 |
+
ENV HOME=/root
|
| 97 |
+
# Create user and group if not root
|
| 98 |
+
RUN if [ $UID -ne 0 ]; then \
|
| 99 |
+
if [ $GID -ne 0 ]; then \
|
| 100 |
+
addgroup --gid $GID app; \
|
| 101 |
+
fi; \
|
| 102 |
+
adduser --uid $UID --gid $GID --home $HOME --disabled-password --no-create-home app; \
|
| 103 |
+
fi
|
| 104 |
+
|
| 105 |
+
RUN mkdir -p $HOME/.cache/chroma
|
| 106 |
+
RUN echo -n 00000000-0000-0000-0000-000000000000 > $HOME/.cache/chroma/telemetry_user_id
|
| 107 |
+
|
| 108 |
+
# Make sure the user has access to the app and root directory
|
| 109 |
+
RUN chown -R $UID:$GID /app $HOME
|
| 110 |
+
|
| 111 |
+
RUN if [ "$USE_OLLAMA" = "true" ]; then \
|
| 112 |
+
apt-get update && \
|
| 113 |
+
# Install pandoc and netcat
|
| 114 |
+
apt-get install -y --no-install-recommends git build-essential pandoc netcat-openbsd curl && \
|
| 115 |
+
apt-get install -y --no-install-recommends gcc python3-dev && \
|
| 116 |
+
# for RAG OCR
|
| 117 |
+
apt-get install -y --no-install-recommends ffmpeg libsm6 libxext6 && \
|
| 118 |
+
# install helper tools
|
| 119 |
+
apt-get install -y --no-install-recommends curl jq && \
|
| 120 |
+
# install ollama
|
| 121 |
+
curl -fsSL https://ollama.com/install.sh | sh && \
|
| 122 |
+
# cleanup
|
| 123 |
+
rm -rf /var/lib/apt/lists/*; \
|
| 124 |
+
else \
|
| 125 |
+
apt-get update && \
|
| 126 |
+
# Install pandoc, netcat and gcc
|
| 127 |
+
apt-get install -y --no-install-recommends git build-essential pandoc gcc netcat-openbsd curl jq && \
|
| 128 |
+
apt-get install -y --no-install-recommends gcc python3-dev && \
|
| 129 |
+
# for RAG OCR
|
| 130 |
+
apt-get install -y --no-install-recommends ffmpeg libsm6 libxext6 && \
|
| 131 |
+
# cleanup
|
| 132 |
+
rm -rf /var/lib/apt/lists/*; \
|
| 133 |
+
fi
|
| 134 |
+
|
| 135 |
+
# install python dependencies
|
| 136 |
+
COPY --chown=$UID:$GID ./backend/requirements.txt ./requirements.txt
|
| 137 |
+
|
| 138 |
+
RUN pip3 install --no-cache-dir uv && \
|
| 139 |
+
if [ "$USE_CUDA" = "true" ]; then \
|
| 140 |
+
# If you use CUDA the whisper and embedding model will be downloaded on first use
|
| 141 |
+
pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/$USE_CUDA_DOCKER_VER --no-cache-dir && \
|
| 142 |
+
uv pip install --system -r requirements.txt --no-cache-dir && \
|
| 143 |
+
python -c "import os; from sentence_transformers import SentenceTransformer; SentenceTransformer(os.environ['RAG_EMBEDDING_MODEL'], device='cpu')" && \
|
| 144 |
+
python -c "import os; from faster_whisper import WhisperModel; WhisperModel(os.environ['WHISPER_MODEL'], device='cpu', compute_type='int8', download_root=os.environ['WHISPER_MODEL_DIR'])"; \
|
| 145 |
+
python -c "import os; import tiktoken; tiktoken.get_encoding(os.environ['TIKTOKEN_ENCODING_NAME'])"; \
|
| 146 |
+
else \
|
| 147 |
+
pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu --no-cache-dir && \
|
| 148 |
+
uv pip install --system -r requirements.txt --no-cache-dir && \
|
| 149 |
+
python -c "import os; from sentence_transformers import SentenceTransformer; SentenceTransformer(os.environ['RAG_EMBEDDING_MODEL'], device='cpu')" && \
|
| 150 |
+
python -c "import os; from faster_whisper import WhisperModel; WhisperModel(os.environ['WHISPER_MODEL'], device='cpu', compute_type='int8', download_root=os.environ['WHISPER_MODEL_DIR'])"; \
|
| 151 |
+
python -c "import os; import tiktoken; tiktoken.get_encoding(os.environ['TIKTOKEN_ENCODING_NAME'])"; \
|
| 152 |
+
fi; \
|
| 153 |
+
chown -R $UID:$GID /app/backend/data/
|
| 154 |
+
|
| 155 |
+
|
| 156 |
+
|
| 157 |
+
# copy embedding weight from build
|
| 158 |
+
# RUN mkdir -p /root/.cache/chroma/onnx_models/all-MiniLM-L6-v2
|
| 159 |
+
# COPY --from=build /app/onnx /root/.cache/chroma/onnx_models/all-MiniLM-L6-v2/onnx
|
| 160 |
+
|
| 161 |
+
# copy built frontend files
|
| 162 |
+
COPY --chown=$UID:$GID --from=build /app/build /app/build
|
| 163 |
+
COPY --chown=$UID:$GID --from=build /app/CHANGELOG.md /app/CHANGELOG.md
|
| 164 |
+
COPY --chown=$UID:$GID --from=build /app/package.json /app/package.json
|
| 165 |
+
|
| 166 |
+
# copy backend files
|
| 167 |
+
COPY --chown=$UID:$GID ./backend .
|
| 168 |
+
|
| 169 |
+
EXPOSE 8080
|
| 170 |
+
|
| 171 |
+
HEALTHCHECK CMD curl --silent --fail http://localhost:${PORT:-8080}/health | jq -ne 'input.status == true' || exit 1
|
| 172 |
+
|
| 173 |
+
USER $UID:$GID
|
| 174 |
+
|
| 175 |
+
ARG BUILD_HASH
|
| 176 |
+
ENV WEBUI_BUILD_VERSION=${BUILD_HASH}
|
| 177 |
+
ENV DOCKER=true
|
| 178 |
+
|
| 179 |
+
CMD [ "bash", "start.sh"]
|