# Use a base Python image FROM python:3.9-slim # Set the working directory WORKDIR /app # Copy requirements first to leverage Docker caching COPY requirements.txt requirements.txt # Install system dependencies needed by OpenCV and potentially others RUN apt-get update && apt-get install -y --no-install-recommends \ libgl1-mesa-glx \ libglib2.0-0 \ # Add any other system libs if needed during build && rm -rf /var/lib/apt/lists/* # Install Python dependencies # Use --no-cache-dir to reduce image size RUN pip install --no-cache-dir -r requirements.txt # Copy the rest of the application code COPY . . # Expose the port Flask runs on (default is 5000) EXPOSE 5000 # Command to run the application # Use gunicorn for a more robust server than Flask's default debug server # Install gunicorn first RUN pip install --no-cache-dir gunicorn CMD ["gunicorn", "--bind", "0.0.0.0:5000", "app:app"]