Dockerfile 3.11 KB
Newer Older
Timothy J. Baek's avatar
Timothy J. Baek committed
1
2
# syntax=docker/dockerfile:1

3
FROM node:alpine as build
4

Timothy J. Baek's avatar
Timothy J. Baek committed
5
6
WORKDIR /app

Timothy J. Baek's avatar
Timothy J. Baek committed
7
# wget embedding model weight from alpine (does not exist from slim-buster)
Xiaodong Ye's avatar
Xiaodong Ye committed
8
9
RUN wget "https://chroma-onnx-models.s3.amazonaws.com/all-MiniLM-L6-v2/onnx.tar.gz" -O - | \
    tar -xzf - -C /app
Timothy J. Baek's avatar
Timothy J. Baek committed
10

Xiaodong Ye's avatar
Xiaodong Ye committed
11
COPY package.json package-lock.json ./
12
RUN npm ci
13

14
15
COPY . .
RUN npm run build
Timothy J. Baek's avatar
Timothy J. Baek committed
16

Timothy J. Baek's avatar
Timothy J. Baek committed
17

Timothy J. Baek's avatar
Timothy J. Baek committed
18
FROM python:3.11-slim-bookworm as base
Timothy J. Baek's avatar
Timothy J. Baek committed
19
20

ENV ENV=prod
21
ENV PORT ""
Timothy J. Baek's avatar
Timothy J. Baek committed
22

23
ENV OLLAMA_BASE_URL "/ollama"
Timothy J. Baek's avatar
Timothy J. Baek committed
24
25
26
27

ENV OPENAI_API_BASE_URL ""
ENV OPENAI_API_KEY ""

28
ENV WEBUI_SECRET_KEY ""
29
ENV WEBUI_AUTH_TRUSTED_EMAIL_HEADER ""
Timothy J. Baek's avatar
Timothy J. Baek committed
30

31
32
33
ENV SCARF_NO_ANALYTICS true
ENV DO_NOT_TRACK true

34
######## Preloaded models ########
35
# whisper TTS Settings
36
ENV WHISPER_MODEL="base"
Timothy J. Baek's avatar
refac  
Timothy J. Baek committed
37
ENV WHISPER_MODEL_DIR="/app/backend/data/cache/whisper/models"
38

39
# RAG Embedding Model Settings
40
41
# any sentence transformer model; models to use can be found at https://huggingface.co/models?library=sentence-transformers
# Leaderboard: https://huggingface.co/spaces/mteb/leaderboard 
42
# for better persormance and multilangauge support use "intfloat/multilingual-e5-large" (~2.5GB) or "intfloat/multilingual-e5-base" (~1.5GB)
43
# IMPORTANT: If you change the default model (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.
44
ENV RAG_EMBEDDING_MODEL="all-MiniLM-L6-v2"
pandego's avatar
pandego committed
45
# device type for whisper tts and embbeding models - "cpu" (default), "cuda" (nvidia gpu and CUDA required) or "mps" (apple silicon) - choosing this right can lead to better performance
46
ENV RAG_EMBEDDING_MODEL_DEVICE_TYPE="cpu"
Timothy J. Baek's avatar
refac  
Timothy J. Baek committed
47
48
49
ENV RAG_EMBEDDING_MODEL_DIR="/app/backend/data/cache/embedding/models"
ENV SENTENCE_TRANSFORMERS_HOME $RAG_EMBEDDING_MODEL_DIR

50
######## Preloaded models ########
51

Timothy J. Baek's avatar
Timothy J. Baek committed
52
53
WORKDIR /app/backend

54
# install python dependencies
Timothy J. Baek's avatar
Timothy J. Baek committed
55
COPY ./backend/requirements.txt ./requirements.txt
Timothy J. Baek's avatar
Timothy J. Baek committed
56

Timothy J. Baek's avatar
Timothy J. Baek committed
57
58
RUN apt-get update && apt-get install ffmpeg libsm6 libxext6  -y

Ismael's avatar
Ismael committed
59
60
RUN pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu --no-cache-dir
RUN pip3 install -r requirements.txt --no-cache-dir
61

TriantaTV's avatar
TriantaTV committed
62
# Install pandoc and netcat
Timothy J. Baek's avatar
Timothy J. Baek committed
63
64
# RUN python -c "import pypandoc; pypandoc.download_pandoc()"
RUN apt-get update \
TriantaTV's avatar
TriantaTV committed
65
    && apt-get install -y pandoc netcat-openbsd \
Timothy J. Baek's avatar
Timothy J. Baek committed
66
67
    && rm -rf /var/lib/apt/lists/*

68
# preload embedding model
69
RUN python -c "import os; from chromadb.utils import embedding_functions; sentence_transformer_ef = embedding_functions.SentenceTransformerEmbeddingFunction(model_name=os.environ['RAG_EMBEDDING_MODEL'], device=os.environ['RAG_EMBEDDING_MODEL_DEVICE_TYPE'])"
70
# preload tts model
71
RUN python -c "import os; from faster_whisper import WhisperModel; WhisperModel(os.environ['WHISPER_MODEL'], device='auto', compute_type='int8', download_root=os.environ['WHISPER_MODEL_DIR'])"
72

73
74
# copy embedding weight from build
RUN mkdir -p /root/.cache/chroma/onnx_models/all-MiniLM-L6-v2
Xiaodong Ye's avatar
Xiaodong Ye committed
75
COPY --from=build /app/onnx /root/.cache/chroma/onnx_models/all-MiniLM-L6-v2/onnx
76
77
78

# copy built frontend files
COPY --from=build /app/build /app/build
79
80
COPY --from=build /app/CHANGELOG.md /app/CHANGELOG.md
COPY --from=build /app/package.json /app/package.json
81
82

# copy backend files
Timothy J. Baek's avatar
Timothy J. Baek committed
83
84
COPY ./backend .

pandego's avatar
pandego committed
85
CMD [ "bash", "start.sh"]