Commit 8885584b authored by chenpangpang's avatar chenpangpang
Browse files

feat: 初始提交

parent 7e6e7f2b
# gpu-base-image-build
## 构建命令
- 基于[pytorch官方镜像](https://hub.docker.com/r/pytorch/pytorch)构建镜像
```bash
./build_ubuntu.sh jupyterlab \
juypterlab-pytorch:2.3.1-py3.10-cuda12.1-ubuntu22.04 \
pytorch/pytorch:2.3.1-cuda12.1-cudnn8-runtime
```
- 参数1: framework,不需要改动
- 参数2: 输出镜像名称
- 参数3: 基础镜像
- 基于[nvidia官方镜像](https://hub.docker.com/r/nvidia/cuda)构建镜像
```bash
./build_ubuntu.sh jupyterlab \
juypterlab-pytorch:2.3.1-py3.8-cuda12.1-ubuntu22.04 \
nvidia/cuda:12.1.0-cudnn8-runtime-ubuntu22.04 \
TORCH_VERSION="2.3.1" \
TORCHVISION_VERSION="0.18.1" \
TORCHAUDIO_VERSION="2.3.1" \
CONDA_URL="https://mirrors.tuna.tsinghua.edu.cn/anaconda/miniconda/Miniconda3-py38_22.11.1-1-Linux-x86_64.sh"
```
- 参数1: framework,不需要改动
- 参数2: 输出镜像名称
- 参数3: 基础镜像
## 验证镜像
-
\ No newline at end of file
#请确保网络畅通,插件可自行安装
#请将以下FROM后的镜像修改为需要添加codeserver的原始镜像
FROM nvidia/cuda:11.3.1-cudnn8-runtime-ubuntu20.04
LABEL module="vscode"
ARG DEBIAN_FRONTEND=noninteractive
ENV TZ=Asia/Shanghai
ENV SHELL=/bin/bash \
LC_ALL=en_US.UTF-8 \
LANG=en_US.UTF-8 \
LANGUAGE=en_US.UTF-8
ARG SOURCES="-i https://pypi.tuna.tsinghua.edu.cn/simple --trusted-host pypi.tuna.tsinghua.edu.cn"
SHELL ["/bin/bash","-c"]
USER root
WORKDIR /tmp
# 设置软链接python pip
RUN ln -sf /usr/bin/pip3 /usr/bin/pip \
&& ln -sf /usr/bin/python3 /usr/bin/python
COPY ./python-requirements.txt /tmp/
COPY ./code-server_4.7.0_amd64.deb ./
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}') \
&& 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}-updates main restricted universe multiverse\n\
deb http://mirrors.aliyun.com/ubuntu/ ${version_codename}-proposed main restricted universe multiverse\n\
deb http://mirrors.aliyun.com/ubuntu/ ${version_codename}-backports main restricted universe multiverse\n\
deb-src http://mirrors.aliyun.com/ubuntu/ ${version_codename} main restricted universe multiverse\n\
deb-src http://mirrors.aliyun.com/ubuntu/ ${version_codename}-security main restricted universe multiverse\n\
deb-src http://mirrors.aliyun.com/ubuntu/ ${version_codename}-updates main restricted universe multiverse\n\
deb-src http://mirrors.aliyun.com/ubuntu/ ${version_codename}-proposed main restricted universe multiverse\n\
deb-src http://mirrors.aliyun.com/ubuntu/ ${version_codename}-backports main restricted universe multiverse" > /etc/apt/sources.list \
&& apt-get update -y \
&& apt-get install --no-install-recommends -y \
openssl \
libssl-dev \
net-tools \
locales \
wget \
git \
sudo \
openssh-client \
openssh-server \
python3.8 \
python3-pip \
&& locale-gen en_US.UTF-8 \
&& dpkg -i code-server_4.7.0_amd64.deb \
&& pip3 config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple \
&& pip install -r /tmp/python-requirements.txt ${SOURCES} \
&& cp /root/.config/pip/pip.conf /etc/pip.conf \
&& mkdir -p /var/run/sshd \
&& ssh-keygen -A \
&& sed -i "s/#UseDNS .*/UseDNS no/" /etc/ssh/sshd_config
WORKDIR /
RUN pip3 install torch==1.10.0 torchvision==0.11.0 torchaudio==0.10.0 --index-url https://download.pytorch.org/whl/cu113 && \
([ ! -d /root/.cache/pip ] || rm -r /root/.cache/pip)
### 添加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
EXPOSE 8080
\ No newline at end of file
ARG BASE_IMAGE="nvidia/cuda:11.7.1-cudnn8-runtime-ubuntu20.04"
FROM $BASE_IMAGE
ARG BASE_IMAGE
ARG DEBIAN_FRONTEND=noninteractive
LABEL module="jupyter"
# 是否基于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"
ARG SOURCES="-i https://pypi.tuna.tsinghua.edu.cn/simple --trusted-host pypi.tuna.tsinghua.edu.cn"
ENV TZ=Asia/Shanghai
ENV SHELL=/bin/bash \
LC_ALL=en_US.UTF-8 \
LANG=en_US.UTF-8 \
LANGUAGE=en_US.UTF-8
ENV HF_ENDPOINT=https://hf-mirror.com
SHELL ["/bin/bash","-c"]
USER root
RUN cp /etc/apt/sources.list /etc/apt/sources.list.bak \
&& mv /etc/apt/sources.list.d /etc/apt/sources.list.d.bak \
&& version_id=$(cat /etc/os-release | grep -i 'VERSION_CODENAME' | awk -F= '{print $2}') \
&& echo -e "deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ ${version_id} main restricted universe multiverse \n\
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ ${version_id}-security main restricted universe multiverse\n\
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ ${version_id}-updates main restricted universe multiverse\n\
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ ${version_id}-proposed main restricted universe multiverse\n\
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ ${version_id}-backports main restricted universe multiverse\n\
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ ${version_id} main restricted universe multiverse\n\
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ ${version_id}-security main restricted universe multiverse\n\
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ ${version_id}-updates main restricted universe multiverse\n\
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ ${version_id}-proposed main restricted universe multiverse\n\
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ ${version_id}-backports main restricted universe multiverse" > /etc/apt/sources.list \
&& apt-get update -y \
&& apt-get install --no-install-recommends -y vim openssl libssl-dev net-tools locales wget git git-lfs sudo openssh-client openssh-server \
&& locale-gen en_US.UTF-8
RUN if [ $BASE_IMAGE_IS_TORCH -eq 0 ];then \
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
ENV PATH=$PATH:/opt/conda/bin
RUN if [ $BASE_IMAGE_IS_TORCH -eq 0 ];then \
pip3 install --upgrade pip ${SOURCES} || pip install --upgrade pip ${SOURCES} \
&& pip3 config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple \
&& pip3 install --no-cache-dir setuptools ipywidgets wheel \
&& mv /etc/apt/sources.list.bak /etc/apt/sources.list \
&& mv /etc/apt/sources.list.d.bak /etc/apt/sources.list.d \
&& pip3 install matplotlib; fi
# 安装pytorch 需要设置代理
#ENV http_proxy=http://ac19pn3az3:M36tPjtQ@10.21.131.1:3128/
#ENV https_proxy=http://ac19pn3az3:M36tPjtQ@10.21.131.1:3128/
RUN if [ $BASE_IMAGE_IS_TORCH -eq 0 ];then \
pip3 install torch==$TORCH_VERSION torchvision==$TORCHVISION_VERSION torchaudio==$TORCHAUDIO_VERSION \
--index-url https://download.pytorch.org/whl/cu$(echo "$BASE_IMAGE" | awk -F'[:-]' '{n=split($2,a,"."); print a[1] a[2]}') \
&& rm -r /root/.cache/pip; fi
# 安装jupyterlab插件
RUN pip3 install jupyterlab==4.0.0
RUN mkdir -p /tmp/jupyter-extension
COPY ./jupyter_ext_dataset-0.1.0-py3-none-any.whl /tmp/jupyter-extension/
COPY ./jupyter_ext_logo-0.1.0-py3-none-any.whl /tmp/jupyter-extension/
COPY ./jupyterlab_language_pack_zh_cn-4.0.post6-py2.py3-none-any.whl /tmp/jupyter-extension/
COPY ./requirements.txt /tmp/jupyter-extension/
COPY ./static /tmp/jupyter-extension/static
COPY extension.sh /tmp/
RUN chmod +x /tmp/extension.sh && \
/tmp/extension.sh
COPY ./jupyter_lab_config.py /etc/
RUN jupytersite="$(python3 -m pip show jupyterlab | grep -i '^location' | awk '{print $2}')" \
&& JUPYTERLAB_DIR=$(echo ${jupytersite%%/lib/python*}) \
&& if [[ ${JUPYTERLAB_DIR}/bin/jupyter != "/opt/conda/bin/jupyter" ]]; \
then mkdir -p /opt/conda/bin; \
ln -sf ${JUPYTERLAB_DIR}/bin/jupyter /opt/conda/bin/jupyter;fi \
&& echo "export JUPYTER_CONFIG_PATH=/etc" >> /etc/bash.bashrc \
&& echo "export JUPYTER=${JUPYTERLAB_DIR}/bin/jupyter" >> /etc/bash.bashrc\
&& echo "export PATH=${JUPYTERLAB_DIR}/bin:${PATH}" >> /etc/bash.bashrc \
&& mkdir -p /var/run/sshd \
&& ssh-keygen -A \
&& sed -i "s/#UseDNS .*/UseDNS no/" /etc/ssh/sshd_config
COPY ./python-requirements.txt /tmp/
RUN pip install -r /tmp/python-requirements.txt ${SOURCES}
EXPOSE 8888
#请确保网络畅通
#请将以下FROM后的镜像修改为需要添加rstudio的原始镜像
FROM original_images_name
#如有问题请通过以下邮箱联系
LABEL maintainer="chenwch1@sugon.com"
LABEL module="rstudio"
ARG R_VERSION=4.2.1
ARG DEBIAN_FRONTEND=noninteractive
ENV TZ=Asia/Shanghai
ENV SHELL=/bin/bash \
LC_ALL=en_US.UTF-8 \
LANG=en_US.UTF-8 \
LANGUAGE=en_US.UTF-8
ENV PATH=/usr/lib/rstudio-server/bin:${PATH}
SHELL ["/bin/bash","-c"]
USER root
WORKDIR /tmp
#设置代理
ENV http_proxy=http://ac19pn3az3:M36tPjtQ@10.21.131.1:3128/
ENV https_proxy=http://ac19pn3az3:M36tPjtQ@10.21.131.1:3128/
ENV HF_ENDPOINT=https://hf-mirror.com
COPY ./python-requirements.txt /tmp/
RUN cp /etc/apt/sources.list /etc/apt/sources.list.bak \
#&& 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}') \
&& version_id=$(cat /etc/os-release | grep -i 'VERSION_ID' | awk -F= '{print $2}' | sed 's/\"//g' | awk -F. '{print $1$2}') \
&& 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}-updates main restricted universe multiverse\n\
deb http://mirrors.aliyun.com/ubuntu/ ${version_codename}-proposed main restricted universe multiverse\n\
deb http://mirrors.aliyun.com/ubuntu/ ${version_codename}-backports main restricted universe multiverse\n\
deb-src http://mirrors.aliyun.com/ubuntu/ ${version_codename} main restricted universe multiverse\n\
deb-src http://mirrors.aliyun.com/ubuntu/ ${version_codename}-security main restricted universe multiverse\n\
deb-src http://mirrors.aliyun.com/ubuntu/ ${version_codename}-updates main restricted universe multiverse\n\
deb-src http://mirrors.aliyun.com/ubuntu/ ${version_codename}-proposed main restricted universe multiverse\n\
deb-src http://mirrors.aliyun.com/ubuntu/ ${version_codename}-backports main restricted universe multiverse" > /etc/apt/sources.list \
&& apt-get update -y \
&& apt-get install --no-install-recommends -y \
gdebi-core \
curl \
openssl \
locales \
libssl-dev \
net-tools \
wget \
git \
sudo \
openssh-client \
openssh-server \
&& locale-gen en_US.UTF-8 \
&& curl -C - -kO --retry 10 https://cdn.rstudio.com/r/ubuntu-${version_id}/pkgs/r-${R_VERSION}_1_amd64.deb \
&& curl -C - -kO --retry 10 https://download2.rstudio.org/server/bionic/amd64/rstudio-server-2022.07.2-576-amd64.deb \
&& gdebi -n r-${R_VERSION}_1_amd64.deb \
&& ln -s /opt/R/4.2.1/bin/R /usr/local/bin/R \
&& ln -s /opt/R/4.2.1/bin/Rscript /usr/local/bin/Rscript \
&& gdebi -n rstudio-server-2022.07.2-576-amd64.deb \
&& chmod 1777 /var/run/rstudio-server \
&& chmod 1777 /var/lib/rstudio-server \
&& rm -rf /var/lib/rstudio-server/rstudio-os.sqlite \
&& echo "export PATH=/usr/lib/rstudio-server/bin:${PATH}" >> /etc/bashrc \
#&& rm -rf /tmprm \
&& rm -rf /var/cache/yum/* \
&& pip3 config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple \
&& pip install -r /tmp/python-requirements.txt ${SOURCES} \
&& mkdir -p /var/run/sshd \
&& ssh-keygen -A \
&& sed -i "s/#UseDNS .*/UseDNS no/" /etc/ssh/sshd_config
WORKDIR /
ENTRYPOINT bash --login;
#/bin/bash
# pytorch==2.2.1 torchvision==0.17.1 torchaudio==2.2.1 pytorch-cuda=12.1
# cuda=11.6(这个版本的空镜像,有些框架需要低版本)
# paddlepaddle-gpu==2.6.1.post120 cuda12
# tensroflow 安装最高版本 cuda12
rm -r ./tmp
framework=$1
newtag=$2
tmp_dockerfile="Dockerfile.${RANDOM}"
if [ ! -d "./tmp" ];then
mkdir tmp
fi
if [ "${framework}" == "jupyterlab" ];then
cp ./jupyter-extension-install-v2/*.whl ./tmp/
cp ./jupyter-extension-install-v2/requirements.txt ./tmp/
cp ./extension.sh ./tmp/
cp ./jupyter_lab_config.py ./tmp/
cp -r ./jupyter-extension-install-v2/static ./tmp/
fi
if [ "${framework}" == "codeserver" ];then
cp ./code-server_4.7.0_amd64.deb ./tmp/
fi
cp ./python-requirements.txt ./tmp/
cp -f ./Dockerfile.${framework}_ubuntu ./tmp/${tmp_dockerfile}
# temp_image="$(grep -n '^FROM' ./tmp/${tmp_dockerfile} | tac | head -1 | awk '{print $2}')"
# sed -i "s?${temp_image}?${base_tag}?g" ./tmp/${tmp_dockerfile}
docker build -f ./tmp/${tmp_dockerfile} -t ${newtag} ./tmp/
if [[ $? -eq 0 ]];then
echo -e "\033[32mBuild Image Successfully !\033[0m"
else
echo -e "\033[32mBuild Image unsuccessful !\033[0m"
exit 1
fi
\ No newline at end of file
echo "启动jupyter 检查文件中..."
WORKSPACE="/tmp/jupyter-extension"
content=$(nohup jupyter lab --allow-root --ip=0.0.0.0 --port=8888 > /tmp/start.log 2>&1 & sleep 20s; cat /tmp/start.log| grep "JupyterLab application directory")
echo $content
if [ -z "$content" ]; then
echo "content Not Found! please retry!"
else
jupyter_file_path=$(echo "$content" | grep -oP '(?<=is\s)(\/[^ ]+)')
fi
# ls "${jupyter_file_path}/static/index.html"
# echo "jupyter sourcecode path is :${jupyter_file_path}/static"
file_check=$(if [ -d "${jupyter_file_path}/static" ]; then echo "success"; else echo "file check failed"; fi)
echo $file_check
if [ "failed" == "$file_check" ]; then
echo "image jupyter sourcecode path check failed! please retry!"
fi
# 获取index的内容 那去js名 替换
js_content=$(cat ${jupyter_file_path}/static/index.html)
echo $js_content
js_path=$(echo "$js_content" | grep -oP '{{page_config\.fullStaticUrl}}/main\.[^"]+\.js\?v=[^"]+' )
js_path2=$(echo "$js_content" | grep -oP '{{page_config\.fullStaticUrl}}/vendors~main\.[^"]+\.js\?v=[^"]+' )
js_path3=$(echo "$js_content" | grep -oP '{{page_config\.fullStaticUrl}}/vendors~main\.[^"]+\.js' )
echo "jupyter js source path is: $js_path"
if [ -z "$js_path" ];then
if [ -z "$js_path2" ];then
if [ -z "$js_path3" ];then
echo "image jupyter sourcecode main js path check failed!please retry!"
else
js_path=$js_path3
fi
else
js_path=$js_path2
fi
fi
cat $WORKSPACE/static/index-base.html > $WORKSPACE/static/index.html
sed -i "s#mainJsParam#${js_path}#g" $WORKSPACE/static/index.html
cp -a $WORKSPACE/static/index.html ${jupyter_file_path}/static/index.html
cp -a $WORKSPACE/static/scnet-loading.gif ${jupyter_file_path}/static/scnet-loading.gif
pip3 uninstall -r $WORKSPACE/requirements.txt
pip3 install --no-index --find-links=$WORKSPACE/ -r $WORKSPACE/requirements.txt
if pip list | grep -E 'jupyter_ext_dataset' && pip list | grep -E 'jupyter_ext_logo' && pip list | grep -E 'jupyterlab-language-pack-zh-CN' && [ "$(jupyter lab --version | cut -d. -f1)" -gt 2 ];then echo "安装成功";else echo \"安装失败!! \" | tee /jupyter-ext/errorImages.txt; fi
rm -r $WORKSPACE
\ No newline at end of file
# Jupyterlab插件部署手册
# Jupyterlab版本
期望后续新镜像Jupyterlab版本≥4.0.0 (python ≥ 3.8)
```bash
pip install jupyterlab=4.0.0
```
# 插件更新
## 单个镜像插件安装
```bash
# 提供whl插件包,每个功能一种插件,容器内执行
pip install jupyter_ext_dataset-0.1.0-py3-none-any.whl
# 批量安装
pip install --no-index --find-links=. -r requirements.txt
```
## 批量镜像插件安装
使用updateJupyterImage_script脚本
## 功能验证
Jupyterlab插件功能验证
```bash
# 确认三个插件及jupyterlab都有
pip list
```
在Sothisai中启动后
汉化、scnet图标、数据集插件左边菜单
\ No newline at end of file
#!/bin/bash
# 框架
framework=$1
# 输出镜像tag
image_tag=$2
# 基础镜像
base_image=$3
build_args=" --build-arg BASE_IMAGE=$base_image"
if [ ${base_image%%:*} = "pytorch/pytorch" ]; then
build_args="$build_args --build-arg BASE_IMAGE_IS_TORCH=1 "
fi
for arg in ${*:4}
do
build_args="$build_args --build-arg $arg "
done
tmp_dockerfile="Dockerfile.${RANDOM}"
if [ ! -d "./tmp" ];then
mkdir tmp
fi
if [ "${framework}" == "jupyterlab" ];then
cp ./jupyter-extension-install-v2/*.whl ./tmp/
cp ./jupyter-extension-install-v2/requirements.txt ./tmp/
cp ./extension.sh ./tmp/
cp ./jupyter_lab_config.py ./tmp/
cp -r ./jupyter-extension-install-v2/static ./tmp/
fi
if [ "${framework}" == "codeserver" ];then
cp ./code-server_4.7.0_amd64.deb ./tmp/
fi
cp ./python-requirements.txt ./tmp/
cp -f ./Dockerfile.${framework}_ubuntu ./tmp/${tmp_dockerfile}
echo "docker build -f ./tmp/${tmp_dockerfile} -t ${image_tag} $build_args ./tmp/"
docker build -f ./tmp/${tmp_dockerfile} -t ${image_tag} $build_args ./tmp/
rm -r ./tmp
if [[ $? -eq 0 ]];then
echo -e "\033[32mBuild Image Successfully !\033[0m"
else
echo -e "\033[32mBuild Image fail!\033[0m"
exit 1
fi
\ No newline at end of file
image.sourcefind.cn:5000/cpu/admin/base/jupyterlab:3.4.7-multi.python
\ No newline at end of file
jupyterlab-language-pack-zh-CN
jupyter_ext_logo
jupyter_ext_dataset
\ No newline at end of file
<!doctype html><html lang="en"><head><meta charset="utf-8"><title>JupyterLab</title><meta name="viewport" content="width=device-width,initial-scale=1">{# Copy so we do not modify the page_config with updates. #} {% set page_config_full = page_config.copy() %} {# Set a dummy variable - we just want the side effect of the update. #} {% set _ = page_config_full.update(baseUrl=base_url, wsUrl=ws_url) %}<script id="jupyter-config-data" type="application/json">{{ page_config_full | tojson }}</script>{% block favicon %}<link rel="icon" type="image/x-icon" href="{{ base_url | escape }}static/favicons/favicon.ico" class="idle favicon"><link rel="" type="image/x-icon" href="{{ base_url | escape }}static/favicons/favicon-busy-1.ico" class="busy favicon">{% endblock %}<script defer="defer" src="mainJsParam"></script></head>
<script>/* Remove token from URL. */
(function () {
var location = window.location;
var search = location.search;
// If there is no query string, bail.
if (search.length <= 1) {
return;
}
// Rebuild the query string without the `token`.
var query = '?' + search.slice(1).split('&')
.filter(function (param) { return param.split('=')[0] !== 'token'; })
.join('&');
// Rebuild the URL with the new query string.
var url = location.origin + location.pathname +
(query !== '?' ? query : '') + location.hash;
if (url === location.href) {
return;
}
window.history.replaceState({ }, '', url);
})();</script>
<body>
<div id="sugon-logo-wrap">
<img src="{{page_config.fullStaticUrl}}/scnet-loading.gif" />
</div>
</body>
<style>
#sugon-logo-wrap {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
width: 300px;
height: 150px;
z-index: 100;
}
#sugon-logo-wrap img {
width: 100%;
}
</style>
<script>
var sugonLoadInterval = setInterval(() => {
var sugonMenu = document.getElementById('jp-menu-panel')
if (sugonMenu) {
clearInterval(sugonLoadInterval)
document.body.removeChild(document.getElementById('sugon-logo-wrap'))
}
}, 100)
</script>
</html>
<!doctype html><html lang="en"><head><meta charset="utf-8"><title>JupyterLab</title><meta name="viewport" content="width=device-width,initial-scale=1">{# Copy so we do not modify the page_config with updates. #} {% set page_config_full = page_config.copy() %} {# Set a dummy variable - we just want the side effect of the update. #} {% set _ = page_config_full.update(baseUrl=base_url, wsUrl=ws_url) %}<script id="jupyter-config-data" type="application/json">{{ page_config_full | tojson }}</script>{% block favicon %}<link rel="icon" type="image/x-icon" href="{{ base_url | escape }}static/favicons/favicon.ico" class="idle favicon"><link rel="" type="image/x-icon" href="{{ base_url | escape }}static/favicons/favicon-busy-1.ico" class="busy favicon">{% endblock %}<script defer="defer" src="{{page_config.fullStaticUrl}}/main.9907354c68bf45c5d68c.js?v=9907354c68bf45c5d68c"></script></head>
<script>/* Remove token from URL. */
(function () {
var location = window.location;
var search = location.search;
// If there is no query string, bail.
if (search.length <= 1) {
return;
}
// Rebuild the query string without the `token`.
var query = '?' + search.slice(1).split('&')
.filter(function (param) { return param.split('=')[0] !== 'token'; })
.join('&');
// Rebuild the URL with the new query string.
var url = location.origin + location.pathname +
(query !== '?' ? query : '') + location.hash;
if (url === location.href) {
return;
}
window.history.replaceState({ }, '', url);
})();</script>
<body>
<div id="sugon-logo-wrap">
<img src="{{page_config.fullStaticUrl}}/scnet-loading.gif" />
</div>
</body>
<style>
#sugon-logo-wrap {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
width: 300px;
height: 150px;
z-index: 100;
}
#sugon-logo-wrap img {
width: 100%;
}
</style>
<script>
var sugonLoadInterval = setInterval(() => {
var sugonMenu = document.getElementById('jp-menu-panel')
if (sugonMenu) {
clearInterval(sugonLoadInterval)
document.body.removeChild(document.getElementById('sugon-logo-wrap'))
}
}, 100)
</script>
</html>
#!/bin/bash
WORKSPACE="/opt/jupyter-ext/install"
#循环读取images.txt,并存入list中
n=0
fail_image_array=()
for line in $(cat images.txt | grep ^[^#])
do
list[$n]=$line
((n+=1))
done
echo "需推送的镜像地址如下:"
for variable in ${list[@]}
do
echo ${variable}
done
for variable in ${list[@]}
do
#下载镜像
echo "准备拉取镜像: $variable"
docker pull $variable
# #获取拉取的镜像ID
imageId=`docker images -q $variable`
echo "[$variable]拉取完成后的镜像ID: $imageId"
#启动容器
CONTAINER_ID=$(docker run -v $WORKSPACE:/jupyter-ext -itd $variable)
echo "容器ID:${CONTAINER_ID},启动jupyter 检查文件中..."
content=$(docker exec ${CONTAINER_ID} bash -c 'nohup jupyter lab --allow-root --ip=0.0.0.0 --port=8888 > /tmp/start.log 2>&1 & sleep 20s; cat /tmp/start.log| grep "JupyterLab application directory"')
echo $content
if [ -z "$content" ]; then
echo "image jupyter sourcecode path check failed!please retry! imageId:$imageId,containerId:${CONTAINER_ID}"
docker stop ${CONTAINER_ID}
fail_image_array+=("${variable}")
continue
else
jupyter_file_path=$(echo "$content" | grep -oP '(?<=is\s)(\/[^ ]+)')
fi
echo "jupyter sourcecode path is :${jupyter_file_path}/static"
file_check=$(docker exec ${CONTAINER_ID} bash -c 'if [ -d "'${jupyter_file_path}'/static" ]; then echo "success"; else echo "failed"; fi')
echo $file_check
if [ "failed" == "$file_check" ]; then
echo "image jupyter sourcecode path check failed!please retry! image:$variable"
docker stop ${CONTAINER_ID}
fail_image_array+=("${variable}")
continue
fi
# 获取index的内容 那去js名 替换
js_content=$(docker exec ${CONTAINER_ID} bash -c "cat '${jupyter_file_path}'/static/index.html ")
echo $js_content
js_path=$(echo "$js_content" | grep -oP '{{page_config\.fullStaticUrl}}/main\.[^"]+\.js\?v=[^"]+' )
js_path2=$(echo "$js_content" | grep -oP '{{page_config\.fullStaticUrl}}/vendors~main\.[^"]+\.js\?v=[^"]+' )
js_path3=$(echo "$js_content" | grep -oP '{{page_config\.fullStaticUrl}}/vendors~main\.[^"]+\.js' )
echo "jupyter js source path is: $js_path"
if [ -z "$js_path" ];then
if [ -z "$js_path2" ];then
if [ -z "$js_path3" ];then
echo "image jupyter sourcecode main js path check failed!please retry! imageId:$imageId,containerId:${CONTAINER_ID}"
docker stop ${CONTAINER_ID}
fail_image_array+=("${variable}")
continue
else
js_path=$js_path3
fi
else
js_path=$js_path2
fi
fi
cat $WORKSPACE/static/index-base.html > $WORKSPACE/static/index.html
sed -i "s#mainJsParam#${js_path}#g" $WORKSPACE/static/index.html
docker cp -a $WORKSPACE/static/index.html ${CONTAINER_ID}:${jupyter_file_path}/static/index.html
docker cp -a $WORKSPACE/static/scnet-loading.gif ${CONTAINER_ID}:${jupyter_file_path}/static/scnet-loading.gif
jupyter_dir=$(docker exec ${CONTAINER_ID} bash -c "whereis jupyter | cat|awk -F':' '{print \$2}'")
echo "image env jupyter cmd path :${jupyter_dir}"
# docker exec ${CONTAINER_ID} bash -c "mkdir -p '/opt/conda/bin/';ln -s ${jupyter_dir} /opt/conda/bin/"
# 卸载之前jupyterlab插件
docker exec ${CONTAINER_ID} bash -c "pip uninstall -r /jupyter-ext/requirements.txt"
# 安装jupyterlab插件
docker exec ${CONTAINER_ID} bash -c "pip install --no-index --find-links=/jupyter-ext -r /jupyter-ext/requirements.txt;if pip list | grep -E 'jupyter_ext_dataset' && pip list | grep -E 'jupyter_ext_logo' && pip list | grep -E 'jupyterlab-language-pack-zh-CN' && [ "$(jupyter lab --version | cut -d. -f1)" -gt 2 ];then echo "安装成功";else echo \"安装失败!! $variable\" | tee /jupyter-ext/errorImages.txt; fi"
# 禁用splash插件
docker exec ${CONTAINER_ID} bash -c "jupyter labextension disable @jupyterlab/apputils-extension:splash"
# 打镜像
docker commit ${CONTAINER_ID} $variable
#重新打镜像标签
# docker tag $imageId $registryAddr$repository:$imageNewTag
# #推送镜像
# docker push $registryAddr$repository:$imageNewTag
# 删除容器及镜像
# docker stop ${CONTAINER_ID}
# docker rm ${CONTAINER_ID}
# docker rmi ${imageId}
# 验证命令
# docker run -it -p8080:8080 --env JUPYTERLAB_WORKSPACES_DIR=/tmp/111 --entrypoint='' f7fa3a053830 /bin/bash
# mkidr -p /opt/conda/bin/;ln -n /usr/bin/jupyter /opt/conda/bin/jupyter ;/opt/conda/bin/jupyter lab --allow-root --ip=0.0.0.0 --port=8080
done
echo "jupyter source code update failed:"
echo $fail_image_array
\ No newline at end of file
This diff is collapsed.
matplotlib
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment