# 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"]