File size: 1,267 Bytes
3f2c936
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# 云部署镜像(1003, Hugging Face Spaces / Render 通用): 只含代码, 不含 schema / 论文 / 标注 / 密钥。
# 论文和标注在 GitHub 私有仓库; schema 启动时从同一仓库读(SCHEMA_REPO_PATH); 密钥在平台的 Secrets 里。
# 含 Docling + PyMuPDF(CPU 版 torch), 供管理员「上传论文」在服务器上转换; 模型首次转换时下载到 HF_HOME。
FROM python:3.11-slim
RUN apt-get update && apt-get install -y --no-install-recommends libgl1 libglib2.0-0 \
 && rm -rf /var/lib/apt/lists/* && useradd -m -u 1000 user
WORKDIR /srv
COPY app/requirements.txt app/requirements-convert.txt app/
RUN pip install --no-cache-dir -r app/requirements.txt \
 && pip install --no-cache-dir torch torchvision --index-url https://download.pytorch.org/whl/cpu \
 && pip install --no-cache-dir -r app/requirements-convert.txt
COPY app app
# 上云默认开密码; 真要关可在平台变量里覆盖 REQUIRE_PASSWORD=0
ENV STORAGE_BACKEND=github PORT=7860 CACHE_DIR=/tmp/repl_cache REQUIRE_PASSWORD=1 \
    SCHEMA_REPO_PATH=config/schema_0817.json HF_HOME=/tmp/hf OMP_NUM_THREADS=2 HOME=/home/user
USER user
EXPOSE 7860
WORKDIR /srv/app
CMD ["sh", "-c", "uvicorn main:app --host 0.0.0.0 --port ${PORT} --proxy-headers --forwarded-allow-ips='*'"]