web4355/road-damage-detection
1
1FROM python:3.11-slim2 3# Hugging Face requires the container to run as a non-root user with ID 10004RUN useradd -m -u 1000 user5 6WORKDIR /app7 8# Install system dependencies required by OpenCV and YOLO9RUN apt-get update && apt-get install -y \10 libgl1-mesa-glx \11 libglib2.0-0 \12 && rm -rf /var/lib/apt/lists/*13 14# Copy requirements15COPY --chown=user requirements.txt .16 17# Switch to the non-root user to install Python packages18USER user19ENV PATH="/home/user/.local/bin:$PATH"20 21# Install Python dependencies22RUN pip install --no-cache-dir -r requirements.txt23 24# Copy the rest of your app's code25COPY --chown=user . /app26 27# Initialize the database file28RUN python -c "from app import db, app; app.app_context().push(); db.create_all()"29 30# Hugging Face Spaces requires the app to run on port 786031ENV PORT=786032EXPOSE 786033 34# Start the Flask app using Gunicorn35CMD ["gunicorn", "-b", "0.0.0.0:7860", "--timeout", "120", "--workers", "1", "--threads", "2", "app:app"]36 