| # Dockerfile | |
| FROM python:3.10-slim | |
| # Build tools | |
| RUN apt-get update && apt-get install -y --no-install-recommends \ | |
| build-essential \ | |
| && rm -rf /var/lib/apt/lists/* | |
| WORKDIR /app | |
| # Upgrade pip toolchain and preinstall deps that unblock tf-models-official | |
| RUN pip install --no-cache-dir --upgrade pip setuptools wheel \ | |
| && pip install --no-cache-dir "Cython<3" "pyyaml<5.4.0,>=5.1" | |
| # Then install your requirements | |
| COPY requirements.txt /app/requirements.txt | |
| RUN pip install --no-cache-dir -r requirements.txt | |
| # App code | |
| COPY . /app | |
| ENV PORT=7860 PYTHONUNBUFFERED=1 | |
| EXPOSE 7860 | |
| # Gunicorn loads Flask app from run.py | |
| CMD ["sh", "-c", "exec gunicorn run:app --workers 2 --threads 8 --timeout 120 --bind 0.0.0.0:${PORT:-7860}"] |