cnmksjs's picture
Update Dockerfile
4151092 verified
FROM nvidia/cuda:12.3.2-cudnn9-devel-ubuntu22.04
# 设置环境变量,避免 tzdata 交互式配置
ENV DEBIAN_FRONTEND=noninteractive
# 安装 tzdata 和其他常用工具
RUN apt-get update && \
apt-get install -y \
tzdata \
git \
curl \
python3-pip \
python3-dev \
build-essential \
ffmpeg \
libsm6 \
libxext6 \
cmake \
libgl1-mesa-glx \
&& rm -rf /var/lib/apt/lists/*
# 配置时区(例如:Asia/Shanghai)
RUN ln -fs /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && \
dpkg-reconfigure -f noninteractive tzdata
# 安装 pyenv 和 Python 3.10
RUN curl https://pyenv.run | bash
RUN export PATH="$HOME/.pyenv/bin:$PATH" && \
eval "$(pyenv init --path)" && \
pyenv install 3.10.10 && \
pyenv global 3.10.10 && \
pyenv rehash
# 安装 Python 依赖库
COPY requirements.txt /tmp/requirements.txt
RUN pip install --no-cache-dir -r /tmp/requirements.txt
# 安装 Hugging Face 和 Gradio 所需的库
RUN pip install gradio torch transformers
# 设置工作目录
WORKDIR /home/user/app
# 复制代码到容器中
COPY . /home/user/app
# 暴露端口
EXPOSE 7860
# 启动 Gradio 应用
CMD ["python", "app.py"]