nanoapple commited on
Commit
be97446
·
verified ·
1 Parent(s): ecc2c28

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +31 -4
Dockerfile CHANGED
@@ -1,20 +1,47 @@
1
  FROM python:3.11-slim
2
 
3
- # 系统依赖(Tesseract + 语言包 + Ghostscript + qpdf 等)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4
  RUN apt-get update && apt-get install -y --no-install-recommends \
5
- tesseract-ocr tesseract-ocr-eng tesseract-ocr-chi-sim \
6
- ghostscript qpdf pngquant unpaper icc-profiles-free \
7
- libmagic1 ca-certificates && \
 
 
 
 
 
 
 
8
  rm -rf /var/lib/apt/lists/*
9
 
 
10
  WORKDIR /app
11
  COPY requirements.txt /app/requirements.txt
12
  RUN pip install --no-cache-dir -r requirements.txt
13
 
 
14
  COPY app.py /app/app.py
15
  COPY README.md /app/README.md
16
 
 
17
  EXPOSE 7860
18
  ENV STREAMLIT_SERVER_PORT=7860
19
  ENV STREAMLIT_SERVER_ADDRESS=0.0.0.0
 
 
 
20
  CMD ["streamlit", "run", "app.py", "--server.port=7860", "--server.address=0.0.0.0"]
 
1
  FROM python:3.11-slim
2
 
3
+ # ========= 系统环境变量(必须在 import streamlit 之前生效) =========
4
+ # 把 HOME 等全部指向 /tmp(可写目录)
5
+ ENV HOME=/tmp
6
+ ENV XDG_CACHE_HOME=/tmp
7
+ ENV STREAMLIT_CACHE_DIR=/tmp
8
+ ENV STREAMLIT_GLOBAL_DATA_DIR=/tmp
9
+ ENV STREAMLIT_RUNTIME_DIR=/tmp
10
+ ENV STREAMLIT_CONFIG_DIR=/tmp/.streamlit
11
+ ENV STREAMLIT_BROWSER_GATHER_USAGE_STATS=false
12
+
13
+ # 创建必要目录
14
+ RUN mkdir -p /tmp/.streamlit
15
+
16
+ # ========= 安装系统依赖 =========
17
+ # Tesseract OCR + 中文包 + PDF 处理工具
18
  RUN apt-get update && apt-get install -y --no-install-recommends \
19
+ tesseract-ocr \
20
+ tesseract-ocr-eng \
21
+ tesseract-ocr-chi-sim \
22
+ ghostscript \
23
+ qpdf \
24
+ pngquant \
25
+ unpaper \
26
+ icc-profiles-free \
27
+ libmagic1 \
28
+ ca-certificates && \
29
  rm -rf /var/lib/apt/lists/*
30
 
31
+ # ========= 安装 Python 依赖 =========
32
  WORKDIR /app
33
  COPY requirements.txt /app/requirements.txt
34
  RUN pip install --no-cache-dir -r requirements.txt
35
 
36
+ # ========= 复制应用代码 =========
37
  COPY app.py /app/app.py
38
  COPY README.md /app/README.md
39
 
40
+ # ========= 容器启动配置 =========
41
  EXPOSE 7860
42
  ENV STREAMLIT_SERVER_PORT=7860
43
  ENV STREAMLIT_SERVER_ADDRESS=0.0.0.0
44
+ # 禁止 Streamlit 自动打开浏览器(Spaces 环境也不会)
45
+ ENV STREAMLIT_BROWSER_SERVER_ADDRESS=0.0.0.0
46
+
47
  CMD ["streamlit", "run", "app.py", "--server.port=7860", "--server.address=0.0.0.0"]