File size: 877 Bytes
245a4de | 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 | # Use an official Python runtime as a parent image
FROM python:3.9-slim
# Set the working directory in the container
WORKDIR /code
# Install system dependencies (required for OpenCV)
RUN apt-get update && apt-get install -y \
libgl1-mesa-glx \
libglib2.0-0 \
&& rm -rf /var/lib/apt/lists/*
# Copy requirements first to leverage Docker cache
COPY requirements.txt /code/requirements.txt
# Install PyTorch CPU-only (Detailed command significantly reduces size/memory usage)
RUN pip install --no-cache-dir torch torchvision --index-url https://download.pytorch.org/whl/cpu
# Install other python dependencies
RUN pip install --no-cache-dir --upgrade -r requirements.txt
# Copy the rest of the application
COPY . /code
# Expose the port
EXPOSE 7860
# Command to run the application
CMD ["gunicorn", "-b", "0.0.0.0:7860", "app:app"]
|