| FROM python:3.10-slim | |
| ENV PYTHONUNBUFFERED=1 \ | |
| PIP_NO_CACHE_DIR=1 \ | |
| PORT=7860 \ | |
| HF_HOME=/root/.cache/huggingface | |
| # 1) Cài system deps: lib cho OpenCV + toolchain build C/C++ | |
| RUN apt-get update && apt-get install -y --no-install-recommends \ | |
| libgl1 \ | |
| libglib2.0-0 \ | |
| build-essential \ | |
| gcc \ | |
| g++ \ | |
| make \ | |
| pkg-config \ | |
| && rm -rf /var/lib/apt/lists/* | |
| WORKDIR /app | |
| # 2) Cài Python deps (nâng pip trước để tránh lỗi wheel) | |
| COPY requirements.txt . | |
| RUN python -m pip install --upgrade pip setuptools wheel \ | |
| && pip install -r requirements.txt | |
| # 3) Copy source | |
| COPY . . | |
| EXPOSE 7860 | |
| # 4) Chạy bằng gunicorn (app.py phải có biến flask_app) | |
| CMD ["gunicorn", "--bind", "0.0.0.0:7860", "app:flask_app"] |