# Use an image with Python and build tools pre-installed | |
FROM python:3.10-slim | |
# Set environment variables | |
ENV DEBIAN_FRONTEND=noninteractive | |
# Install system dependencies for dlib and face_recognition | |
RUN apt-get update && \ | |
apt-get install -y \ | |
build-essential \ | |
cmake \ | |
gfortran \ | |
libopenblas-dev \ | |
liblapack-dev \ | |
libx11-dev \ | |
libgtk-3-dev \ | |
libboost-python-dev \ | |
libboost-thread-dev \ | |
libboost-system-dev \ | |
python3-dev \ | |
wget \ | |
&& rm -rf /var/lib/apt/lists/* | |
# Set working directory | |
WORKDIR /app | |
# Copy only requirements first to cache dependencies | |
COPY requirements.txt . | |
# Install Python dependencies (includes face_recognition and FastAPI) | |
RUN pip install --upgrade pip && pip install --no-cache-dir -r requirements.txt | |
# Copy the entire app | |
COPY . . | |
# Expose the app port | |
EXPOSE 7860 | |
# Run the FastAPI app using uvicorn | |
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"] | |