Spaces:
Runtime error
Runtime error
| # Dockerfile for Phishing URL Detection FastAPI Application | |
| # Base image: Python 3.10 slim for smaller image size | |
| FROM python:3.10-slim | |
| # Set environment variables | |
| ENV PYTHONUNBUFFERED=1 \ | |
| PYTHONDONTWRITEBYTECODE=1 \ | |
| PIP_NO_CACHE_DIR=1 \ | |
| PIP_DISABLE_PIP_VERSION_CHECK=1 | |
| # Install system dependencies required for ML libraries and Playwright | |
| RUN apt-get update && apt-get install -y --no-install-recommends \ | |
| libgomp1 \ | |
| wget \ | |
| # Playwright/Chromium dependencies | |
| libnss3 \ | |
| libnspr4 \ | |
| libatk1.0-0 \ | |
| libatk-bridge2.0-0 \ | |
| libcups2 \ | |
| libdrm2 \ | |
| libdbus-1-3 \ | |
| libxkbcommon0 \ | |
| libxcomposite1 \ | |
| libxdamage1 \ | |
| libxfixes3 \ | |
| libxrandr2 \ | |
| libgbm1 \ | |
| libpango-1.0-0 \ | |
| libcairo2 \ | |
| libasound2 \ | |
| libatspi2.0-0 \ | |
| libxshmfence1 \ | |
| && rm -rf /var/lib/apt/lists/* | |
| # Create non-root user for security | |
| RUN useradd -m -u 1000 user && \ | |
| mkdir -p /app && \ | |
| chown -R user:user /app | |
| # Set working directory | |
| WORKDIR /app | |
| # Copy requirements first for better caching | |
| COPY --chown=user:user requirements.txt . | |
| # Switch to non-root user | |
| USER user | |
| # Add user's local bin to PATH | |
| ENV PATH="/home/user/.local/bin:$PATH" | |
| # Install Python dependencies | |
| RUN pip install --user --no-cache-dir --upgrade pip && \ | |
| pip install --user --no-cache-dir -r requirements.txt | |
| # Install Playwright browsers (as user) | |
| # System dependencies are already installed above, so we just need the browser binaries | |
| RUN python -m playwright install chromium | |
| # Copy application code and model | |
| COPY --chown=user:user . . | |
| # Expose ports (7860 is default, 8000 for compatibility) | |
| EXPOSE 7860 8000 | |
| # Health check (uses port 7860 by default) | |
| HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \ | |
| CMD python -c "import requests; requests.get('http://localhost:7860/health')" || exit 1 | |
| # Run the application | |
| # Use app.py for HuggingFace Spaces compatibility, defaults to port 7860 | |
| CMD ["python", "app.py"] |