# 1. Use a stable, lightweight Python image FROM python:3.11-slim # 2. Set the working directory WORKDIR /code # 3. Install only the essential libraries for image processing # These replace the old mesa-glx package that caused your error RUN apt-get update && apt-get install -y \ libgl1 \ libglib2.0-0 \ && rm -rf /var/lib/apt/lists/* # 4. Copy and install requirements (Cache optimized) COPY requirements.txt . RUN pip install --no-cache-dir -r requirements.txt # 5. Copy your app.py and any other files COPY . . # 6. Expose the standard port for Streamlit EXPOSE 7860 # 7. Run the app # Using 7860 as the port makes it compatible with Hugging Face Spaces # Start the app with security flags to prevent the 403 AxiosError CMD ["streamlit", "run", "app.py", \ "--server.port", "7860", \ "--server.address", "0.0.0.0", \ "--server.enableCORS", "false", \ "--server.enableXsrfProtection", "false"]