File size: 1,424 Bytes
bf52c74
12d0de7
 
 
dba943a
 
12d0de7
dba943a
12d0de7
 
 
bf52c74
12d0de7
 
 
 
01b9b7a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12d0de7
 
a597565
 
 
 
12d0de7
 
 
 
a597565
 
12d0de7
dba943a
a597565
 
 
12d0de7
a597565
12d0de7
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
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"]