chen666-666 commited on
Commit
b1b8d73
·
verified ·
1 Parent(s): 5875510

Upload 2 files

Browse files
Files changed (1) hide show
  1. Dockerfile +23 -21
Dockerfile CHANGED
@@ -1,31 +1,33 @@
1
- # 使用官方 Python 轻量镜像
2
  FROM python:3.10-slim
3
 
4
- # 安装系统依赖,包括中文字体和其他必需的工具
5
- RUN apt-get update && \
6
- apt-get install -y --no-install-recommends \
7
- fonts-noto-cjk \ # 中文字体
8
- fontconfig \ # 字体配置工具
9
- python3-pip \ # pip
10
- git \ # git(如果有需要拉取代码)
11
- curl \ # curl(如果有需要下载文件)
12
- && apt-get clean && \
13
- rm -rf /var/lib/apt/lists/*
14
-
15
- # 设置 matplotlib 临时缓存目录(防止权限问题)
16
- ENV MPLCONFIGDIR=/tmp/matplotlib
17
-
18
  # 设置工作目录
19
  WORKDIR /app
20
 
21
- # 拷贝 Python 依赖文件
22
- COPY requirements.txt .
 
 
 
 
 
 
 
 
 
 
23
 
24
- # 安装 Python 库
 
 
 
25
  RUN pip install --no-cache-dir -r requirements.txt
26
 
27
- # 拷贝项目代码
28
- COPY . .
 
 
 
29
 
30
- # 运行 Gradio 应用
31
  CMD ["python", "app.py"]
 
1
+ # 使用 python:3.10-slim 作为基础镜像
2
  FROM python:3.10-slim
3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4
  # 设置工作目录
5
  WORKDIR /app
6
 
7
+ # 安装必要的系统依赖
8
+ RUN apt-get update && apt-get install -y \
9
+ libglib2.0-0 \
10
+ libx11-6 \
11
+ libxrender1 \
12
+ libxext6 \
13
+ # 安装中文字体
14
+ fonts-noto-cjk \
15
+ fonts-wqy-microhei \
16
+ # 清理缓存
17
+ && apt-get clean \
18
+ && rm -rf /var/lib/apt/lists/*
19
 
20
+ # 复制当前目录到容器内
21
+ COPY . /app
22
+
23
+ # 安装 Python 依赖
24
  RUN pip install --no-cache-dir -r requirements.txt
25
 
26
+ # 暴露端口(假设你的 Gradio 应用在 7860 端口运行)
27
+ EXPOSE 7860
28
+
29
+ # 设置环境变量
30
+ ENV PYTHONUNBUFFERED=1
31
 
32
+ # 设置默认命令
33
  CMD ["python", "app.py"]