50 lines
2.0 KiB
Docker
50 lines
2.0 KiB
Docker
FROM debian:bullseye
|
|
ARG CREATE_USER="jovyan"
|
|
ARG CREATE_USER_PASSWD="password"
|
|
ARG ROOT_PASSWD="password"
|
|
ARG HOME="/home/${CREATE_USER}"
|
|
ARG DEBIAN_FRONTEND="noninteractive"
|
|
ENV DEBIAN_FRONTEND=${DEBIAN_FRONTEND}
|
|
|
|
RUN <<EOT
|
|
#!/bin/bash
|
|
# 更新软件源
|
|
apt-get update
|
|
|
|
# 安装时区数据包并设置时区
|
|
apt-get install -y tzdata
|
|
ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
|
|
echo 'Asia/Shanghai' > /etc/timezone
|
|
dpkg-reconfigure -f noninteractive tzdata
|
|
|
|
# 安装所需的软件包
|
|
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
|
|
|
|
# 配置 SSH
|
|
mkdir -p /var/run/sshd
|
|
mkdir -p /root/.ssh
|
|
echo "root:${ROOT_PASSWD}" | chpasswd
|
|
sed -ri 's/^#?PermitRootLogin\s+.*/PermitRootLogin yes/' /etc/ssh/sshd_config
|
|
sed -ri 's/^UsePAM\s+yes/UsePAM no/' /etc/ssh/sshd_config
|
|
|
|
# 创建新用户
|
|
useradd -m -s /bin/bash ${CREATE_USER}
|
|
echo "${CREATE_USER}:${CREATE_USER_PASSWD}" | chpasswd
|
|
echo "${CREATE_USER} ALL=(ALL:ALL) NOPASSWD:ALL" >> /etc/sudoers
|
|
|
|
# 安装 Jupyter 和相关软件
|
|
npm install -g configurable-http-proxy
|
|
python3 -m pip3 install jupyterhub jupyterlab notebook 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 lckr_jupyterlab_variableinspector
|
|
|
|
# 清理和减小镜像大小
|
|
apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /usr/share/man/?? /usr/share/man/??_*
|
|
|
|
# 创建 JupyterHub 配置目录
|
|
mkdir -p /root/.jupyterhub
|
|
EOT
|
|
|
|
COPY jupyterhub_config.py /root/.jupyterhub
|
|
EXPOSE 9000
|
|
|
|
# ENTRYPOINT [ "jupyterhub", "-f", "/root/.jupyterhub/jupyterhub_config.py"]
|