FROM python:3.11-slim # Environment variables for HF deployment ENV PYTHONUNBUFFERED=1 ENV PYTHONDONTWRITEBYTECODE=1 ENV SESSION_BACKEND=jwt ENV APP_ENV=production ENV PORT=7860 # Install system dependencies RUN apt-get update && apt-get install -y \ gcc \ g++ \ && rm -rf /var/lib/apt/lists/* # Set working directory WORKDIR /app # Copy requirements first for better caching COPY requirements.txt . # Install Python dependencies RUN pip install --no-cache-dir --upgrade pip RUN pip install --no-cache-dir -r requirements.txt # Copy application code COPY . . # Create non-root user RUN useradd -m -u 1000 user && \ chown -R user:user /app USER user # Expose port EXPOSE 7860 # Run the application CMD ["python", "app.py"]