FROM python:3.10-slim # Set environment variables ENV PYTHONUNBUFFERED=1 \ PYTHONDONTWRITEBYTECODE=1 \ PORT=7860 \ HOME=/home/user # Install system dependencies RUN apt-get update && apt-get install -y --no-install-recommends \ build-essential \ && rm -rf /var/lib/apt/lists/* # Create a non-root user with UID 1000 RUN useradd -m -u 1000 user # Set up working directory inside home for proper permissions WORKDIR $HOME/app # Copy requirements first to leverage Docker cache COPY requirements.txt $HOME/app/ # Install dependencies RUN pip install --no-cache-dir -r requirements.txt # Copy application files (including main.py, saved_hybrid_model, deberta_model) COPY --chown=user:user . $HOME/app # Expose port 7860 (HuggingFace default) EXPOSE 7860 # Command to run uvicorn CMD ["python", "main.py"]