# Dockerfile for Hugging Face Spaces (Backend) FROM python:3.11-slim WORKDIR /app # Install system dependencies for OpenCV RUN apt-get update && apt-get install -y \ libgl1 \ libglib2.0-0 \ && rm -rf /var/lib/apt/lists/* # OPTIMIZATION: Install CPU-only PyTorch first to avoid downloading CUDA (huge) RUN pip install --no-cache-dir torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu # Copy requirements and install dependencies COPY requirements.txt . RUN pip install --no-cache-dir -r requirements.txt # Copy application code COPY app ./app COPY static ./static # Create storage directories RUN mkdir -p photo/enrolled audio/enrolled temp_uploads static/uploads/reminders qdrant_storage # Create a non-root user (optional but good practice, though HF Spaces runs as 1000 usually) RUN useradd -m -u 1000 user # Fix permissions: Give user ownership of /app RUN chown -R user:user /app USER user ENV HOME=/home/user \ PATH=/home/user/.local/bin:$PATH WORKDIR /app # Expose port 7860 for Hugging Face Spaces EXPOSE 7860 # Run the application CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "7860"]