|
| 1 | +# Update Built-in Notebook Images |
| 2 | + |
| 3 | +In the Notebook, multiple available base images are provided by default for developers to choose from. |
| 4 | +In most cases, this will meet the developers' needs. |
| 5 | + |
| 6 | + |
| 7 | + |
| 8 | +DaoCloud provides a default Notebook image that contains all necessary development tools and resources. |
| 9 | + |
| 10 | +```markdown |
| 11 | +baize/baize-notebook |
| 12 | +``` |
| 13 | + |
| 14 | +This Notebook includes basic development tools. Taking `baize-notebook:v0.5.0` (May 30, 2024) as an example, the relevant dependencies and versions are as follows: |
| 15 | + |
| 16 | +| Dependency | Version | Description | |
| 17 | +| ------------- | -------- | --------------------------------------------------------- | |
| 18 | +| Ubuntu | 22.04.3 | Default OS | |
| 19 | +| Python | 3.11.6 | Default Python version | |
| 20 | +| pip | 23.3.1 | | |
| 21 | +| conda(mamba) | 23.3.1 | | |
| 22 | +| jupyterlab | 3.6.6 | JupyterLab image, providing a complete Notebook experience | |
| 23 | +| codeserver | v4.89.1 | Mainstream Code development tool for a familiar experience | |
| 24 | +| *baizectl | v0.5.0 | DaoCloud built-in CLI task management tool | |
| 25 | +| *SSH | - | Supports local SSH direct access to the Notebook container | |
| 26 | +| *kubectl | v1.27 | Kubernetes CLI for managing container resources within Notebook | |
| 27 | + |
| 28 | +!!! note |
| 29 | + |
| 30 | + With each version iteration, DCE 5.0 will proactively maintain and update. |
| 31 | + |
| 32 | +However, sometimes users may need custom images. This page explains how to update images and add them to the Notebook creation interface for selection. |
| 33 | + |
| 34 | +## Build Custom Images (For Reference Only) |
| 35 | + |
| 36 | +!!! note |
| 37 | + |
| 38 | + Building a new image **requires using `baize-notebook` as the base image** to ensure the Notebook runs properly. |
| 39 | + |
| 40 | +When building a custom image, it is recommended to first understand the Dockerfile of |
| 41 | +the baize-notebook image to better understand how to build a custom image. |
| 42 | + |
| 43 | +### Dockerfile for baize-notebook |
| 44 | + |
| 45 | +```dockerfile |
| 46 | +ARG BASE_IMG=docker.m.daocloud.io/kubeflownotebookswg/jupyter:v1.8.0 |
| 47 | + |
| 48 | +FROM $BASE_IMG |
| 49 | + |
| 50 | +USER root |
| 51 | + |
| 52 | +# install - useful linux packages |
| 53 | +RUN export DEBIAN_FRONTEND=noninteractive \ |
| 54 | + && apt-get -yq update \ |
| 55 | + && apt-get -yq install --no-install-recommends \ |
| 56 | + openssh-server git git-lfs bash-completion \ |
| 57 | + && apt-get clean \ |
| 58 | + && rm -rf /var/lib/apt/lists/* |
| 59 | + |
| 60 | +# remove default s6 jupyterlab run script |
| 61 | +RUN rm -rf /etc/services.d/jupyterlab |
| 62 | + |
| 63 | +# install - useful jupyter plugins |
| 64 | +RUN mamba install -n base -y jupyterlab-language-pack-zh-cn \ |
| 65 | + && mamba clean --all -y |
| 66 | + |
| 67 | +ARG CODESERVER_VERSION=4.89.1 |
| 68 | +ARG TARGETARCH |
| 69 | + |
| 70 | +RUN curl -fsSL "https://github.com/coder/code-server/releases/download/v$CODESERVER_VERSION/code-server_${CODESERVER_VERSION}_$TARGETARCH.deb" -o /tmp/code-server.deb \ |
| 71 | + && dpkg -i /tmp/code-server.deb \ |
| 72 | + && rm -f /tmp/code-server.deb |
| 73 | + |
| 74 | +ARG CODESERVER_PYTHON_VERSION=2024.4.1 |
| 75 | +ARG CODESERVER_JUPYTER_VERSION=2024.3.1 |
| 76 | +ARG CODESERVER_LANGUAGE_PACK_ZH_CN=1.89.0 |
| 77 | +ARG CODESERVER_YAML=1.14.0 |
| 78 | +ARG CODESERVER_DOTENV=1.0.1 |
| 79 | +ARG CODESERVER_EDITORCONFIG=0.16.6 |
| 80 | +ARG CODESERVER_TOML=0.19.1 |
| 81 | +ARG CODESERVER_GITLENS=15.0.4 |
| 82 | + |
| 83 | +# configure for code-server extensions |
| 84 | +# # https://github.com/kubeflow/kubeflow/blob/709254159986d2cc99e675d0fad5a128ddeb0917/components/example-notebook-servers/codeserver-python/Dockerfile |
| 85 | +# # and |
| 86 | +# # https://github.com/kubeflow/kubeflow/blob/709254159986d2cc99e675d0fad5a128ddeb0917/components/example-notebook-servers/codeserver/Dockerfile |
| 87 | +RUN code-server --list-extensions --show-versions \ |
| 88 | + && code-server --list-extensions --show-versions \ |
| 89 | + && code-server \ |
| 90 | + --install-extension MS-CEINTL.vscode-language-pack-zh-hans@$CODESERVER_LANGUAGE_PACK_ZH_CN \ |
| 91 | + --install-extension ms-python.python@$CODESERVER_PYTHON_VERSION \ |
| 92 | + --install-extension ms-toolsai.jupyter@$CODESERVER_JUPYTER_VERSION \ |
| 93 | + --install-extension redhat.vscode-yaml@$CODESERVER_YAML \ |
| 94 | + --install-extension mikestead.dotenv@$CODESERVER_DOTENV \ |
| 95 | + --install-extension EditorConfig.EditorConfig@$CODESERVER_EDITORCONFIG \ |
| 96 | + --install-extension tamasfe.even-better-toml@$CODESERVER_TOML \ |
| 97 | + --install-extension eamodio.gitlens@$CODESERVER_GITLENS \ |
| 98 | + --install-extension catppuccin.catppuccin-vsc-pack \ |
| 99 | + --force \ |
| 100 | + && code-server --list-extensions --show-versions |
| 101 | + |
| 102 | +# configure for code-server |
| 103 | +RUN mkdir -p /home/${NB_USER}/.local/share/code-server/User \ |
| 104 | + && chown -R ${NB_USER}:users /home/${NB_USER} \ |
| 105 | + && cat <<EOF > /home/${NB_USER}/.local/share/code-server/User/settings.json |
| 106 | +{ |
| 107 | + "gitlens.showWelcomeOnInstall": false, |
| 108 | + "workbench.colorTheme": "Catppuccin Mocha", |
| 109 | +} |
| 110 | +EOF |
| 111 | + |
| 112 | +RUN mkdir -p /tmp_home/${NB_USER}/.local/share \ |
| 113 | + && mv /home/${NB_USER}/.local/share/code-server /tmp_home/${NB_USER}/.local/share |
| 114 | + |
| 115 | +# set ssh configuration |
| 116 | +RUN mkdir -p /run/sshd \ |
| 117 | + && chown -R ${NB_USER}:users /etc/ssh \ |
| 118 | + && chown -R ${NB_USER}:users /run/sshd \ |
| 119 | + && sed -i "/#\?Port/s/^.*$/Port 2222/g" /etc/ssh/sshd_config \ |
| 120 | + && sed -i "/#\?PasswordAuthentication/s/^.*$/PasswordAuthentication no/g" /etc/ssh/sshd_config \ |
| 121 | + && sed -i "/#\?PubkeyAuthentication/s/^.*$/PubkeyAuthentication yes/g" /etc/ssh/sshd_config \ |
| 122 | + && rclone_version=v1.65.0 && \ |
| 123 | + arch=$(uname -m | sed -E 's/x86_64/amd64/g;s/aarch64/arm64/g') && \ |
| 124 | + filename=rclone-${rclone_version}-linux-${arch} && \ |
| 125 | + curl -fsSL https://github.com/rclone/rclone/releases/download/${rclone_version}/${filename}.zip -o ${filename}.zip && \ |
| 126 | + unzip ${filename}.zip && mv ${filename}/rclone /usr/local/bin && rm -rf ${filename} ${filename}.zip |
| 127 | + |
| 128 | +# Init mamba |
| 129 | +RUN mamba init --system |
| 130 | + |
| 131 | +# init baize-base environment for essential python packages |
| 132 | +RUN mamba create -n baize-base -y python \ |
| 133 | + && /opt/conda/envs/baize-base/bin/pip install tensorboard \ |
| 134 | + && mamba clean --all -y \ |
| 135 | + && ln -s /opt/conda/envs/baize-base/bin/tensorboard /usr/local/bin/tensorboard |
| 136 | + |
| 137 | +# prepare baize-runtime-env directory |
| 138 | +RUN mkdir -p /opt/baize-runtime-env \ |
| 139 | + && chown -R ${NB_USER}:users /opt/baize-runtime-env |
| 140 | + |
| 141 | +ARG APP |
| 142 | +ARG PROD_NAME |
| 143 | +ARG TARGETOS |
| 144 | + |
| 145 | +COPY out/$TARGETOS/$TARGETARCH/data-loader /usr/local/bin/ |
| 146 | +COPY out/$TARGETOS/$TARGETARCH/baizectl /usr/local/bin/ |
| 147 | + |
| 148 | +RUN chmod +x /usr/local/bin/baizectl /usr/local/bin/data-loader && \ |
| 149 | + echo "source /etc/bash_completion" >> /opt/conda/etc/profile.d/conda.sh && \ |
| 150 | + echo "source <(baizectl completion bash)" >> /opt/conda/etc/profile.d/conda.sh && \ |
| 151 | + echo "source <(kubectl completion bash)" >> /opt/conda/etc/profile.d/conda.sh && \ |
| 152 | + echo '[ -f /run/baize-env ] && export $(cat /run/baize-env | xargs)' >> /opt/conda/etc/profile.d/conda.sh && \ |
| 153 | + echo 'alias conda="mamba"' >> /opt/conda/etc/profile.d/conda.sh |
| 154 | + |
| 155 | +USER ${NB_UID} |
| 156 | +``` |
| 157 | + |
| 158 | +### Build Your Image |
| 159 | + |
| 160 | +```dockerfile |
| 161 | +ARG BASE_IMG=release.daocloud.io/baize/baize-notebook:v0.5.0 |
| 162 | + |
| 163 | +FROM $BASE_IMG |
| 164 | +USER root |
| 165 | + |
| 166 | +# Do Customization |
| 167 | +RUN mamba install -n baize-base -y pytorch torchvision torchaudio cpuonly -c pytorch \ |
| 168 | + && mamba install -n baize-base -y tensorflow \ |
| 169 | + && mamba clean --all -y |
| 170 | + |
| 171 | +USER ${NB_UID} |
| 172 | +``` |
| 173 | + |
| 174 | +## Add to the Notebook Image List (Helm) |
| 175 | + |
| 176 | +!!! warning |
| 177 | + |
| 178 | + Note that this must be done by the platform administrator. Be cautious with changes. |
| 179 | + |
| 180 | +Currently, the image selector needs to be modified by updating the `Helm` parameters of `baize`. The specific steps are as follows: |
| 181 | + |
| 182 | +In the `Helm Applications` list of the kpanda-global-cluster global management cluster, |
| 183 | +find baize, enter the update page, and modify the Notebook image in the `YAML` parameters: |
| 184 | + |
| 185 | + |
| 186 | + |
| 187 | +Note the parameter modification path `global.config.notebook_images`: |
| 188 | + |
| 189 | +```yaml |
| 190 | +... |
| 191 | +global: |
| 192 | + ... |
| 193 | + config: |
| 194 | + notebook_images: |
| 195 | + ... |
| 196 | + names: release.daocloud.io/baize/baize-notebook:v0.5.0 |
| 197 | + # Add your image information here |
| 198 | +``` |
| 199 | + |
| 200 | +After the update is completed and the Helm application restarts successfully, |
| 201 | +you can see the new image in the Notebook creation interface image selection. |
0 commit comments