Spaces:
Sleeping

wuyan123258 commited on
Commit
499a681
·
verified ·
1 Parent(s): ad055b7

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +17 -13
Dockerfile CHANGED
@@ -1,28 +1,32 @@
1
- # 使用更小的基础镜像
2
  FROM python:3.9-slim
3
 
4
- # 设置环境变量和时区(可选)
5
- ENV PYTHONUNBUFFERED=1
6
 
7
- # 合并RUN指令:安装系统依赖并清理
 
 
 
 
 
8
  RUN apt-get update && \
9
- apt-get install -y --no-install-recommends \
10
- ffmpeg \
11
- git && \
12
  apt-get clean && \
13
  rm -rf /var/lib/apt/lists/* /tmp/*
14
 
15
- # 设置工作目录
16
- WORKDIR /app
17
-
18
- # 先复制依赖文件(此层变化频率低,利于缓存)
19
  COPY requirements.txt .
20
 
21
  # 安装Python依赖
22
  RUN pip install --no-cache-dir --upgrade pip && \
23
  pip install --no-cache-dir -r requirements.txt
24
 
25
- # 最后复制应用代码(此层变化频率最高)
26
  COPY . .
27
 
28
- # ... 其余配置 (如EXPOSE, CMD等)
 
 
 
 
 
1
+ # 使用官方Python镜像
2
  FROM python:3.9-slim
3
 
4
+ # 设置工作目录
5
+ WORKDIR /app
6
 
7
+ # 设置环境变量:使用国内镜像源加速下载,这是最重要的调整!
8
+ ENV PIP_INDEX_URL=https://pypi.tuna.tsinghua.edu.cn/simple
9
+ ENV PIP_TRUSTED_HOST=pypi.tuna.tsinghua.edu.cn
10
+ ENV HF_ENDPOINT=https://hf-mirror.com
11
+
12
+ # 安装系统依赖,并清理缓存
13
  RUN apt-get update && \
14
+ apt-get install -y --no-install-recommends ffmpeg && \
 
 
15
  apt-get clean && \
16
  rm -rf /var/lib/apt/lists/* /tmp/*
17
 
18
+ # 复制依赖文件
 
 
 
19
  COPY requirements.txt .
20
 
21
  # 安装Python依赖
22
  RUN pip install --no-cache-dir --upgrade pip && \
23
  pip install --no-cache-dir -r requirements.txt
24
 
25
+ # 最后复制应用代码
26
  COPY . .
27
 
28
+ # 暴露端口
29
+ EXPOSE 7860
30
+
31
+ # 启动命令(假设使用Gradio)
32
+ CMD ["python", "app.py"]