Spaces:
Sleeping
Sleeping
File size: 968 Bytes
f59cf24 7fea25f |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# β
Use official slim image
FROM python:3.10-slim
# β
Set working directory
WORKDIR /app
# β
Set environment variables early to ensure cache use in setup.py
ENV TRANSFORMERS_CACHE=/app/model_cache \
HF_HOME=/app/model_cache \
TORCH_HOME=/app/model_cache \
TOKENIZERS_PARALLELISM=false \
OMP_NUM_THREADS=4
# β
Install only necessary OS packages and clean cache
RUN apt-get update && apt-get install -y git \
&& rm -rf /var/lib/apt/lists/*
# β
Copy files (excluding model_cache, logs, etc. via .dockerignore)
COPY . .
# β
Upgrade pip + install deps without cache
RUN pip install --upgrade pip \
&& pip install --no-cache-dir -r requirements.txt
# β
Run setup.py to download the model
RUN python setup.py
# β
Expose Hugging Face Space-required port
EXPOSE 7860
# β
Launch FastAPI on port 7860 for HF Space
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860", "--timeout-keep-alive", "120", "--log-level", "info"]
|