Spaces:
Sleeping
Sleeping
| # Hugging Face Docker Spaces base image | |
| FROM python:3.10-slim | |
| # ------------------------------------------------- | |
| # System dependencies | |
| # ------------------------------------------------- | |
| RUN apt-get update && apt-get install -y \ | |
| git \ | |
| build-essential \ | |
| wget \ | |
| && rm -rf /var/lib/apt/lists/* | |
| # ------------------------------------------------- | |
| # Environment variables | |
| # ------------------------------------------------- | |
| ENV PYTHONDONTWRITEBYTECODE=1 | |
| ENV PYTHONUNBUFFERED=1 | |
| ENV TRANSFORMERS_CACHE=/data/.cache/huggingface | |
| ENV HF_HOME=/data/.cache/huggingface | |
| ENV NLTK_DATA=/data/nltk_data | |
| # ------------------------------------------------- | |
| # Create working directory | |
| # ------------------------------------------------- | |
| WORKDIR /app | |
| # ------------------------------------------------- | |
| # Install Python dependencies | |
| # ------------------------------------------------- | |
| COPY requirements.txt . | |
| RUN pip install --no-cache-dir -r requirements.txt | |
| # ------------------------------------------------- | |
| # Pre-download NLTK resources (avoid runtime downloads) | |
| # ------------------------------------------------- | |
| RUN python - <<EOF | |
| import nltk | |
| nltk.download("punkt", download_dir="/data/nltk_data") | |
| nltk.download("punkt_tab", download_dir="/data/nltk_data") | |
| EOF | |
| # ------------------------------------------------- | |
| # Copy application code | |
| # ------------------------------------------------- | |
| COPY app.py . | |
| COPY static ./static | |
| # ------------------------------------------------- | |
| # Expose HF-required port | |
| # ------------------------------------------------- | |
| EXPOSE 7860 | |
| # ------------------------------------------------- | |
| # Start FastAPI | |
| # ------------------------------------------------- | |
| CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"] | |