FROM python:3.11-slim

RUN apt-get update && apt-get install -y --no-install-recommends \
    poppler-utils \
    libgomp1 \
    && rm -rf /var/lib/apt/lists/*

WORKDIR /app

# Install PyTorch CPU + pdf2zh
RUN pip install --no-cache-dir torch --index-url https://download.pytorch.org/whl/cpu
RUN pip install --no-cache-dir pdf2zh

COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt

COPY . .

LABEL org.opencontainers.image.description="LLM 论文图书馆 + pdf2zh 翻译引擎"

VOLUME ["/app/papers", "/app/data"]
EXPOSE 8000
ENV PORT=8000
ENV LOG_LEVEL=info
ENV DEEPSEEK_MODEL=deepseek-chat

CMD ["sh", "-c", "python3 -m uvicorn api.server:app --host 0.0.0.0 --port ${PORT} --log-level ${LOG_LEVEL}"]
