cnmksjs commited on
Commit
4151092
·
verified ·
1 Parent(s): 3f403d6

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +45 -23
Dockerfile CHANGED
@@ -1,36 +1,58 @@
1
  FROM nvidia/cuda:12.3.2-cudnn9-devel-ubuntu22.04
2
 
3
- # 设置工作目录
4
- WORKDIR /home/user/app
5
-
6
- # 设置国内 apt 源,提高安装速度(可选)
7
- RUN sed -i 's|archive.ubuntu.com|mirrors.aliyun.com|g' /etc/apt/sources.list
8
-
9
- # 更新系统并安装必要依赖
10
- RUN apt-get update && apt-get install -y \
11
- git wget curl zip unzip \
12
- libgl1-mesa-glx libglib2.0-0 \
13
- ffmpeg libsm6 libxext6 \
14
- build-essential python3 python3-pip python3-dev \
 
 
 
 
 
15
  && rm -rf /var/lib/apt/lists/*
16
 
17
- # 设置时区(防止 tzdata 交互阻塞)
18
- RUN DEBIAN_FRONTEND=noninteractive TZ=Etc/UTC apt-get update && apt-get install -y tzdata && \
19
- ln -fs /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && \
20
  dpkg-reconfigure -f noninteractive tzdata
21
 
22
- # 确保 pip 是最新版本
23
- RUN pip3 install --no-cache-dir --upgrade pip
 
 
 
 
 
24
 
25
- # 安装 Python 依赖
26
  COPY requirements.txt /tmp/requirements.txt
27
- RUN pip3 install --no-cache-dir -r /tmp/requirements.txt
 
 
 
 
 
 
28
 
29
- # 复制应用代码到容器
30
  COPY . /home/user/app
31
 
32
- # 暴露端口(Hugging Face 默认使用 7860)
33
  EXPOSE 7860
34
 
35
- # 运行 Gradio Web UI
36
- CMD ["python3", "app.py"]
 
 
 
 
 
 
 
 
1
  FROM nvidia/cuda:12.3.2-cudnn9-devel-ubuntu22.04
2
 
3
+ # 设置环境变量,避免 tzdata 交互式配置
4
+ ENV DEBIAN_FRONTEND=noninteractive
5
+
6
+ # 安装 tzdata 和其他常用工具
7
+ RUN apt-get update && \
8
+ apt-get install -y \
9
+ tzdata \
10
+ git \
11
+ curl \
12
+ python3-pip \
13
+ python3-dev \
14
+ build-essential \
15
+ ffmpeg \
16
+ libsm6 \
17
+ libxext6 \
18
+ cmake \
19
+ libgl1-mesa-glx \
20
  && rm -rf /var/lib/apt/lists/*
21
 
22
+ # 配置时区(例如:Asia/Shanghai)
23
+ RUN ln -fs /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && \
 
24
  dpkg-reconfigure -f noninteractive tzdata
25
 
26
+ # 安装 pyenv 和 Python 3.10
27
+ RUN curl https://pyenv.run | bash
28
+ RUN export PATH="$HOME/.pyenv/bin:$PATH" && \
29
+ eval "$(pyenv init --path)" && \
30
+ pyenv install 3.10.10 && \
31
+ pyenv global 3.10.10 && \
32
+ pyenv rehash
33
 
34
+ # 安装 Python 依赖库
35
  COPY requirements.txt /tmp/requirements.txt
36
+ RUN pip install --no-cache-dir -r /tmp/requirements.txt
37
+
38
+ # 安装 Hugging Face 和 Gradio 所需的库
39
+ RUN pip install gradio torch transformers
40
+
41
+ # 设置工作目录
42
+ WORKDIR /home/user/app
43
 
44
+ # 复制代码到容器中
45
  COPY . /home/user/app
46
 
47
+ # 暴露端口
48
  EXPOSE 7860
49
 
50
+ # 启动 Gradio 应用
51
+ CMD ["python", "app.py"]
52
+
53
+
54
+
55
+
56
+
57
+
58
+