FaceRecognitionAPI / Dockerfile
MinaNasser's picture
7th
dba943a
FROM python:3.10-slim
WORKDIR /app
# Install system dependencies using correct package names for Debian Trixie
# libgl1-mesa-glx is replaced by libgl1 in Trixie
RUN apt-get update && apt-get install -y \
libgl1 \
libglib2.0-0 \
libsm6 \
libxext6 \
libxrender1 \
libgomp1 \
wget \
&& rm -rf /var/lib/apt/lists/*
# Set environment variables
ENV PYTHONUNBUFFERED=1 \
PYTHONDONTWRITEBYTECODE=1 \
APP_NAME=FaceRecognitionAPI \
APP_VERSION=1.0.0 \
APP_VARIANT=v1 \
HOST=0.0.0.0 \
PORT=7860 \
DETECTION_MODEL=mtcnn \
YOLOFACE_MODEL_PATH=assets/yolov11n-face.pt \
CHROMA_DB_PATH=./chroma_data \
COLLECTION_NAME=face_embeddings_collection \
SIMILARITY_THRESHOLD=0.7 \
MAX_RESULTS=1
# Copy requirements first for better caching
COPY requirements.txt .
# Install Python dependencies
RUN pip install --no-cache-dir --upgrade pip && \
pip install --no-cache-dir -r requirements.txt
# Copy the rest of the application
COPY . .
# Create necessary directories
RUN mkdir -p assets chroma_data static/crops
# Download YOLO model (with retry logic)
RUN wget -O assets/yolov11n-face.pt \
https://github.com/YapaLab/yolo-face/releases/download/1.0.0/yolov11n-face.pt \
|| echo "Model download failed, will download on first run"
# Expose port
EXPOSE 7860
# Run the application
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]