| FROM python:3.9-slim | |
| WORKDIR /app | |
| COPY requirements.txt . | |
| RUN pip install --no-cache-dir -r requirements.txt | |
| COPY . . | |
| EXPOSE 7860 | |
| # --- START: FINAL OPTIMIZED COMMAND FOR ~10 CONCURRENT USERS ON FREE TIER --- | |
| # This configuration uses only 1 worker to minimize RAM usage. | |
| # It assigns 10 threads to that single worker, allowing it to handle | |
| # approximately 10 concurrent requests while staying within the 512MB RAM limit. | |
| # This is the most efficient setup for a high-concurrency goal on a low-memory plan. | |
| CMD ["gunicorn", "--workers", "8", "--worker-class", "gthread", "--threads", "10", "--bind", "0.0.0.0:7860", "--timeout", "720", "app:app"] | |
| # --- END: FINAL OPTIMIZED COMMAND --- | |