change nodejs to 18 and all install nglview

This commit is contained in:
2024-05-26 23:52:38 +08:00
parent 03e1542842
commit 25f494b3a8
3 changed files with 46 additions and 21 deletions

View File

@@ -8,6 +8,8 @@ ARG ROOT_PASSWD="password"
ARG HOME="/home/${CREATE_USER}"
ARG DEBIAN_FRONTEND="noninteractive"
ENV DEBIAN_FRONTEND=${DEBIAN_FRONTEND}
ARG NODEJS_VERSION='18'
ENV NODEJS_VERSION=${NODEJS_VERSION}
USER root
RUN <<EOT
@@ -19,6 +21,8 @@ apt-get install -y tzdata
ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
echo 'Asia/Shanghai' > /etc/timezone
dpkg-reconfigure -f noninteractive tzdata
sudo apt-get remove --purge libnode72:amd64 -y
curl -fsSL https://deb.nodesource.com/setup_${NODEJS_VERSION}.x | sudo -E bash -
# 安装所需的软件包
apt-get install -y python3 python3-pip gcc g++ build-essential nodejs npm gdebi-core curl wget openssh-server vim lrzsz net-tools sudo git
# 创建新用户
@@ -30,8 +34,20 @@ EOT
RUN <<EOT
#!/bin/bash
# 安装 Jupyter 和相关软件
npm install -g configurable-http-proxy
python3 -m pip install jupyterhub jupyterlab notebook radian pycurl jupyter-rsession-proxy ipykernel jupyterlab-language-pack-zh-CN jupyterlab-git jupyterlab-system-monitor jupyter_nbextensions_configurator jupyter_contrib_nbextensions jupyterlab-unfold jupyterlab_widgets jupyterlab-drawio jupyterlab-spreadsheet-editor jupyterlab-cell-flash jedi-language-server jupyterlab_code_formatter jupyterlab-spellchecker jupyterlab_vim nbresuse ipydrawio jedi ipympl black isort theme-darcula ipywidgets tensorboard jupyterlab_latex jupyter_bokeh autopep8 xeus-python jupyterlab-lsp python-lsp-server nglview dockerspawner jupyterhub-nativeauthenticator lckr_jupyterlab_variableinspector
npm install -g configurable-http-proxy yarn --registry=https://registry.npmmirror.com
python3 -m pip install ipython jupyter_packaging jupyterhub jupyterlab notebook radian pycurl jupyter-rsession-proxy ipykernel jupyterlab-language-pack-zh-CN jupyterlab-git jupyterlab-system-monitor jupyter_nbextensions_configurator jupyter_contrib_nbextensions jupyterlab-unfold jupyterlab_widgets jupyterlab-drawio jupyterlab-spreadsheet-editor jupyterlab-cell-flash jedi-language-server jupyterlab_code_formatter jupyterlab-spellchecker jupyterlab_vim nbresuse ipydrawio jedi ipympl black isort theme-darcula ipywidgets tensorboard jupyterlab_latex jupyter_bokeh autopep8 xeus-python jupyterlab-lsp python-lsp-server nglview dockerspawner jupyterhub-nativeauthenticator lckr_jupyterlab_variableinspector
git clone https://ghproxy.dockless.eu.org/https://github.com/arose/nglview
cd nglview
python3 setup.py install
cd js
rm -rf node_modules package-lock.json
npm install typescript@latest --registry=https://registry.npmmirror.com
npm install --registry=https://registry.npmmirror.com
cd ../..
python -m ipykernel install --sys-prefix
jupyter nbextension enable --py --sys-prefix widgetsnbextension
jupyter nbextension enable --py --sys-prefix nglview
jupyter-nbextension enable nglview --py --sys-prefix
# 创建 JupyterHub 配置目录
mkdir -p /root/.jupyterhub
EOT
@@ -52,22 +68,9 @@ sudo wget "https://download2.rstudio.org/server/$(lsb_release -cs)/amd64/rstudio
sudo chmod +x /tmp/rstudio-server.deb
sudo gdebi -n /tmp/rstudio-server.deb
sudo rm -rf /tmp/rstudio-server.deb
EOT
RUN <<EOT
#!/bin/bash
# 安装micromamba
echo "1" | bash <(curl -s https://raw.githubusercontent.com/hotwa/MicroMamba_Installer/main/install.sh)
mkdir -p /root/workspace/personal /root/workspace/project
EOT
RUN <<EOT
#!/bin/bash
# 清理和减小镜像大小
apt-get clean
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /usr/share/man/?? /usr/share/man/??_*
EOT
CMD ["jupyterhub", "-f", "/srv/jupyterhub/jupyterhub_config.py"]

View File

@@ -10,6 +10,19 @@ c = get_config() # noqa: F821
# avoid having to rebuild the JupyterHub container every time we change a
# configuration parameter.
# from dockerspawner import DockerSpawner
# class MyDockerSpawner(DockerSpawner):
# def start(self):
# # 启动父类的start方法
# self.user_options['environment']['JUPYTER_ENABLE_NBEXTENSIONS'] = 'true'
# self.user_options['cmd'] = [
# 'bash',
# '-c',
# 'pip install nglview jupyter_packaging -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com && jupyter nbextension enable nglview --py --sys-prefix && jupyter labextension install nglview-js-widgets && jupyter labextension install @jupyter-widgets/jupyterlab-manager && start-singleuser.sh'
# ]
# return super().start()
# Spawn single-user servers as Docker containers
c.JupyterHub.spawner_class = "dockerspawner.DockerSpawner"

View File

@@ -78,6 +78,8 @@ ARG ROOT_PASSWD="password"
ARG HOME="/home/${CREATE_USER}"
ARG DEBIAN_FRONTEND="noninteractive"
ENV DEBIAN_FRONTEND=${DEBIAN_FRONTEND}
ARG NODEJS_VERSION='18'
ENV NODEJS_VERSION=${NODEJS_VERSION}
COPY install.sh /tmp
RUN <<EOT
@@ -90,7 +92,10 @@ ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
echo 'Asia/Shanghai' > /etc/timezone
dpkg-reconfigure -f noninteractive tzdata
# 安装所需的软件包
sudo apt-get remove --purge libnode72:amd64 -y
curl -fsSL https://deb.nodesource.com/setup_${NODEJS_VERSION}.x | sudo -E bash -
apt-get install -y python3 python3-pip gcc g++ build-essential nodejs npm gdebi-core curl wget openssh-server vim lrzsz net-tools sudo git nodejs
npm install -g configurable-http-proxy yarn --registry=https://registry.npmmirror.com
# 创建新用户
useradd -m -s /bin/bash ${CREATE_USER}
echo "${CREATE_USER}:${CREATE_USER_PASSWD}" | chpasswd
@@ -100,11 +105,7 @@ EOT
# 安装 Jupyter 和相关软件
RUN <<EOT
#!/bin/bash
npm install -g configurable-http-proxy
git clone https://github.com/arose/nglview
cd nglview
python setup.py install
cd ..
python3 -m pip install ipython jupyterhub jupyterlab notebook jupyter_packaging -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com
python3 -m pip install aiohttp -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com
python3 -m pip install jupyterhub jupyterlab notebook radian pycurl aiohttp jupyter-rsession-proxy ipykernel>=6.25.0 jupyterlab-language-pack-zh-CN jupyterlab-git jupyterlab-system-monitor jupyter_nbextensions_configurator jupyter_contrib_nbextensions jupyterlab_widgets jupyterlab-drawio jupyterlab-spreadsheet-editor jupyterlab-cell-flash jedi-language-server jupyterlab_code_formatter jupyterlab-spellchecker jupyterlab_vim nbresuse ipydrawio jedi ipympl black isort theme-darcula ipywidgets tensorboard jupyterlab_latex jupyter_bokeh autopep8 xeus-python jupyterlab-lsp python-lsp-server dockerspawner jupyterhub-nativeauthenticator lckr_jupyterlab_variableinspector -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com
EOT
@@ -178,8 +179,16 @@ RUN <<EOT
#!/bin/bash
sudo apt update
sudo apt install -y texlive-full
mamba create -n torch pytorch torchvision torchaudio python=3 ipython nglview requests scienceplots autopep8 ipykernel\
mamba create -n torch jupyter_packaging pytorch biopython biopandas pymol-open-source mdtraj torchvision torchaudio python=3 ipython requests scienceplots autopep8 ipykernel\
pandas numpy matplotlib scipy seaborn orange3 -c pytorch -c nvidia -c conda-forge -y
git clone https://ghproxy.dockless.eu.org/https://github.com/arose/nglview
cd nglview
mamba run -n torch python3 setup.py install
cd js
rm -rf node_modules package-lock.json
npm install typescript@latest --registry=https://registry.npmmirror.com
npm install --registry=https://registry.npmmirror.com
cd ../..
mamba run -n torch python -m ipykernel install --user --name="torch" --display-name="torch_env"
EOT