Download Dockerfile from Text-to-Document-Generation/Docgenie-API: direct link, hf CLI and curl.
- Browser
- Download file 2.96 kB
-
https://huggingface.co/spaces/Text-to-Document-Generation/Docgenie-API/resolve/main/Dockerfile
- Command line
-
hf download hf://spaces/Text-to-Document-Generation/Docgenie-API/Dockerfile
-
curl -L -o Dockerfile https://huggingface.co/spaces/Text-to-Document-Generation/Docgenie-API/resolve/main/Dockerfile
2.96 kB
| # ============================================ | |
| # DocGenie API + Worker - Dockerfile (Minimal) | |
| # ============================================ | |
| # Adapted for Hugging Face Spaces (Docker SDK): | |
| # - Non-root user (UID 1000) β HF Spaces requirement | |
| # - Port 7860 β HF Spaces default | |
| # - Playwright browsers in user-owned path | |
| FROM python:3.11-slim | |
| WORKDIR /app | |
| # Install runtime system dependencies | |
| RUN apt-get update && apt-get install -y \ | |
| wget \ | |
| gnupg \ | |
| poppler-utils \ | |
| tesseract-ocr \ | |
| tesseract-ocr-eng \ | |
| libglib2.0-0 \ | |
| libnss3 \ | |
| libnspr4 \ | |
| libdbus-1-3 \ | |
| libatk1.0-0 \ | |
| libatk-bridge2.0-0 \ | |
| libcups2 \ | |
| libdrm2 \ | |
| libxkbcommon0 \ | |
| libxcomposite1 \ | |
| libxdamage1 \ | |
| libxfixes3 \ | |
| libxrandr2 \ | |
| libgbm1 \ | |
| libasound2 \ | |
| libpango-1.0-0 \ | |
| libcairo2 \ | |
| && rm -rf /var/lib/apt/lists/* | |
| # Install pip packages (no uv needed - simpler) | |
| COPY api/requirements.txt ./api/requirements.txt | |
| RUN pip install --no-cache-dir -r api/requirements.txt | |
| # Copy ONLY the docgenie modules needed by API (not the full package) | |
| COPY docgenie/__init__.py ./docgenie/__init__.py | |
| COPY docgenie/logging.py ./docgenie/logging.py | |
| COPY docgenie/generation ./docgenie/generation | |
| COPY data/prompt_templates ./data/prompt_templates | |
| COPY data/visual_element_prefabs ./data/visual_element_prefabs | |
| # Copy API code | |
| COPY api ./api | |
| # Copy startup script | |
| COPY start.sh ./start.sh | |
| RUN chmod +x start.sh | |
| # Clean up Python cache | |
| RUN find /usr/local/lib/python3.11/site-packages -type d -name "__pycache__" -exec rm -rf {} + 2>/dev/null || true && \ | |
| find /usr/local/lib/python3.11/site-packages -name "*.pyc" -delete | |
| # ------------------------------------------------------- | |
| # Non-root user setup β required by Hugging Face Spaces | |
| # ------------------------------------------------------- | |
| RUN useradd -m -u 1000 user | |
| # Install Playwright system dependencies as root (requires apt β must run before USER switch) | |
| RUN playwright install-deps chromium | |
| # Create writable directories and hand ownership to user | |
| RUN mkdir -p /tmp/docgenie /home/user/.cache/playwright && \ | |
| chown -R user:user /app /tmp/docgenie /home/user | |
| # Switch to non-root user for all runtime operations | |
| USER user | |
| # Set environment variables | |
| ENV HOME=/home/user \ | |
| PATH=/home/user/.local/bin:$PATH \ | |
| PYTHONUNBUFFERED=1 \ | |
| PYTHONPATH=/app \ | |
| PORT=7860 \ | |
| PLAYWRIGHT_BROWSERS_PATH=/home/user/.cache/playwright | |
| # Download Playwright Chromium browser binary into user-owned cache directory | |
| # (browser download only β system deps already installed above as root) | |
| RUN playwright install chromium | |
| # Expose port 7860 (Hugging Face Spaces default) | |
| EXPOSE 7860 | |
| # Health check | |
| HEALTHCHECK --interval=30s --timeout=10s --start-period=40s --retries=3 \ | |
| CMD python -c "import requests; requests.get('http://localhost:7860/health')" | |
| # Start command β shell script handles API + RQ worker | |
| CMD ["./start.sh"] | |