Spaces:
Build error
Build error
| FROM python:3.10-slim | |
| # Create user with ID 1000 (required for Hugging Face Spaces) | |
| RUN useradd -m -u 1000 user | |
| # Set environment variables | |
| ENV HOME=/home/user \ | |
| PATH=/home/user/.local/bin:$PATH \ | |
| PYTHONPATH=$HOME/app \ | |
| PYTHONUNBUFFERED=1 \ | |
| GRADIO_SERVER_NAME=0.0.0.0 | |
| # Install system dependencies for OpenCV and image processing | |
| RUN apt-get update && apt-get install -y \ | |
| libgl1-mesa-glx \ | |
| libglib2.0-0 \ | |
| libsm6 \ | |
| libxext6 \ | |
| libxrender-dev \ | |
| libgomp1 \ | |
| libgtk-3-0 \ | |
| libavcodec-dev \ | |
| libavformat-dev \ | |
| libswscale-dev \ | |
| curl \ | |
| && rm -rf /var/lib/apt/lists/* | |
| # Switch to user and set working directory | |
| USER user | |
| WORKDIR $HOME/app | |
| # Copy requirements first for better Docker layer caching | |
| COPY --chown=user ./requirements.txt requirements.txt | |
| # Install Python dependencies | |
| RUN pip install --no-cache-dir --upgrade pip && \ | |
| pip install --no-cache-dir --upgrade -r requirements.txt | |
| # Copy all application files | |
| COPY --chown=user . $HOME/app | |
| # Expose port 7860 (Hugging Face Spaces default) | |
| EXPOSE 7860 | |
| # Health check for the application | |
| HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \ | |
| CMD curl -f http://localhost:7860/ || exit 1 | |
| # Run the Gradio application | |
| CMD ["python", "app.py"] |