Võ Minh Trí commited on
Commit ·
17ad64d
1
Parent(s): 9315343
- Dockerfile +15 -6
- requirements.txt +7 -5
Dockerfile
CHANGED
|
@@ -1,12 +1,21 @@
|
|
| 1 |
-
FROM python:3.
|
| 2 |
|
| 3 |
-
WORKDIR /
|
| 4 |
|
| 5 |
-
|
|
|
|
|
|
|
|
|
|
| 6 |
|
| 7 |
-
|
|
|
|
|
|
|
| 8 |
|
| 9 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
|
| 11 |
-
# Chạy uvicorn và bắt buộc mở cổng 7860
|
| 12 |
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
|
|
|
|
| 1 |
+
FROM python:3.10-slim
|
| 2 |
|
| 3 |
+
WORKDIR /app
|
| 4 |
|
| 5 |
+
# Cài dependencies trước để tận dụng Docker layer cache
|
| 6 |
+
COPY requirements.txt .
|
| 7 |
+
RUN pip install --no-cache-dir --index-url https://download.pytorch.org/whl/cpu torch==2.3.1 \
|
| 8 |
+
&& pip install --no-cache-dir -r requirements.txt
|
| 9 |
|
| 10 |
+
# Copy code + meta-classifier đã train sẵn
|
| 11 |
+
COPY app.py .
|
| 12 |
+
COPY meta_classifier.joblib .
|
| 13 |
|
| 14 |
+
# HF Space mặc định expose port 7860
|
| 15 |
+
EXPOSE 7860
|
| 16 |
+
|
| 17 |
+
# Cache HF models trong container (tránh lỗi permission khi Space chạy non-root)
|
| 18 |
+
ENV HF_HOME=/app/.cache/huggingface
|
| 19 |
+
RUN mkdir -p /app/.cache/huggingface && chmod -R 777 /app/.cache
|
| 20 |
|
|
|
|
| 21 |
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
|
requirements.txt
CHANGED
|
@@ -1,6 +1,8 @@
|
|
| 1 |
--extra-index-url https://download.pytorch.org/whl/cpu
|
| 2 |
-
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
|
|
|
|
|
|
|
|
| 1 |
--extra-index-url https://download.pytorch.org/whl/cpu
|
| 2 |
+
torch==2.3.1+cpu
|
| 3 |
+
transformers==4.42.3
|
| 4 |
+
fastapi==0.111.0
|
| 5 |
+
uvicorn==0.30.1
|
| 6 |
+
scikit-learn==1.5.0
|
| 7 |
+
joblib==1.4.2
|
| 8 |
+
pydantic==2.7.4
|