Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
chenpangpang
gpu-base-image-build
Commits
aca891db
Commit
aca891db
authored
Jan 09, 2026
by
chenpangpang
Browse files
修改vscode的build脚本
parent
c0562231
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
57 additions
and
23 deletions
+57
-23
build_space/Dockerfile.codeserver_ubuntu
build_space/Dockerfile.codeserver_ubuntu
+57
-23
No files found.
build_space/Dockerfile.codeserver_ubuntu
100755 → 100644
View file @
aca891db
#请确保网络畅通,插件可自行安装
ARG BASE_IMAGE="nvidia/cuda:11.7.1-cudnn8-runtime-ubuntu20.04"
#请将以下FROM后的镜像修改为需要添加codeserver的原始镜像
FROM nvidia/cuda:11.3.1-cudnn8-runtime-ubuntu20.04
FROM $BASE_IMAGE
ARG BASE_IMAGE
LABEL module="vscode"
LABEL module="vscode"
ARG DEBIAN_FRONTEND=noninteractive
ARG DEBIAN_FRONTEND=noninteractive
# 是否基于torch镜像构建
ARG BASE_IMAGE_IS_TORCH=0
ARG TORCH_VERSION="2.0.1"
ARG TORCHVISION_VERSION="0.15.2"
ARG TORCHAUDIO_VERSION="2.0.2"
ARG CONDA_URL="https://mirrors.tuna.tsinghua.edu.cn/anaconda/miniconda/Miniconda3-py310_24.7.1-0-Linux-x86_64.sh"
ENV TZ=Asia/Shanghai
ENV TZ=Asia/Shanghai
ENV SHELL=/bin/bash \
ENV SHELL=/bin/bash \
LC_ALL=en_US.UTF-8 \
LC_ALL=en_US.UTF-8 \
...
@@ -13,15 +21,14 @@ SHELL ["/bin/bash","-c"]
...
@@ -13,15 +21,14 @@ SHELL ["/bin/bash","-c"]
USER root
USER root
WORKDIR /tmp
WORKDIR /tmp
# 设置软链接python pip
ENV HF_ENDPOINT=https://hf-mirror.com
RUN ln -sf /usr/bin/pip3 /usr/bin/pip \
&& ln -sf /usr/bin/python3 /usr/bin/python
COPY ./python-requirements.txt /tmp/
COPY ./python-requirements.txt /tmp/
COPY ./code-server_4.7.0_amd64.deb ./
COPY ./code-server_4.22.1_amd64.deb ./
RUN cp /etc/apt/sources.list /etc/apt/sources.list.bak; \
RUN cp /etc/apt/sources.list /etc/apt/sources.list.bak \
version_codename=$(cat /etc/os-release | grep -i 'VERSION_CODENAME' | awk -F= '{print $2}') \
&& mv /etc/apt/sources.list.d /etc/apt/sources.list.d.bak \
&& version_codename=$(cat /etc/os-release | grep -i 'VERSION_CODENAME' | awk -F= '{print $2}') \
&& echo -e "deb http://mirrors.aliyun.com/ubuntu/ ${version_codename} main restricted universe multiverse \n\
&& echo -e "deb http://mirrors.aliyun.com/ubuntu/ ${version_codename} main restricted universe multiverse \n\
deb http://mirrors.aliyun.com/ubuntu/ ${version_codename}-security main restricted universe multiverse\n\
deb http://mirrors.aliyun.com/ubuntu/ ${version_codename}-security main restricted universe multiverse\n\
deb http://mirrors.aliyun.com/ubuntu/ ${version_codename}-updates main restricted universe multiverse\n\
deb http://mirrors.aliyun.com/ubuntu/ ${version_codename}-updates main restricted universe multiverse\n\
...
@@ -43,29 +50,56 @@ deb-src http://mirrors.aliyun.com/ubuntu/ ${version_codename}-backports main res
...
@@ -43,29 +50,56 @@ deb-src http://mirrors.aliyun.com/ubuntu/ ${version_codename}-backports main res
sudo \
sudo \
openssh-client \
openssh-client \
openssh-server \
openssh-server \
python3.8 \
python3-pip \
&& locale-gen en_US.UTF-8 \
&& locale-gen en_US.UTF-8 \
&& dpkg -i code-server_4.7.0_amd64.deb \
&& dpkg -i code-server_4.22.1_amd64.deb \
&& pip3 config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple \
#&& apt-get clean \
&& pip install -r /tmp/python-requirements.txt ${SOURCES} \
#&& rm -rf /var/lib/apt/lists/* \
&& cp /root/.config/pip/pip.conf /etc/pip.conf \
#&& rm -rf /tmprm \
#&& mv /etc/apt/sources.list.bak /etc/apt/sources.list \
#&& mv /etc/apt/sources.list.d.bak /etc/apt/sources.list.d \
&& mkdir -p /var/run/sshd \
&& mkdir -p /var/run/sshd \
&& ssh-keygen -A \
&& ssh-keygen -A \
&& sed -i "s/#UseDNS .*/UseDNS no/" /etc/ssh/sshd_config
&& sed -i "s/#UseDNS .*/UseDNS no/" /etc/ssh/sshd_config
WORKDIR /
# ----- conda and python install -----
RUN pip3 install torch==1.10.0 torchvision==0.11.0 torchaudio==0.10.0 --index-url https://download.pytorch.org/whl/cu113 && \
RUN if [ -n "$CONDA_URL" ];then \
([ ! -d /root/.cache/pip ] || rm -r /root/.cache/pip)
mkdir -p /tmp/conda-extension \
&& cd /tmp/conda-extension \
&& wget $CONDA_URL \
&& bash $(echo $CONDA_URL | awk -F "/" '{print $NF}') -b -p /opt/conda \
&& echo "export PATH=\$PATH:/opt/conda/bin" >> /etc/profile.d/sothisai.sh \
&& cd .. \
&& rm -rf /tmp/conda-extension; fi
### 添加HF的镜像变量
ENV PATH=$PATH:/opt/conda/bin
#ENV HF_ENDPOINT=https://hf-mirror.com
#RUN echo 'export HF_ENDPOINT=https://hf-mirror.com' >> /etc/bash.bashrc && \
# echo 'export HF_ENDPOINT=https://hf-mirror.com' >> ~/.bashrc
RUN pip3 install --upgrade pip ${SOURCES} || pip install --upgrade pip ${SOURCES} \
&& pip3 config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple \
&& mv /etc/apt/sources.list.bak /etc/apt/sources.list \
&& mv /etc/apt/sources.list.d.bak /etc/apt/sources.list.d
RUN if [ -n "$TORCH_VERSION" ] && [ $BASE_IMAGE_IS_TORCH -eq 0 ];then \
cuda_version=$(echo "$BASE_IMAGE" | awk -F'[:-]' '{n=split($2,a,"."); print a[1] a[2]}') \
&& if [ "${TORCH_VERSION%%.*}" -eq 1 ]; then \
pip3 install --no-cache-dir "numpy<2" \
&& pip3 install --no-cache-dir torch==$TORCH_VERSION+cu$cuda_version torchvision==$TORCHVISION_VERSION+cu$cuda_version torchaudio==$TORCHAUDIO_VERSION \
--extra-index-url https://download.pytorch.org/whl/cu$cuda_version;else \
pip3 install --no-cache-dir torch==$TORCH_VERSION torchvision==$TORCHVISION_VERSION torchaudio==$TORCHAUDIO_VERSION \
--index-url https://download.pytorch.org/whl/cu$cuda_version; fi \
&& rm -r /root/.cache/pip; fi
RUN if [ -n "$TORCH_VERSION" ];then \
pip install --no-cache-dir transformers accelerate diffusers; fi
COPY ./python-requirements.txt /tmp/
RUN pip install --no-cache-dir -r /tmp/python-requirements.txt
### 添加HF的镜像变量
ENV HF_ENDPOINT=https://hf-mirror.com
RUN echo 'export HF_ENDPOINT=https://hf-mirror.com' >> /etc/bash.bashrc && \
echo 'export HF_ENDPOINT=https://hf-mirror.com' >> ~/.bashrc && \
echo 'export CUDA_HOME=/usr/local/cuda' >> /etc/bash.bashrc
EXPOSE 8080
EXPOSE 8080
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment