Gabriel00A commited on
Commit
f93d5f6
·
verified ·
1 Parent(s): bd0687e

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +30 -7
Dockerfile CHANGED
@@ -1,21 +1,44 @@
1
- # Dockerfile for Hugging Face Space with tesseract + gradio app
2
  FROM python:3.11-slim
3
 
4
- RUN apt-get update && apt-get install -y --no-install-recommends \
5
- tesseract-ocr \
6
- tesseract-ocr-chi-sim \
7
- libtesseract-dev \
8
- libleptonica-dev \
9
- poppler-utils \
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10
  && rm -rf /var/lib/apt/lists/*
11
 
12
  WORKDIR /app
13
 
 
 
 
 
14
  COPY requirements.txt /app/requirements.txt
15
  RUN pip install --no-cache-dir -r /app/requirements.txt
16
 
 
17
  COPY . /app
18
 
 
 
 
19
  EXPOSE 7860
20
 
 
21
  CMD ["python", "app.py"]
 
1
+ # 修正版 Dockerfile - 含常见系统依赖以保证 pip install 成功
2
  FROM python:3.11-slim
3
 
4
+ # 避免交互安装,更新并安装系统依赖(包含 tesseract 与图片/压缩库)
5
+ RUN apt-get update && \
6
+ apt-get install -y --no-install-recommends \
7
+ build-essential \
8
+ gcc \
9
+ git \
10
+ ca-certificates \
11
+ curl \
12
+ unzip \
13
+ libjpeg-dev \
14
+ zlib1g-dev \
15
+ libpng-dev \
16
+ libfreetype6-dev \
17
+ liblcms2-dev \
18
+ libwebp-dev \
19
+ tesseract-ocr \
20
+ tesseract-ocr-chi-sim \
21
+ libtesseract-dev \
22
+ libleptonica-dev \
23
+ poppler-utils \
24
  && rm -rf /var/lib/apt/lists/*
25
 
26
  WORKDIR /app
27
 
28
+ # 升级 pip 并安装 wheel,减少编译失败几率
29
+ RUN python -m pip install --upgrade pip setuptools wheel
30
+
31
+ # 复制依赖文件并安装
32
  COPY requirements.txt /app/requirements.txt
33
  RUN pip install --no-cache-dir -r /app/requirements.txt
34
 
35
+ # 复制所有应用文件
36
  COPY . /app
37
 
38
+ # 创建持久化目录(Spaces 会把 repo 挂载到 /app)
39
+ RUN mkdir -p /app/storage /app/data
40
+
41
  EXPOSE 7860
42
 
43
+ # 启动命令(Gradio app.py 用这个;若你用 uvicorn,替换为 uvicorn 启动)
44
  CMD ["python", "app.py"]