FROM python:3.11-slim # Create non-root user for security RUN useradd -m -u 1000 appuser WORKDIR /app # Copy requirements first for better caching COPY requirements.txt . # Install dependencies RUN pip install --no-cache-dir -r requirements.txt # Copy application files COPY . . # Change ownership to non-root user RUN chown -R appuser:appuser /app USER appuser # Expose port EXPOSE 7860 # Health check HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \ CMD curl -f http://localhost:7860/health || exit 1 # Run the application CMD ["python", "app.py"]