FROM python:3.12-slim

WORKDIR /app

# Install system dependencies
RUN apt-get update && apt-get install -y \
    build-essential \
    libreoffice \
    wget \
    && rm -rf /var/lib/apt/lists/*
RUN pip install --upgrade pip
RUN pip install uv

# Configure uv and install mineru
ENV UV_SYSTEM_PYTHON=1
RUN uv pip install --system -U "mineru[core]"



# Copy requirements first to leverage Docker cache
# COPY requirements.txt .
# RUN pip install huggingface_hub
# RUN wget https://github.com/opendatalab/MinerU/raw/master/scripts/download_models_hf.py -O download_models_hf.py
# RUN wget https://raw.githubusercontent.com/opendatalab/MinerU/refs/heads/release-1.3.1/scripts/download_models_hf.py -O download_models_hf.py

# RUN python download_models_hf.py
RUN mineru-models-download -s modelscope -m pipeline




# RUN pip install --no-cache-dir -r requirements.txt
# RUN pip install -U magic-pdf[full]


# Copy the rest of the application
# COPY . .

# Create storage directories
# RUN mkdir -p storage/uploads storage/processed

# Expose the port the app runs on
EXPOSE 8000

# Command to run the application
CMD ["mineru-api", "--host", "0.0.0.0", "--port", "8000"] 