File size: 902 Bytes
fb7b761
 
7a29666
 
 
 
fb7b761
b1b8d73
 
 
 
 
 
 
 
 
 
 
7a29666
fb7b761
 
b1b8d73
 
7a29666
 
fb7b761
 
 
 
b1b8d73
 
fb7b761
b1b8d73
7a29666
fb7b761
7a29666
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
35
36
37
# 使用更小的基础镜像 python:3.10-slim-buster,减少镜像体积
FROM python:3.10-slim-buster

# 设置工作目录
WORKDIR /app

# 安装系统依赖,包括图形库和中文字体
RUN apt-get update && apt-get install -y \
    libglib2.0-0 \
    libx11-6 \
    libxrender1 \
    libxext6 \
    # 安装中文字体
    fonts-noto-cjk \
    fonts-wqy-microhei \
    # 清理缓存
    && apt-get clean \
    && rm -rf /var/lib/apt/lists/*

# 复制 requirements.txt 文件先安装 Python 依赖,减少不必要的层
COPY requirements.txt /app/

# 安装 Python 依赖
RUN pip install --no-cache-dir -r requirements.txt

# 复制剩余应用代码到容器中
COPY . /app

# 暴露端口(假设 Gradio 应用在 7860 端口运行)
EXPOSE 7860

# 设置环境变量,确保 Python 输出不缓冲
ENV PYTHONUNBUFFERED=1

# 设置默认命令,启动应用
CMD ["python", "app.py"]