CoolFace
Apppublic

iridescentX/openui

sourceHugging Faceupdated 2y agoView on Hugging Face
0likes
Dockerfile162 linesDownload Raw Back to root
1# syntax=docker/dockerfile:12# Initialize device type args3# use build args in the docker build commmand with --build-arg="BUILDARG=true"4ARG USE_CUDA=false5ARG USE_OLLAMA=false6# Tested with cu117 for CUDA 11 and cu121 for CUDA 12 (default)7ARG USE_CUDA_VER=cu1218# any sentence transformer model; models to use can be found at https://huggingface.co/models?library=sentence-transformers9# 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.12ARG USE_EMBEDDING_MODEL=sentence-transformers/all-MiniLM-L6-v213ARG USE_RERANKING_MODEL=""14ARG BUILD_HASH=dev-build15# Override at your own risk - non-root configurations are untested16ARG UID=017ARG GID=018 19######## WebUI frontend ########20FROM --platform=$BUILDPLATFORM node:21-alpine3.19 as build21ARG BUILD_HASH22 23WORKDIR /app24 25COPY package.json package-lock.json ./26RUN npm ci27 28COPY . .29ENV APP_BUILD_HASH=${BUILD_HASH}30RUN npm run build31 32######## WebUI backend ########33FROM python:3.11-slim-bookworm as base34 35# Use args36ARG USE_CUDA37ARG USE_OLLAMA38ARG USE_CUDA_VER39ARG USE_EMBEDDING_MODEL40ARG USE_RERANKING_MODEL41ARG UID42ARG GID43 44## Basis ##45ENV ENV=prod \46    PORT=8080 \47    # pass build args to the build48    USE_OLLAMA_DOCKER=${USE_OLLAMA} \49    USE_CUDA_DOCKER=${USE_CUDA} \50    USE_CUDA_DOCKER_VER=${USE_CUDA_VER} \51    USE_EMBEDDING_MODEL_DOCKER=${USE_EMBEDDING_MODEL} \52    USE_RERANKING_MODEL_DOCKER=${USE_RERANKING_MODEL}53 54## Basis URL Config ##55ENV OLLAMA_BASE_URL="/ollama" \56    OPENAI_API_BASE_URL=""57 58## API Key and Security Config ##59ENV OPENAI_API_KEY="" \60    WEBUI_SECRET_KEY="" \61    SCARF_NO_ANALYTICS=true \62    DO_NOT_TRACK=true \63    ANONYMIZED_TELEMETRY=false64 65#### Other models #########################################################66## whisper TTS model settings ##67ENV WHISPER_MODEL="base" \68    WHISPER_MODEL_DIR="/app/backend/data/cache/whisper/models"69 70## RAG Embedding model settings ##71ENV RAG_EMBEDDING_MODEL="$USE_EMBEDDING_MODEL_DOCKER" \72    RAG_RERANKING_MODEL="$USE_RERANKING_MODEL_DOCKER" \73    SENTENCE_TRANSFORMERS_HOME="/app/backend/data/cache/embedding/models"74 75## Hugging Face download cache ##76ENV HF_HOME="/app/backend/data/cache/embedding/models"77#### Other models ##########################################################78 79WORKDIR /app/backend80 81ENV HOME /root82# Create user and group if not root83RUN if [ $UID -ne 0 ]; then \84    if [ $GID -ne 0 ]; then \85    addgroup --gid $GID app; \86    fi; \87    adduser --uid $UID --gid $GID --home $HOME --disabled-password --no-create-home app; \88    fi89 90RUN mkdir -p $HOME/.cache/chroma91RUN echo -n 00000000-0000-0000-0000-000000000000 > $HOME/.cache/chroma/telemetry_user_id92 93# Make sure the user has access to the app and root directory94RUN chown -R $UID:$GID /app $HOME95 96RUN if [ "$USE_OLLAMA" = "true" ]; then \97    apt-get update && \98    # Install pandoc and netcat99    apt-get install -y --no-install-recommends pandoc netcat-openbsd curl && \100    apt-get install -y --no-install-recommends gcc python3-dev && \101    # for RAG OCR102    apt-get install -y --no-install-recommends ffmpeg libsm6 libxext6 && \103    # install helper tools104    apt-get install -y --no-install-recommends curl jq && \105    # install ollama106    curl -fsSL https://ollama.com/install.sh | sh && \107    # cleanup108    rm -rf /var/lib/apt/lists/*; \109    else \110    apt-get update && \111    # Install pandoc, netcat and gcc112    apt-get install -y --no-install-recommends pandoc gcc netcat-openbsd curl jq && \113    apt-get install -y --no-install-recommends gcc python3-dev && \114    # for RAG OCR115    apt-get install -y --no-install-recommends ffmpeg libsm6 libxext6 && \116    # cleanup117    rm -rf /var/lib/apt/lists/*; \118    fi119 120# install python dependencies121COPY --chown=$UID:$GID ./backend/requirements.txt ./requirements.txt122 123RUN pip3 install uv && \124    if [ "$USE_CUDA" = "true" ]; then \125    # If you use CUDA the whisper and embedding model will be downloaded on first use126    pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/$USE_CUDA_DOCKER_VER --no-cache-dir && \127    uv pip install --system -r requirements.txt --no-cache-dir && \128    python -c "import os; from sentence_transformers import SentenceTransformer; SentenceTransformer(os.environ['RAG_EMBEDDING_MODEL'], device='cpu')" && \129    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'])"; \130    else \131    pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu --no-cache-dir && \132    uv pip install --system -r requirements.txt --no-cache-dir && \133    python -c "import os; from sentence_transformers import SentenceTransformer; SentenceTransformer(os.environ['RAG_EMBEDDING_MODEL'], device='cpu')" && \134    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'])"; \135    fi; \136    chown -R $UID:$GID /app/backend/data/137 138 139 140# copy embedding weight from build141# RUN mkdir -p /root/.cache/chroma/onnx_models/all-MiniLM-L6-v2142# COPY --from=build /app/onnx /root/.cache/chroma/onnx_models/all-MiniLM-L6-v2/onnx143 144# copy built frontend files145COPY --chown=$UID:$GID --from=build /app/build /app/build146COPY --chown=$UID:$GID --from=build /app/CHANGELOG.md /app/CHANGELOG.md147COPY --chown=$UID:$GID --from=build /app/package.json /app/package.json148 149# copy backend files150COPY --chown=$UID:$GID ./backend .151 152EXPOSE 8080153 154HEALTHCHECK CMD curl --silent --fail http://localhost:8080/health | jq -e '.status == true' || exit 1155 156USER $UID:$GID157 158ARG BUILD_HASH159ENV WEBUI_BUILD_VERSION=${BUILD_HASH}160 161CMD [ "bash", "start.sh"]162