| |
| FROM python:3.10-slim-bullseye |
|
|
|
|
| ENV DEBIAN_FRONTEND=noninteractive \ |
| PYTHONUNBUFFERED=1 \ |
| PYTHONDONTWRITEBYTECODE=1 |
|
|
|
|
| WORKDIR /code |
|
|
| |
| RUN apt-get update && apt-get install -y --no-install-recommends \ |
| build-essential \ |
| git \ |
| curl \ |
| libopenblas-dev \ |
| libomp-dev \ |
| && rm -rf /var/lib/apt/lists/* |
|
|
|
|
| |
| COPY requirements.txt . |
| RUN pip install --no-cache-dir -r requirements.txt |
|
|
| |
| RUN pip install --no-cache-dir slowapi cachetools |
|
|
| |
| RUN pip install --no-cache-dir huggingface-hub sentencepiece accelerate fasttext |
|
|
| |
| ENV HF_HOME=/models/huggingface \ |
| TRANSFORMERS_CACHE=/models/huggingface \ |
| HUGGINGFACE_HUB_CACHE=/models/huggingface \ |
| HF_HUB_CACHE=/models/huggingface |
|
|
| |
| RUN mkdir -p /models/huggingface /logs && chmod -R 777 /models/huggingface /logs |
|
|
| |
| |
| |
|
|
| |
| COPY . . |
|
|
| |
| RUN mkdir -p /code/logs && chmod -R 777 /code/logs |
|
|
| |
| EXPOSE 7860 |
|
|
| |
| HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \ |
| CMD python -c "import requests; requests.get('http://localhost:7860/health', timeout=5).raise_for_status()" || exit 1 |
|
|
| |
| |
| ENV OMP_NUM_THREADS=4 \ |
| MKL_NUM_THREADS=4 \ |
| NUMEXPR_NUM_THREADS=4 \ |
| PYTHONPATH=/code |
|
|
| CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "7860", "--workers", "1", "--timeout-keep-alive", "30", "--log-level", "info"] |