deepFace-api / Dockerfile
Rhaegar0x00's picture
Update Dockerfile
7e163af verified
Raw
History Blame Contribute Delete
906 Bytes
# Sử dụng Python 3.9 (DeepFace chạy ổn định nhất trên bản này)
FROM python:3.9-slim-bullseye
# Cài đặt các thư viện hệ thống cần thiết cho OpenCV
RUN apt-get update && apt-get install -y \
libgl1-mesa-glx \
libglib2.0-0 \
&& rm -rf /var/lib/apt/lists/*
# Thiết lập thư mục làm việc
WORKDIR /app
# Copy và cài đặt thư viện Python
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
# Tạo thư mục cache cho DeepFace (để lưu model weights)
RUN mkdir -p /root/.deepface/weights
# Copy toàn bộ code vào
COPY . .
# Mở cổng 7860 (Cổng bắt buộc của Hugging Face)
EXPOSE 7860
# Chạy server bằng Gunicorn (Production grade) thay vì Flask run
# Thêm tham số --workers 2 và --threads 2
CMD ["gunicorn", "-b", "0.0.0.0:7860", "app:app", "--workers", "2", "--threads", "2", "--timeout", "120"]