Team Ai
Apppublic

imran-decoder/filecrackhead

sourceHugging Faceupdated 7mo agoView on Hugging Face
0likes
Dockerfile83 linesDownload Raw Back to root
1# ============================================================2# Multi-Format Document File Conversion Service3# Production Dockerfile — Hugging Face Spaces compatible4# Port: 78605# ============================================================6 7FROM python:3.11-slim8 9# ── System-level metadata ────────────────────────────────────10LABEL maintainer="file-converter-service"11LABEL description="Multi-format document conversion API"12 13# ── Environment ──────────────────────────────────────────────14ENV PYTHONDONTWRITEBYTECODE=1 \15    PYTHONUNBUFFERED=1 \16    DEBIAN_FRONTEND=noninteractive \17    # LibreOffice headless mode — no display server available18    DISPLAY="" \19    # Tesseract data directory20    TESSDATA_PREFIX=/usr/share/tesseract-ocr/5/tessdata21 22# ── System dependencies ──────────────────────────────────────23RUN apt-get update && apt-get install -y --no-install-recommends \24    # Core conversion tools25    libreoffice \26    libreoffice-writer \27    libreoffice-calc \28    libreoffice-impress \29    pandoc \30    poppler-utils \31    ghostscript \32    # OCR (Tesseract)33    tesseract-ocr \34    tesseract-ocr-eng \35    # python-magic backend36    libmagic1 \37    # Image conversion (cairosvg + pillow-heif)38    libcairo2-dev \39    libffi-dev \40    libheif-dev \41    # General utilities42    curl \43    fonts-liberation \44    fonts-noto \45    fonts-noto-cjk \46    && rm -rf /var/lib/apt/lists/*47 48# ── Create non-root user for security ────────────────────────49RUN groupadd -r appuser && useradd -r -g appuser appuser50 51# ── Working directory ────────────────────────────────────────52WORKDIR /app53 54# ── Python dependencies ───────────────────────────────────────55COPY requirements.txt .56RUN pip install --no-cache-dir --upgrade pip && \57    pip install --no-cache-dir -r requirements.txt58 59# ── Application code ──────────────────────────────────────────60COPY . .61 62# ── Temp directory (writable by app user) ────────────────────63RUN mkdir -p /tmp/file_converter && \64    chown -R appuser:appuser /tmp/file_converter && \65    chown -R appuser:appuser /app66 67# ── LibreOffice user profile directory ───────────────────────68RUN mkdir -p /home/appuser/.config/libreoffice && \69    chown -R appuser:appuser /home/appuser70 71USER appuser72 73# ── Health check ─────────────────────────────────────────────74HEALTHCHECK --interval=30s --timeout=10s --start-period=15s --retries=3 \75    CMD curl -f http://localhost:7860/health || exit 176 77# ── Expose port (Hugging Face Spaces default) ────────────────78EXPOSE 786079 80# ── Run ──────────────────────────────────────────────────────81CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "7860", \82     "--workers", "1", "--log-level", "info", "--timeout-keep-alive", "30"]83