MindSpace_ChatbotAI / Dockerfile
Asuranosuke's picture
Upload 3 files
c665e73 verified
Raw
History Blame Contribute Delete
980 Bytes
FROM python:3.11-slim
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1
# HuggingFace cache dir
ENV HF_HOME=/app/.cache
ENV TRANSFORMERS_CACHE=/app/.cache
RUN apt-get update && apt-get install -y \
build-essential \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app
COPY requirements.txt .
RUN pip install --upgrade pip && \
pip install --no-cache-dir -r requirements.txt
# Pre-download models at build time (tránh timeout lúc runtime)
RUN python -c "\
from transformers import pipeline; \
pipeline('text-classification', model='j-hartmann/emotion-english-distilroberta-base', top_k=None, device=-1); \
print('emotion model cached')"
RUN python -c "\
from sentence_transformers import SentenceTransformer; \
SentenceTransformer('all-MiniLM-L6-v2'); \
print('embedding model cached')"
# Chỉ copy app.py — không copy cả project
COPY app.py .
# HF Spaces bắt buộc port 7860
EXPOSE 7860
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]