toxicity / Dockerfile
Võ Minh Trí
.
17ad64d
Raw
History Blame Contribute Delete
678 Bytes
FROM python:3.10-slim
WORKDIR /app
# Cài dependencies trước để tận dụng Docker layer cache
COPY requirements.txt .
RUN pip install --no-cache-dir --index-url https://download.pytorch.org/whl/cpu torch==2.3.1 \
&& pip install --no-cache-dir -r requirements.txt
# Copy code + meta-classifier đã train sẵn
COPY app.py .
COPY meta_classifier.joblib .
# HF Space mặc định expose port 7860
EXPOSE 7860
# Cache HF models trong container (tránh lỗi permission khi Space chạy non-root)
ENV HF_HOME=/app/.cache/huggingface
RUN mkdir -p /app/.cache/huggingface && chmod -R 777 /app/.cache
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]