Spaces:
Runtime error
Runtime error
Update Dockerfile
Browse files- Dockerfile +35 -13
Dockerfile
CHANGED
|
@@ -1,31 +1,53 @@
|
|
| 1 |
FROM python:3.10-slim
|
| 2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
RUN apt-get update && apt-get install -y --no-install-recommends \
|
| 4 |
-
|
| 5 |
-
g++ \
|
| 6 |
-
wget \
|
| 7 |
-
curl \
|
| 8 |
git \
|
| 9 |
-
|
|
|
|
|
|
|
| 10 |
&& rm -rf /var/lib/apt/lists/*
|
| 11 |
|
| 12 |
-
WORKDIR /app
|
| 13 |
|
| 14 |
COPY requirements.txt .
|
| 15 |
-
|
| 16 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 17 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
|
| 19 |
-
|
|
|
|
| 20 |
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
|
|
|
|
| 27 |
COPY . .
|
| 28 |
|
|
|
|
| 29 |
EXPOSE 7860
|
| 30 |
|
| 31 |
-
|
|
|
|
|
|
| 1 |
FROM python:3.10-slim
|
| 2 |
|
| 3 |
+
|
| 4 |
+
ENV DEBIAN_FRONTEND=noninteractive \
|
| 5 |
+
PYTHONUNBUFFERED=1 \
|
| 6 |
+
PYTHONDONTWRITEBYTECODE=1
|
| 7 |
+
|
| 8 |
+
|
| 9 |
+
WORKDIR /code
|
| 10 |
+
|
| 11 |
+
# System Dependencies
|
| 12 |
RUN apt-get update && apt-get install -y --no-install-recommends \
|
| 13 |
+
build-essential \
|
|
|
|
|
|
|
|
|
|
| 14 |
git \
|
| 15 |
+
curl \
|
| 16 |
+
libopenblas-dev \
|
| 17 |
+
libomp-dev \
|
| 18 |
&& rm -rf /var/lib/apt/lists/*
|
| 19 |
|
|
|
|
| 20 |
|
| 21 |
COPY requirements.txt .
|
|
|
|
| 22 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 23 |
|
| 24 |
+
# Hugging Face + model tools
|
| 25 |
+
RUN pip install --no-cache-dir huggingface-hub sentencepiece accelerate fasttext
|
| 26 |
+
|
| 27 |
+
# Hugging Face cache environment
|
| 28 |
+
ENV HF_HOME=/models/huggingface \
|
| 29 |
+
TRANSFORMERS_CACHE=/models/huggingface \
|
| 30 |
+
HUGGINGFACE_HUB_CACHE=/models/huggingface \
|
| 31 |
+
HF_HUB_CACHE=/models/huggingface
|
| 32 |
|
| 33 |
+
# Created cache dir and set permissions
|
| 34 |
+
RUN mkdir -p /models/huggingface && chmod -R 777 /models/huggingface
|
| 35 |
|
| 36 |
+
# Pre-download models at build time
|
| 37 |
+
RUN python -c "from huggingface_hub import snapshot_download; snapshot_download(repo_id='Remostart/Plutus_Tutor_model')" \
|
| 38 |
+
&& python -c "from huggingface_hub import snapshot_download; snapshot_download(repo_id='sentence-transformers/paraphrase-multilingual-MiniLM-L12-v2')" \
|
| 39 |
+
&& find /models/huggingface -name '*.lock' -delete
|
| 40 |
|
| 41 |
+
# Preload tokenizers (avoid runtime delays)
|
| 42 |
+
RUN python -c "from transformers import AutoTokenizer; AutoTokenizer.from_pretrained('Remostart/Plutus_Tutor_model', use_fast=True)" \
|
| 43 |
+
&& python -c "from transformers import AutoTokenizer; AutoTokenizer.from_pretrained('sentence-transformers/paraphrase-multilingual-MiniLM-L12-v2', use_fast=True)"
|
| 44 |
+
|
| 45 |
|
| 46 |
+
# Copy project files
|
| 47 |
COPY . .
|
| 48 |
|
| 49 |
+
# Expose FastAPI port
|
| 50 |
EXPOSE 7860
|
| 51 |
|
| 52 |
+
# Run FastAPI app with uvicorn (1 workers for concurrency)
|
| 53 |
+
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "7860", "--workers", "1"]
|