diff --git a/.github/workflows/docker-icl-jupyterhub.yaml b/.github/workflows/docker-icl-jupyterhub.yaml index 2537407..303d600 100644 --- a/.github/workflows/docker-icl-jupyterhub.yaml +++ b/.github/workflows/docker-icl-jupyterhub.yaml @@ -7,7 +7,7 @@ on: type: string description: Image tag required: true - default: 0.0.22 + default: 0.0.23 push: description: Push image to DockerHub required: true diff --git a/docker/icl-jupyterhub-triton/Dockerfile b/docker/icl-jupyterhub-triton/Dockerfile index 8a058e3..bf62960 100644 --- a/docker/icl-jupyterhub-triton/Dockerfile +++ b/docker/icl-jupyterhub-triton/Dockerfile @@ -1,6 +1,6 @@ ARG BASE_TAG -FROM pbchekin/icl-jupyterhub:0.0.22 +FROM pbchekin/icl-jupyterhub:0.0.23 USER root diff --git a/docker/icl-jupyterhub/Dockerfile b/docker/icl-jupyterhub/Dockerfile index 03b7ad0..873663c 100644 --- a/docker/icl-jupyterhub/Dockerfile +++ b/docker/icl-jupyterhub/Dockerfile @@ -11,6 +11,8 @@ RUN set -ex; \ python -m build RUN set -ex; \ + # python:3.12 images do not include setuptools and wheel, required for "setup.py bdist_wheel" + pip install setuptools wheel; \ git clone https://github.com/dirkcgrunwald/jupyter_codeserver_proxy-.git; \ cd jupyter_codeserver_proxy-; \ make build-package diff --git a/docker/icl-jupyterhub/entrypoint.sh b/docker/icl-jupyterhub/entrypoint.sh index a2dc373..ef25497 100644 --- a/docker/icl-jupyterhub/entrypoint.sh +++ b/docker/icl-jupyterhub/entrypoint.sh @@ -16,6 +16,18 @@ cd ~ if [[ ! -d $conda_prefix ]]; then echo "$conda_prefix does not exists, copying from /template" tar x -Ipixz -f /template/conda.tar.xz +elif [[ ! -d $conda_prefix/envs/$kernel_env ]]; then + # The existing conda prefix was created by an older image and does not have + # the expected kernel environment: back it up and copy a new one from /template. + conda_backup=$HOME/.conda.bak.$(date +%Y%m%d%H%M%S) + echo "$conda_prefix does not have environment $kernel_env, moving it to $conda_backup and copying from /template" + mv $conda_prefix $conda_backup + tar x -Ipixz -f /template/conda.tar.xz + # .profile may activate an environment that only exists in the old prefix + if [[ -f ~/.profile ]]; then + sed -i "s/^conda activate python-3\..*/conda activate $kernel_env/" ~/.profile + fi + unset conda_backup fi if [[ ! -f ~/.profile ]]; then @@ -39,13 +51,15 @@ if [[ ! -f ~/.jupyter/jupyter_config.json ]]; then } } EOF +fi - # Use environment name for display_name - kernel_json=$conda_prefix/envs/$kernel_env/share/jupyter/kernels/python3/kernel.json +# Use environment name for display_name +kernel_json=$conda_prefix/envs/$kernel_env/share/jupyter/kernels/python3/kernel.json +if [[ -f $kernel_json ]]; then jq ".display_name = \"$kernel_env\"" $kernel_json > /tmp/kernel.json mv /tmp/kernel.json $kernel_json - unset kernel_json fi +unset kernel_json source $conda_prefix/etc/profile.d/conda.sh conda activate $jupyterlab_env diff --git a/docker/icl-jupyterhub/readme.md b/docker/icl-jupyterhub/readme.md index 082289a..ae6959f 100644 --- a/docker/icl-jupyterhub/readme.md +++ b/docker/icl-jupyterhub/readme.md @@ -3,21 +3,15 @@ Overview conda-based passwordless sudo, potentially can be disabled later additional packages installed (gh cli, ssh, vim, rsync, s3cmd) -Modin, Prefect, Ray, ICL +ICL (infractl) with Prefect 3.x in the python-3.12 kernel environment, built from the repository sources Build and push the image -TARGET_TAG=pbchekin/icl-jupyterhub:latest -MODIN_VERSION="0.26.1" -PREFECT_VERSION="2.13.0" -RAY_VERSION="2.9.2" +TARGET_TAG=pbchekin/icl-jupyterhub:0.0.23 Needs to be run from the root of the repository: docker build . \ --file docker/icl-jupyterhub/Dockerfile \ --progress=plain \ - --tag $TARGET_TAG \ - --build-arg PREFECT_VERSION="$PREFECT_VERSION" \ - --build-arg MODIN_VERSION="$MODIN_VERSION" \ - --build-arg RAY_VERSION="$RAY_VERSION" + --tag $TARGET_TAG docker push $TARGET_TAG Create custom JupyterLab kernel In Terminal, create a new conda environment and install ipykernel. diff --git a/scripts/deploy/kind.sh b/scripts/deploy/kind.sh index 30a2e54..839ee62 100755 --- a/scripts/deploy/kind.sh +++ b/scripts/deploy/kind.sh @@ -448,6 +448,12 @@ if [[ " $@ " =~ " --with-cert-manager " ]]; then terraform_extra_args+=( -var cert_manager_enabled=true ) fi +# Use a custom JupyterHub single-user image, for example a locally built one +# loaded into the kind cluster with "kind load docker-image --name x1". +if [[ -n "${ICL_JUPYTERHUB_IMAGE:-}" ]]; then + terraform_extra_args+=( -var jupyterhub_singleuser_default_image="$ICL_JUPYTERHUB_IMAGE" ) +fi + with_corefile control_node "terraform -chdir=terraform/icl init -upgrade -input=false && terraform -chdir=terraform/icl apply -input=false -auto-approve ${terraform_extra_args[*]}" diff --git a/scripts/etc/kind/images.txt b/scripts/etc/kind/images.txt index df0eac5..6e75950 100644 --- a/scripts/etc/kind/images.txt +++ b/scripts/etc/kind/images.txt @@ -15,7 +15,7 @@ kuberay/operator:v0.4.0 kubernetesui/dashboard:v2.6.0 minio/console:v0.20.3 minio/operator:v4.5.1 -pbchekin/icl-jupyterhub:0.0.18 +pbchekin/icl-jupyterhub:0.0.23 pbchekin/icl-prefect:3.6.17-py3.12-icl0.0.4 pbchekin/icl-ray:2.9.2-py312 prefecthq/prefect:3.6.17-python3.12 diff --git a/terraform/icl/variables.tf b/terraform/icl/variables.tf index 05844b6..f85210c 100644 --- a/terraform/icl/variables.tf +++ b/terraform/icl/variables.tf @@ -217,7 +217,7 @@ variable "jupyterhub_singleuser_volume_size" { variable "jupyterhub_singleuser_default_image" { description = "Default Docker image for JupyterHub default profile" # original image: jupyterhub/k8s-singleuser-sample:2.0.1-0.dev.git.6035.h643c0f0c - default = "pbchekin/icl-jupyterhub:0.0.22" + default = "pbchekin/icl-jupyterhub:0.0.23" type = string }