docling-service/Dockerfile

41 lines
1.1 KiB
Docker

FROM python:3.11-slim
WORKDIR /app
# Install system dependencies for Docling and OCR
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
libgl1 \
libglib2.0-0 \
libsm6 \
libxext6 \
libxrender-dev \
libgomp1 \
poppler-utils \
tesseract-ocr \
libtesseract-dev \
ffmpeg \
&& rm -rf /var/lib/apt/lists/*
# Copy requirements first for layer caching
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
# Download Docling models at build time (optional, reduces first-run latency)
RUN python -c "from docling.document_converter import DocumentConverter; DocumentConverter()" || true
# Copy application code
COPY server.py .
# Create non-root user
RUN useradd -m -u 1000 appuser && chown -R appuser:appuser /app
USER appuser
EXPOSE 8081
# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=60s --retries=3 \
CMD python -c "import urllib.request; urllib.request.urlopen('http://localhost:8081/health')" || exit 1
CMD ["uvicorn", "server:app", "--host", "0.0.0.0", "--port", "8081"]