Skip to content

Commit

Permalink
Refactor Dockerfile for optimized build
Browse files Browse the repository at this point in the history
Simplified the Dockerfile in the backend component by streamlining Python and system dependencies installation. Upgraded to Python 3.11 and ensured only necessary packages are installed, reducing image size and potential security vulnerabilities. Unused package lists are removed to maintain a clean build environment.
  • Loading branch information
yousecjoe committed Mar 15, 2024
1 parent f9e8d34 commit 4d856d1
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -53,20 +53,16 @@ ENV SENTENCE_TRANSFORMERS_HOME $RAG_EMBEDDING_MODEL_DIR

WORKDIR /app/backend

# install python dependencies
# install python & dependencies
COPY ./backend/requirements.txt ./requirements.txt

RUN apt-get update && apt-get install ffmpeg libsm6 libxext6 -y
RUN apt-get update && \
apt-get install -y --no-install-recommends python3.11 ffmpeg libsm6 libxext6 pandoc netcat-openbsd && \
rm -rf /var/lib/apt/lists/*

RUN pip3 install torch torchvision torchaudio --no-cache-dir
RUN pip3 install -r requirements.txt --no-cache-dir

# Install pandoc and netcat
# RUN python -c "import pypandoc; pypandoc.download_pandoc()"
RUN apt-get update \
&& apt-get install -y pandoc netcat-openbsd \
&& rm -rf /var/lib/apt/lists/*

# preload embedding model
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'])"
# preload tts model
Expand Down

0 comments on commit 4d856d1

Please sign in to comment.