FROM python:3.10-slim WORKDIR /app # Install system dependencies including Node.js RUN apt-get update && apt-get install -y \ git \ libgl1 \ libglib2.0-0 \ libsm6 \ libxext6 \ libxrender-dev \ libgomp1 \ curl \ && curl -fsSL https://deb.nodesource.com/setup_18.x | bash - \ && apt-get install -y nodejs \ && rm -rf /var/lib/apt/lists/* # Copy requirements first for better caching COPY requirements.txt . # Install Python dependencies RUN pip install --no-cache-dir -r requirements.txt # Copy frontend files and build COPY frontend/package*.json frontend/ WORKDIR /app/frontend RUN npm install COPY frontend/ . RUN npm run build # Copy backend application files WORKDIR /app COPY config.py . COPY model_manager.py . COPY inference.py . COPY app.py . COPY utils/ utils/ # Expose Hugging Face Spaces default port EXPOSE 7860 # Health check HEALTHCHECK --interval=30s --timeout=10s --start-period=60s --retries=3 \ CMD python -c "import requests; requests.get('http://localhost:7860/health')" # Run the FastAPI application CMD ["python", "app.py"]