# 1. Base image with Python 3.10 FROM python:3.10-slim # Container environment settings ENV PYTHONDONTWRITEBYTECODE=1 \ PYTHONUNBUFFERED=1 \ PORT=7860 \ HF_HOME=/tmp/huggingface \ TRANSFORMERS_CACHE=/tmp/huggingface WORKDIR /app # Install minimal OS build dependencies RUN apt-get update && apt-get install -y --no-install-recommends \ build-essential \ curl \ && rm -rf /var/lib/apt/lists/* # Install python dependencies COPY requirements.txt . RUN pip install --no-cache-dir -r requirements.txt # Create non-root user (Hugging Face Spaces runs as UID 1000) RUN useradd -m -u 1000 user # Copy application files COPY backend ./backend COPY frontend ./frontend COPY start.sh . # Create data directories and grant permissions to UID 1000 RUN mkdir -p /data /app/data/chroma_db /app/data/uploads /tmp/huggingface && \ chmod +x /app/start.sh && \ chown -R 1000:1000 /data /app /tmp/huggingface USER 1000 # Hugging Face Spaces listens on port 7860 EXPOSE 7860 CMD ["/app/start.sh"]