File size: 1,197 Bytes
ac4990e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12eecc0
ac4990e
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# use a lightweight Python 3.11 image
FROM python:3.11-slim

# prevent Python from creating .pyc files
# stream logs immediately instead of buffering them
# set the default Gradio port
# disable parallel tokenizer warnings and extra thread usage
ENV PYTHONDONTWRITEBYTECODE=1 \
    PYTHONUNBUFFERED=1 \
    PORT=7860 \
    TOKENIZERS_PARALLELISM=false

# set the working directory inside the container
WORKDIR /app

# install Git for packages or Hugging Face resources that may require it
# remove package-manager files afterward to reduce image size
RUN apt-get update && \
    apt-get install -y --no-install-recommends git && \
    rm -rf /var/lib/apt/lists/*

# copy the dependency file first (so Docker can cache this layer)
COPY requirements.txt .

# install dependencies (without storing the pip download cache)
RUN pip install --no-cache-dir -r requirements.txt

# copy the application source code into the container
COPY . .

# create the local directory used to cache the dataset,
# embeddings, vectorizer, sparse matrix, and retrieval artifacts
RUN mkdir -p /app/.rag_cache

# port used by the Gradio application
EXPOSE 7860

# start HuggingFace RAG application
CMD ["python", "app.py"]