Skip to content

Update jupyter version #1130

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 3 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
109 changes: 0 additions & 109 deletions resources/apt_upgrade_images.sh

This file was deleted.

52 changes: 52 additions & 0 deletions resources/build_base_images.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#!/usr/bin/env bash
# Copyright 2025 CS Group
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# Build the base Docker images that are used in the cluster and in the ci/cd.

set -euo pipefail
#set -x

SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
BUILD_DIR="$(realpath $SCRIPT_DIR/build_base_images)"

# For each dockerfile and associated docker image name, separated by a ;
for params in \
"Dockerfile.python;python:3.11.7-slim-bookworm" \
"Dockerfile.jupyter;quay.io/jupyter/base-notebook:hub-5.2.1"
do
dockerfile=$(echo $params | cut -d ";" -f 1)
base=$(echo $params | cut -d ";" -f 2)

# Add our hosting github organization to the docker image
target="ghcr.io/rs-python/$base"

# Build the docker image
docker build \
--build-arg BASE=${base} \
--build-arg DASK_TAG=2024.5.2 \
--build-arg DASK_GATEWAY_TAG=2024.1.0 \
--build-arg PREFECT_TAG=3.2.13 \
--build-arg PREFECT_DASK_TAG=0.3.3 \
--progress plain \
-f "${BUILD_DIR}/${dockerfile}" \
-t "$target" \
"${BUILD_DIR}"

# Push the docker image to the registry, if the --push option is specified.
if [[ " $@ " == *" --push "* ]]; then
docker login https://ghcr.io/v2/rs-python
docker push "$target"
fi
done
89 changes: 89 additions & 0 deletions resources/build_base_images/Dockerfile.jupyter
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
#!/usr/bin/env bash
# Copyright 2025 CS Group
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# quay.io/jupyter/base-notebook:<tag>
ARG BASE=xxx
FROM ${BASE}

ENV PATH=/home/jovyan/.local/bin:${PATH}

ARG DASK_TAG=xxx
ARG DASK_GATEWAY_TAG=xxx
ARG PREFECT_TAG=xxx
ARG PREFECT_DASK_TAG=xxx

COPY ./layer-cleanup.sh /usr/local/bin/

USER root
RUN chmod 755 /usr/local/bin/layer-cleanup.sh
RUN apt update && apt upgrade -y && layer-cleanup.sh
USER jovyan

# Upgrade pip version
RUN pip install -U pip && layer-cleanup.sh

# Additional python kernel to install to run the notebooks
ARG PYTHON_VERSION=3.11.7
ARG KERNEL_NAME=py3.11.7

# Install additional python kernel
RUN conda create -y -n "$KERNEL_NAME" python="$PYTHON_VERSION" && \
source activate "$KERNEL_NAME" && \
python -V && \
pip install -U pip && \
pip install ipykernel && \
layer-cleanup.sh
USER root
RUN source activate "$KERNEL_NAME" && \
python -m ipykernel install --name "$KERNEL_NAME" --display-name "$KERNEL_NAME" && \
layer-cleanup.sh
USER jovyan

# Set default kernel... does not seem to work
RUN jupyter notebook --generate-config && \
layer-cleanup.sh && \
echo "c.MappingKernelManager.default_kernel_name='$KERNEL_NAME'" >> /home/jovyan/.jupyter/jupyter_notebook_config.py

# Note: put s3fs before boto3 to have a recent version
RUN source activate "$KERNEL_NAME" && \
pip install \
dask[complete]=="${DASK_TAG}" \
distributed=="${DASK_TAG}" \
dask-gateway=="${DASK_GATEWAY_TAG}" \
prefect[aws]=="${PREFECT_TAG}" \
prefect-dask=="${PREFECT_DASK_TAG}" \
ipywidgets \
s3fs \
boto3 && \
layer-cleanup.sh

# Install dot and clean conda
USER root
RUN apt update && apt install -y python3-pydot graphviz && layer-cleanup.sh
USER jovyan

# Use default python version from bash session
RUN echo -e "\nsource activate $KERNEL_NAME" >> /home/jovyan/.bashrc

USER root
RUN chown -R jovyan /home/jovyan
USER jovyan

# Set labels based on the Open Containers Initiative (OCI):
# https://github.com/opencontainers/image-spec/blob/main/annotations.md#pre-defined-annotation-keys
#
LABEL org.opencontainers.image.source="https://github.com/RS-PYTHON/rs-server"
LABEL org.opencontainers.image.ref.name="ghcr.io/rs-python/quay.io/jupyter/base-notebook:hub-5.2.1"
LABEL dockerfile.url="https://github.com/RS-PYTHON/rs-server/blob/develop/resources/build_base_images/Dockerfile.jupyter.k8s"
32 changes: 32 additions & 0 deletions resources/build_base_images/Dockerfile.python
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/usr/bin/env bash
# Copyright 2025 CS Group
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# python:<tag>
ARG BASE=xxx
FROM ${BASE}
RUN apt update && apt upgrade -y

# Upgrade pip version
RUN pip install -U pip

# Note: don't remove cache so the child images that use this one as a base will build faster
# RUN rm -rf /var/cache/apt/archives /var/lib/apt/lists/*

# Set labels based on the Open Containers Initiative (OCI):
# https://github.com/opencontainers/image-spec/blob/main/annotations.md#pre-defined-annotation-keys
#
LABEL org.opencontainers.image.source="https://github.com/RS-PYTHON/rs-server"
LABEL org.opencontainers.image.ref.name="ghcr.io/rs-python/python:3.11.7-slim-bookworm"
LABEL dockerfile.url="https://github.com/RS-PYTHON/rs-server/blob/develop/resources/build_base_images/Dockerfile.python"
34 changes: 34 additions & 0 deletions resources/build_base_images/layer-cleanup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/bin/bash
# Copyright 2024 CS Group
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

apt-get autoclean --yes
apt-get autoremove --yes

rm -rf /var/lib/apt/lists/*
# rm -rf /etc/apt/sources.list.d/* # don't remove the repo list
rm -rf /usr/local/src/*

rm -rf /var/cache/apt/*
rm -rf /root/.cache/*
rm -rf /home/*/.cache/*
# including /root/.cache/pip
rm -rf /usr/local/share/.cache/*
# including /usr/local/share/.cache/yarn

rm -rf /tmp/* /var/tmp/*

conda clean --all --yes

exit 0
2 changes: 1 addition & 1 deletion resources/update_dask_eopf_prefect.sh
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ all_files+=($e $f)

# [local mode] [cluster mode] [jupyter base image]
# [ghcr.io/rs-python/jupyter/minimal-notebook] [ghcr.io/rs-python/quay.io/jupyter/base-notebook]
g=$(_realpath rs-server/resources/apt_upgrade_images.sh) # + re-run with --push
g=$(_realpath rs-server/resources/build_base_images.sh) # + re-run with --push
all_files+=($g)

# [local mode] [jupyter with rs-client-libraries] [ghcr.io/rs-python/jupyter/rs-client-libraries/local]
Expand Down