FROM ubuntu:22.04
# docker 启动方式
# docker run -itd --gpus all --privileged=true --shm-size 8G --name onnx1 97271d29cb79 /bin/bash
MAINTAINER SuSu
# 切换阿里云源
RUN apt-get update && apt-get install -y vim && apt-get install -y sudo && apt-get -y install wget && apt-get install -y curl telnet
RUN sudo apt-get -y install systemctl
# 安装miniconda
# RUN wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh
# RUN bash Miniconda3-latest-Linux-x86_64.sh -b -p /opt/conda && rm -rf Miniconda3-latest-Linux-x86_64.sh
# RUN /opt/conda/bin/conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
ENV CONDA_DIR=/opt/conda
RUN wget --quiet https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O /tmp/miniconda.sh \
&& mkdir -p $CONDA_DIR \
&& bash /tmp/miniconda.sh -b -u -p $CONDA_DIR \
&& rm /tmp/miniconda.sh
# 将 Miniconda 添加到 PATH 环境变量中
ENV PATH=$CONDA_DIR/bin:$PATH
RUN conda update -n base -c defaults conda \
&& conda create -y -n onnx_cuda python=3.10.12
RUN echo "source activate myenv" > ~/.bashrc
ENV PATH /opt/conda/envs/myenv/bin:$PATH
#设置国内源
RUN conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
# RUN pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu121
RUN pip install onnxruntime-gpu==1.17.0 --extra-index-url https://aiinfra.pkgs.visualstudio.com/PublicPackages/_packaging/onnxruntime-cuda-12/pypi/simple/ --force-reinstall
#RUN pip install numpy==1.24.4
RUN conda install -n onnx_cuda -y pytorch torchvision torchaudio pytorch-cuda=12.1 -c pytorch -c nvidia
RUN source activate
# 下载并安装 code-server
RUN curl -fsSL https://code-server.dev/install.sh | sh
# 需要安装一些 插件
# 创建一个非 root 用户
RUN useradd -m coder \
&& echo "coder ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers.d/nopasswd \
&& chmod 0440 /etc/sudoers.d/nopasswd
# 切换到 coder 用户
USER coder
WORKDIR /home/coder
# 暴露 code-server 默认端口
EXPOSE 8080
VOLUME /root/workspace
# 启动 code-server
CMD ["code-server", "--bind-addr", "0.0.0.0:8080", "--auth", "none"]