# Use an official Python runtime as a parent image FROM python:3.11-slim # Set environment variables ENV PYTHONDONTWRITEBYTECODE=1 ENV PYTHONUNBUFFERED=1 ENV PYTHONPATH=/app # Set work directory WORKDIR /app # Install system dependencies required for FAISS, Pillow, and other ML libraries RUN apt-get update && apt-get install -y \ build-essential \ libgomp1 \ libgl1 \ libglib2.0-0 \ && rm -rf /var/lib/apt/lists/* # Copy requirements file first to leverage Docker cache COPY requirements.txt . # Install Python dependencies # We use --no-cache-dir to keep the image size small RUN pip install --no-cache-dir -r requirements.txt # Copy the entire backend directory into the container # Since docker builds from root context, we map backend/ -> /app/backend COPY backend/ ./backend/ # Create necessary data directories (so they exist for the app) RUN mkdir -p /app/data/uploaded_files /app/data/faiss_index /app/models # Expose the port Hugging Face expects (7860) EXPOSE 7860 # Command to run the application on port 7860 CMD ["uvicorn", "backend.main:app", "--host", "0.0.0.0", "--port", "7860"]