FROM python:3.11-slim # Set working directory WORKDIR /app # Install system dependencies RUN apt-get update && apt-get install -y \ build-essential \ && rm -rf /var/lib/apt/lists/* # Copy requirements first for layer caching COPY requirements.txt . # Install Python dependencies RUN pip install --no-cache-dir -r requirements.txt # Copy application files COPY app.py . COPY static/ static/ COPY chroma_db/ chroma_db/ # Set environment variables ENV PORT=7860 ENV PYTHONUNBUFFERED=1 ENV TOKENIZERS_PARALLELISM=false # HuggingFace Spaces runs as non-root user (uid 1000) RUN useradd -m -u 1000 appuser && chown -R appuser:appuser /app USER 1000 # Expose port EXPOSE 7860 # Start the application CMD ["python", "app.py"]