FROM nvidia/cuda:12.3.2-devel-ubuntu20.04
# 设置非交互式环境变量
ENV DEBIAN_FRONTEND=noninteractive
# 添加国内镜像源
RUN cat <<'EOF' > /etc/apt/sources.list
deb https://mirrors.cernet.edu.cn/ubuntu/ focal main restricted universe multiverse
# deb-src https://mirrors.cernet.edu.cn/ubuntu/ focal main restricted universe multiverse
deb https://mirrors.cernet.edu.cn/ubuntu/ focal-updates main restricted universe multiverse
# deb-src https://mirrors.cernet.edu.cn/ubuntu/ focal-updates main restricted universe multiverse
deb https://mirrors.cernet.edu.cn/ubuntu/ focal-backports main restricted universe multiverse
# deb-src https://mirrors.cernet.edu.cn/ubuntu/ focal-backports main restricted universe multiverse
# deb https://mirrors.cernet.edu.cn/ubuntu/ focal-security main restricted universe multiverse
# # deb-src https://mirrors.cernet.edu.cn/ubuntu/ focal-security main restricted universe multiverse
deb http://security.ubuntu.com/ubuntu/ focal-security main restricted universe multiverse
# deb-src http://security.ubuntu.com/ubuntu/ focal-security main restricted universe multiverse
EOF
# 安装SSH服务器
RUN apt-get update && \
apt-get install -y openssh-server wget vim git && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
# 创建一个新的root密码(请更改为您自己的密码)
RUN echo 'root:yourpassword' | chpasswd
# 允许root用户远程登录
RUN sed -i 's/#PermitRootLogin prohibit-password/PermitRootLogin yes/' /etc/ssh/sshd_config
# 修改SSH端口为8022
RUN sed -i 's/#Port 22/Port 8022/' /etc/ssh/sshd_config
# 防止SSH会话意外中断
RUN echo "ClientAliveInterval 60" >> /etc/ssh/sshd_config
RUN echo "ClientAliveCountMax 3" >> /etc/ssh/sshd_config
# 创建SSH运行目录
RUN mkdir /var/run/sshd
# 下载 Miniconda 安装脚本
RUN wget http://mirrors.tuna.tsinghua.edu.cn/anaconda/miniconda/Miniconda3-latest-Linux-x86_64.sh
# 安装 Miniconda
RUN bash Miniconda3-latest-Linux-x86_64.sh -b
RUN rm -f Miniconda3-latest-Linux-x86_64.sh
# 将 conda 加入环境变量 PATH
ENV PATH="/root/miniconda3/bin:${PATH}"
# 添加conda国内镜像源
RUN cat <<'EOF' > ~/.condarc
channels:
- defaults
show_channel_urls: true
default_channels:
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/msys2
custom_channels:
conda-forge: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
pytorch: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
EOF
RUN conda config --set custom_channels.conda-forge https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/
# 初始化环境
RUN conda init
# 创建一个新环境,安装 Python 3.11
RUN conda create --name chatbot python=3.11
# 激活新环境
RUN echo "conda activate chatbot" >> ~/.bashrc
SHELL ["/bin/bash", "--login", "-c"]
# 激活 Conda 环境
SHELL ["conda", "run", "-n", "chatbot", "/bin/bash", "-c"]
# 安装所需的软件包
RUN pip install jupyterlab numpy matplotlib pymysql scipy pandas seaborn tqdm scikit-learn torch torchvision torchaudio -i https://pypi.tuna.tsinghua.edu.cn/simple/
RUN pip install gradio openai pyyaml langchain sentence-transformers pymilvus accelerate dashscope einops bs4 -i https://pypi.tuna.tsinghua.edu.cn/simple/
RUN pip install auto-gptq optimum tiktoken transformers_stream_generator sse_starlette tavily-python pinecone-client networkx langchainhub langchain_experimental -i https://pypi.tuna.tsinghua.edu.cn/simple/
RUN pip install fastapi uvicorn flash_attn mdtex2html pydantic mysql-connector-python -i https://pypi.tuna.tsinghua.edu.cn/simple/