| |
| FROM python:3.10-slim |
|
|
| |
| WORKDIR /app |
|
|
| |
| RUN apt-get update && apt-get install -y \ |
| gcc \ |
| g++ \ |
| make \ |
| libffi-dev \ |
| libssl-dev \ |
| curl \ |
| && rm -rf /var/lib/apt/lists/* |
|
|
| |
| RUN mkdir -p /tmp/transformers_cache /tmp/hf_cache && \ |
| chmod 777 /tmp/transformers_cache /tmp/hf_cache |
|
|
| |
| ENV TRANSFORMERS_CACHE=/tmp/transformers_cache |
| ENV HF_HOME=/tmp/hf_cache |
| ENV TRANSFORMERS_OFFLINE=0 |
| ENV HF_DATASETS_OFFLINE=0 |
|
|
| |
| COPY requirements.txt . |
|
|
| |
| RUN pip install --no-cache-dir -r requirements.txt |
|
|
| |
| RUN mkdir -p /app/models /app/temp |
|
|
| |
| COPY app.py . |
|
|
| |
| ENV PYTHONUNBUFFERED=1 |
| ENV FLASK_APP=app.py |
| ENV FLASK_ENV=production |
| ENV PORT=7860 |
|
|
| |
| EXPOSE 7860 |
|
|
| |
| HEALTHCHECK --interval=30s --timeout=30s --start-period=120s --retries=3 \ |
| CMD curl -f http://localhost:7860/health || exit 1 |
|
|
| |
| CMD ["gunicorn", "--bind", "0.0.0.0:7860", "--workers", "1", "--timeout", "300", "--worker-class", "sync", "--preload", "app:app"] |