Spaces:
Sleeping
Sleeping
fix: updated Dockerfile with proper gated repo authentication
Browse files- Dockerfile +8 -4
Dockerfile
CHANGED
|
@@ -2,12 +2,16 @@ FROM python:3.12-slim
|
|
| 2 |
|
| 3 |
WORKDIR /app
|
| 4 |
|
| 5 |
-
# Layer 1: Install dependencies
|
| 6 |
COPY requirements.txt .
|
| 7 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 8 |
|
| 9 |
-
# Layer 2: Pre-cache AI Models (
|
| 10 |
-
RUN
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
from sentence_transformers import SentenceTransformer, CrossEncoder; \
|
| 12 |
SentenceTransformer('BAAI/bge-m3', cache_folder='/app/models'); \
|
| 13 |
CrossEncoder('BAAI/bge-reranker-base', cache_dir='/app/models'); \
|
|
@@ -16,7 +20,7 @@ AutoTokenizer.from_pretrained('ai4bharat/indictrans2-en-indic-dist-200M', trust_
|
|
| 16 |
AutoModelForSeq2SeqLM.from_pretrained('ai4bharat/indictrans2-en-indic-dist-200M', trust_remote_code=True, cache_dir='/app/models/indictrans2'); \
|
| 17 |
print('✓ All Embedding, Reranker, and IndicTrans2 models cached')"
|
| 18 |
|
| 19 |
-
# Layer 3: Copy application code
|
| 20 |
COPY . .
|
| 21 |
|
| 22 |
EXPOSE 7860
|
|
|
|
| 2 |
|
| 3 |
WORKDIR /app
|
| 4 |
|
| 5 |
+
# Layer 1: Install dependencies
|
| 6 |
COPY requirements.txt .
|
| 7 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 8 |
|
| 9 |
+
# Layer 2: Pre-cache AI Models (Authenticated for Gated Repos)
|
| 10 |
+
RUN --mount=type=secret,id=HF_TOKEN,mode=0444,required=true \
|
| 11 |
+
python -c "\
|
| 12 |
+
import os; \
|
| 13 |
+
from huggingface_hub import login; \
|
| 14 |
+
login(token=open('/run/secrets/HF_TOKEN').read().strip()); \
|
| 15 |
from sentence_transformers import SentenceTransformer, CrossEncoder; \
|
| 16 |
SentenceTransformer('BAAI/bge-m3', cache_folder='/app/models'); \
|
| 17 |
CrossEncoder('BAAI/bge-reranker-base', cache_dir='/app/models'); \
|
|
|
|
| 20 |
AutoModelForSeq2SeqLM.from_pretrained('ai4bharat/indictrans2-en-indic-dist-200M', trust_remote_code=True, cache_dir='/app/models/indictrans2'); \
|
| 21 |
print('✓ All Embedding, Reranker, and IndicTrans2 models cached')"
|
| 22 |
|
| 23 |
+
# Layer 3: Copy application code
|
| 24 |
COPY . .
|
| 25 |
|
| 26 |
EXPOSE 7860
|