# Start from a lightweight Python 3.10 image FROM python:3.10-slim # Set the working directory inside the container WORKDIR /code # Set up the paddlex directories RUN mkdir /.paddlex RUN chmod -R 775 /.paddlex RUN mkdir /.paddlex/temp RUN chmod -R 775 /.paddlex/temp RUN mkdir /.paddlex/func_ret RUN chmod -R 775 /.paddlex/func_ret # Install ALL essential system dependencies for OpenCV & Paddle # libgl1: Fixes libGL.so.1 (OpenGL/GPU-related) # libglib2.0-0: Fixes libgthread-2.0.so.0 (GTK/GLib dependency) # libgomp1: Fixes libgomp.so.1 (GNU OpenMP/Multi-threading) # The other three ensure robust image handling. RUN apt-get update && apt-get install -y \ libgl1 \ libglib2.0-0 \ libgomp1 \ libsm6 \ libxext6 \ libxrender-dev \ && rm -rf /var/lib/apt/lists/* # Copy the requirements file *first* to leverage Docker cache COPY requirements.txt . # Install Python dependencies RUN pip install --no-cache-dir --upgrade -r requirements.txt # Copy the rest of your application code COPY . . # Expose the port your app will run on EXPOSE 7860 # Command to run your FastAPI app with uvicorn CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]