63 lines
1.6 KiB
Docker
63 lines
1.6 KiB
Docker
|
|
# DocProcesser Dockerfile
|
||
|
|
# Optimized for RTX 5080 GPU deployment
|
||
|
|
|
||
|
|
# Use NVIDIA CUDA base image with Python 3.11
|
||
|
|
FROM nvidia/cuda:12.8.0-runtime-ubuntu24.04
|
||
|
|
|
||
|
|
# Set environment variables
|
||
|
|
ENV PYTHONUNBUFFERED=1 \
|
||
|
|
PYTHONDONTWRITEBYTECODE=1 \
|
||
|
|
PIP_NO_CACHE_DIR=1 \
|
||
|
|
PIP_DISABLE_PIP_VERSION_CHECK=1
|
||
|
|
|
||
|
|
# Set working directory
|
||
|
|
WORKDIR /app
|
||
|
|
|
||
|
|
# Install system dependencies
|
||
|
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||
|
|
python3.11 \
|
||
|
|
python3.11-venv \
|
||
|
|
python3.11-dev \
|
||
|
|
python3-pip \
|
||
|
|
libgl1-mesa-glx \
|
||
|
|
libglib2.0-0 \
|
||
|
|
libsm6 \
|
||
|
|
libxext6 \
|
||
|
|
libxrender-dev \
|
||
|
|
libgomp1 \
|
||
|
|
curl \
|
||
|
|
&& rm -rf /var/lib/apt/lists/* \
|
||
|
|
&& ln -sf /usr/bin/python3.11 /usr/bin/python \
|
||
|
|
&& ln -sf /usr/bin/python3.11 /usr/bin/python3
|
||
|
|
|
||
|
|
# Install uv for fast package management
|
||
|
|
RUN curl -LsSf https://astral.sh/uv/install.sh | sh
|
||
|
|
ENV PATH="/root/.local/bin:$PATH"
|
||
|
|
|
||
|
|
# Copy dependency files first for better caching
|
||
|
|
COPY pyproject.toml ./
|
||
|
|
|
||
|
|
# Create virtual environment and install dependencies
|
||
|
|
RUN uv venv /app/.venv
|
||
|
|
ENV PATH="/app/.venv/bin:$PATH"
|
||
|
|
ENV VIRTUAL_ENV="/app/.venv"
|
||
|
|
|
||
|
|
RUN uv pip install -i https://pypi.tuna.tsinghua.edu.cn/simple -e .
|
||
|
|
|
||
|
|
# Copy application code
|
||
|
|
COPY app/ ./app/
|
||
|
|
|
||
|
|
# Create model directories (models should be mounted at runtime)
|
||
|
|
RUN mkdir -p /app/app/model/DocLayout /app/app/model/PP-DocLayout
|
||
|
|
|
||
|
|
# Expose port
|
||
|
|
EXPOSE 8053
|
||
|
|
|
||
|
|
# Health check
|
||
|
|
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
|
||
|
|
CMD curl -f http://localhost:8053/health || exit 1
|
||
|
|
|
||
|
|
# Run the application
|
||
|
|
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8053", "--workers", "1"]
|
||
|
|
|