# Step 1: Use an official Python base image FROM python:3.9-slim # Step 2: Set environment variables to prevent Python from writing .pyc files and to ensure the app runs in the background ENV PYTHONDONTWRITEBYTECODE 1 ENV PYTHONUNBUFFERED 1 # Step 3: Disable torch hub cache and set the cache directory ENV TORCH_HOME=/.cache ENV TORCH_HUB_NO_CACHE=1 # Step 4: Install system dependencies RUN apt-get update && apt-get install -y \ gcc \ g++ \ make \ libgl1-mesa-glx \ libglib2.0-0 \ && rm -rf /var/lib/apt/lists/* # Step 5: Set the working directory inside the container WORKDIR /app # Step 6: Copy the requirements file into the container COPY requirements.txt /app/ # Step 7: Install the Python dependencies RUN pip install --no-cache-dir -r requirements.txt # Step 8: Copy the rest of the application files into the container COPY . / # Step 9: Expose the port that the Flask app will run on EXPOSE 5000 # Step 10: Set the entry point to start the Flask application CMD ["python", "app.py"]