FROM python:3.10-slim 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 better caching COPY requirements.txt . RUN pip install --no-cache-dir -r requirements.txt # Copy application COPY app.py . # Create data directory RUN mkdir -p ./data # Expose port EXPOSE 7860 # Set environment variables ENV PORT=7860 ENV PYTHONUNBUFFERED=1 # Health check HEALTHCHECK --interval=30s --timeout=10s --start-period=40s --retries=3 \ CMD python -c "import requests; requests.get('http://localhost:7860/health')" || exit 1 # Run the application CMD ["python", "app.py"]