-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile.python
More file actions
34 lines (25 loc) · 976 Bytes
/
Dockerfile.python
File metadata and controls
34 lines (25 loc) · 976 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# Python 服务 Dockerfile
# 包含 Tesseract OCR 和 Embedding 模型预下载
FROM python:3.10-slim
# 使用阿里云 Debian 镜像源(国内加速)
RUN sed -i 's/deb.debian.org/mirrors.aliyun.com/g' /etc/apt/sources.list.d/debian.sources
# 安装系统依赖
RUN apt-get update && apt-get install -y --no-install-recommends \
tesseract-ocr \
tesseract-ocr-chi-sim \
tesseract-ocr-eng \
libglib2.0-0 \
libsm6 \
libxext6 \
libxrender-dev \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app
# 先复制 requirements.txt,利用 Docker 缓存
COPY python-service/requirements.txt .
RUN pip install --no-cache-dir --default-timeout=600 --retries=5 -i https://pypi.tuna.tsinghua.edu.cn/simple --trusted-host pypi.tuna.tsinghua.edu.cn -r requirements.txt
# 复制服务代码
COPY python-service/ .
# 创建必要的目录
RUN mkdir -p uploads temp faiss_index
EXPOSE 8000
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"]