# Step 1: Use an official lightweight Python runtime FROM python:3.11-slim # Install system utilities required for compilation (Chromadb / pydantic binaries) RUN apt-get update && apt-get install -y --no-install-recommends \ build-essential \ git \ && rm -rf /var/lib/apt/lists/* # Step 2: Set up Hugging Face's mandatory non-root user (UID 1000) RUN useradd -m -u 1000 user USER user ENV HOME=/home/user \ PATH=/home/user/.local/bin:$PATH WORKDIR $HOME/app # Step 3: Pull down CUDA-compiled PyTorch libraries for the Nvidia T4 GPU RUN pip install --no-cache-dir --upgrade pip && \ pip install --no-cache-dir torch --index-url https://download.pytorch.org/whl/cu121 # Step 4: Copy and install dependencies COPY --chown=user requirements.txt $HOME/app/requirements.txt RUN pip install --no-cache-dir -r requirements.txt # Step 5: Copy over your entire repository (including app folder and chroma_db) COPY --chown=user . $HOME/app # Step 6: Expose the mandatory Hugging Face proxy port EXPOSE 7860 # Step 7: Run main.py as a module from the root directory so imports don't break! CMD ["python", "-m", "app.main"]