Spaces:
Sleeping
Sleeping
Commit ·
6f9d8f6
1
Parent(s): f8ff11b
Docker containerization with baked HuggingFace model cache
Browse files- .dockerignore +10 -0
- Dockerfile +29 -0
- docker-compose.yml +16 -0
- requirements.txt +15 -20
.dockerignore
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
venv/
|
| 2 |
+
__pycache__/
|
| 3 |
+
*.pyc
|
| 4 |
+
.env
|
| 5 |
+
qdrant_storage/
|
| 6 |
+
bm25_index.pkl
|
| 7 |
+
data/
|
| 8 |
+
chroma_db/
|
| 9 |
+
*.pkl
|
| 10 |
+
.git/
|
Dockerfile
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
FROM python:3.11-slim
|
| 2 |
+
|
| 3 |
+
WORKDIR /app
|
| 4 |
+
|
| 5 |
+
# Cài system deps cho underthesea + EasyOCR
|
| 6 |
+
RUN apt-get update && apt-get install -y \
|
| 7 |
+
gcc g++ git libgl1 libglib2.0-0 \
|
| 8 |
+
&& rm -rf /var/lib/apt/lists/*
|
| 9 |
+
|
| 10 |
+
# Cài Python deps trước (cache layer)
|
| 11 |
+
COPY requirements.txt .
|
| 12 |
+
RUN pip install --no-cache-dir --trusted-host pypi.org --trusted-host files.pythonhosted.org --timeout 300 -r requirements.txt
|
| 13 |
+
|
| 14 |
+
# Copy source code
|
| 15 |
+
COPY src/ ./src/
|
| 16 |
+
COPY static/ ./static/
|
| 17 |
+
COPY api.py .
|
| 18 |
+
|
| 19 |
+
# Copy HuggingFace model cache
|
| 20 |
+
COPY hf_models/ /root/.cache/huggingface/hub/
|
| 21 |
+
ENV TRANSFORMERS_OFFLINE=1
|
| 22 |
+
ENV HF_DATASETS_OFFLINE=1
|
| 23 |
+
|
| 24 |
+
# Qdrant storage và BM25 index mount từ volume
|
| 25 |
+
VOLUME ["/app/qdrant_storage", "/app/data"]
|
| 26 |
+
|
| 27 |
+
EXPOSE 8000
|
| 28 |
+
|
| 29 |
+
CMD ["uvicorn", "api:app", "--host", "0.0.0.0", "--port", "8000"]
|
docker-compose.yml
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
services:
|
| 2 |
+
app:
|
| 3 |
+
build: .
|
| 4 |
+
ports:
|
| 5 |
+
- "8000:8000"
|
| 6 |
+
volumes:
|
| 7 |
+
- ./qdrant_storage:/app/qdrant_storage
|
| 8 |
+
- ./bm25_index.pkl:/app/bm25_index.pkl
|
| 9 |
+
- ./data:/app/data
|
| 10 |
+
- hf_cache:/root/.cache/huggingface
|
| 11 |
+
env_file:
|
| 12 |
+
- .env
|
| 13 |
+
restart: unless-stopped
|
| 14 |
+
|
| 15 |
+
volumes:
|
| 16 |
+
hf_cache:
|
requirements.txt
CHANGED
|
@@ -1,20 +1,15 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
numpy>=1.26.0
|
| 17 |
-
|
| 18 |
-
# Utils
|
| 19 |
-
python-dotenv>=1.0.0
|
| 20 |
-
tqdm>=4.66.0
|
|
|
|
| 1 |
+
--extra-index-url https://download.pytorch.org/whl/cpu
|
| 2 |
+
torch==2.5.1+cpu
|
| 3 |
+
fastapi==0.136.3
|
| 4 |
+
uvicorn==0.49.0
|
| 5 |
+
python-dotenv==1.2.2
|
| 6 |
+
google-genai==2.8.0
|
| 7 |
+
groq==1.4.0
|
| 8 |
+
qdrant-client==1.18.0
|
| 9 |
+
rank-bm25==0.2.2
|
| 10 |
+
sentence-transformers==2.7.0
|
| 11 |
+
underthesea==9.5.0
|
| 12 |
+
pypdf==6.13.0
|
| 13 |
+
easyocr==1.7.2
|
| 14 |
+
tqdm==4.68.1
|
| 15 |
+
pydantic==2.13.4
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|