This is an automated email from the ASF dual-hosted git repository. yasith pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/airavata.git
commit 38173a16bad64457bf861f9bea12ba9eb844c478 Author: yasithdev <[email protected]> AuthorDate: Wed Jul 16 04:25:40 2025 -0500 cleanup research-hub scripts, move git clone step to post-init phase. --- .../research-hub/{compose => }/Dockerfile | 13 ++--- .../research-hub/compose/user-container/Dockerfile | 13 ----- .../compose/user-container/bootstrap.sh | 1 - .../compose/user-container/build-container.sh | 2 - .../{compose => }/custom_templates/login.html | 0 .../research-hub/{compose => }/docker-compose.yaml | 6 +-- .../{compose => }/jupyterhub_config.py | 55 ++++++++++------------ .../research-hub/user-container/Dockerfile | 12 +++++ .../research-hub/user-container/Makefile | 3 ++ .../{compose => }/user-container/init.sh | 0 10 files changed, 46 insertions(+), 59 deletions(-) diff --git a/modules/research-framework/research-hub/compose/Dockerfile b/modules/research-framework/research-hub/Dockerfile similarity index 53% rename from modules/research-framework/research-hub/compose/Dockerfile rename to modules/research-framework/research-hub/Dockerfile index 16acfa9aae..d0f9300781 100644 --- a/modules/research-framework/research-hub/compose/Dockerfile +++ b/modules/research-framework/research-hub/Dockerfile @@ -1,18 +1,11 @@ -FROM jupyterhub/jupyterhub:3.0 - -RUN pip install oauthenticator requests pyjwt dockerspawner jupyterhub-idle-culler -RUN apt-get update && \ - apt-get install -y git && \ - pip install oauthenticator requests pyjwt dockerspawner jupyterhub-idle-culler ipywidgets +FROM jupyterhub/jupyterhub:latest +RUN apt-get update && apt-get install -y git && rm -rf /var/lib/apt/lists/* +RUN pip install oauthenticator requests pyjwt dockerspawner jupyterhub-idle-culler ipywidgets COPY jupyterhub_config.py /srv/jupyterhub/jupyterhub_config.py - COPY custom_templates /srv/jupyterhub/custom_templates -RUN mkdir -p /home/jovyan/notebooks && \ - chown -R 1000:100 /home/jovyan/notebooks - ENV JUPYTERHUB_CONFIG=/srv/jupyterhub/jupyterhub_config.py ENV PYTHONPATH=/srv/jupyterhub diff --git a/modules/research-framework/research-hub/compose/user-container/Dockerfile b/modules/research-framework/research-hub/compose/user-container/Dockerfile deleted file mode 100644 index 9a193e0dd5..0000000000 --- a/modules/research-framework/research-hub/compose/user-container/Dockerfile +++ /dev/null @@ -1,13 +0,0 @@ -FROM jupyter/base-notebook:latest - -COPY init.sh /usr/local/bin/init.sh - -USER root -RUN chmod +x /usr/local/bin/init.sh -RUN apt-get update && apt-get install -y git - -USER $NB_USER -RUN pip install ipywidgets jupyterlab-git - -ENTRYPOINT ["/usr/local/bin/init.sh"] -CMD ["start-notebook.py"] \ No newline at end of file diff --git a/modules/research-framework/research-hub/compose/user-container/bootstrap.sh b/modules/research-framework/research-hub/compose/user-container/bootstrap.sh deleted file mode 100644 index b4ae3f6ed5..0000000000 --- a/modules/research-framework/research-hub/compose/user-container/bootstrap.sh +++ /dev/null @@ -1 +0,0 @@ -jupyter lab --config=/jupyter_lab_config.py --ip=0.0.0.0 --port=8888 --no-browser --allow-root --NotebookApp.token='' \ No newline at end of file diff --git a/modules/research-framework/research-hub/compose/user-container/build-container.sh b/modules/research-framework/research-hub/compose/user-container/build-container.sh deleted file mode 100755 index 4270dc6676..0000000000 --- a/modules/research-framework/research-hub/compose/user-container/build-container.sh +++ /dev/null @@ -1,2 +0,0 @@ -docker build --platform linux/x86_64 -t cybershuttle/jupyterlab-base . -docker push cybershuttle/jupyterlab-base \ No newline at end of file diff --git a/modules/research-framework/research-hub/compose/custom_templates/login.html b/modules/research-framework/research-hub/custom_templates/login.html similarity index 100% rename from modules/research-framework/research-hub/compose/custom_templates/login.html rename to modules/research-framework/research-hub/custom_templates/login.html diff --git a/modules/research-framework/research-hub/compose/docker-compose.yaml b/modules/research-framework/research-hub/docker-compose.yaml similarity index 81% rename from modules/research-framework/research-hub/compose/docker-compose.yaml rename to modules/research-framework/research-hub/docker-compose.yaml index a8a5c66400..568cf97028 100644 --- a/modules/research-framework/research-hub/compose/docker-compose.yaml +++ b/modules/research-framework/research-hub/docker-compose.yaml @@ -1,10 +1,9 @@ -version: "3.8" services: jupyterhub: build: . - container_name: jupyterhub-sample + container_name: jupyterhub ports: - - "8000:8000" + - "8000:20000" environment: OAUTH_CLIENT_ID: "cs-jupyterlab" OAUTH_CLIENT_SECRET: "DxeMtfiWU1qkDEmaGHf13RDahCujzhy1" @@ -14,6 +13,7 @@ services: volumes: - ./jupyterlab:/home/jovyan - ./jupyterhub_config.py:/srv/jupyterhub/jupyterhub_config.py + - ./custom_templates:/srv/jupyterhub/custom_templates - /var/run/docker.sock:/var/run/docker.sock restart: always networks: diff --git a/modules/research-framework/research-hub/compose/jupyterhub_config.py b/modules/research-framework/research-hub/jupyterhub_config.py similarity index 75% rename from modules/research-framework/research-hub/compose/jupyterhub_config.py rename to modules/research-framework/research-hub/jupyterhub_config.py index aff309a301..23f288949b 100644 --- a/modules/research-framework/research-hub/compose/jupyterhub_config.py +++ b/modules/research-framework/research-hub/jupyterhub_config.py @@ -3,6 +3,9 @@ import re import sys from dockerspawner import DockerSpawner from oauthenticator.generic import GenericOAuthenticator +from traitlets.config import Config + +c: Config # Authenticator Configuration c.JupyterHub.authenticator_class = GenericOAuthenticator @@ -48,39 +51,31 @@ class CustomDockerSpawner(DockerSpawner): # Create a unique volume name keyed by (username + servername). # If the user spawns again with the same (servername), it will reuse the same volume. safe_user = self.sanitize_name(self.user.name) - safe_srv = self.sanitize_name(self.name) or "default" - - volumes_dict = {} - - git_url = self.user_options.get("git") + safe_srv = self.sanitize_name(self.name or "default") + reference_git_url = "https://github.com/cyber-shuttle/cybershuttle-reference.git" + git_url = self.user_options.get("git") or reference_git_url data_subfolders = self.user_options.get("dataPath", []) print("THE DATA PATH IS: ", data_subfolders) - if git_url or data_subfolders: - vol_name = f"jupyterhub-vol-{safe_user}-{safe_srv}" - volumes_dict[vol_name] = "/home/jovyan/work" - - # If one or more data subfolders are provided, mount them all read-only. - for subfolder in data_subfolders: - host_data_path = os.path.expandvars("$HOME/mnt/{subfolder}") - container_path = f"/cybershuttle_data/{subfolder}" - volumes_dict[host_data_path] = { - 'bind': container_path, - 'mode': 'ro' - } - self.image = "cybershuttle/jupyterlab-base" # TODO using ENV variable - else: - # Sample mode - vol_name = f"jupyterhub-vol-{safe_user}-default-jupyterlab-base" - volumes_dict[vol_name] = "/home/jovyan/work" - self.image = "cybershuttle/jupyterlab-base-sample" # TODO using ENV variable - - self.volumes = volumes_dict - - if git_url: - if not hasattr(self, "environment"): - self.environment = {} - self.environment["GIT_URL"] = git_url + self.image = "cybershuttle/jupyterlab-base" + if not hasattr(self, "environment"): + self.environment = {} + self.environment["GIT_URL"] = git_url + self.post_start_cmd = "/usr/local/bin/init.sh" + self.volumes = {} + + # register the home directory as volume (rw) + vol_name = f"jupyterhub-vol-{safe_user}-{safe_srv}" + self.volumes[vol_name] = "/home/jovyan/work" + + # register given datasets as volumes (ro) + for subfolder in data_subfolders: + host_data_path = os.path.expandvars(f"$HOME/mnt/{subfolder}") + container_path = f"/cybershuttle_data/{subfolder}" + self.volumes[host_data_path] = { + 'bind': container_path, + 'mode': 'ro' + } return await super().start() diff --git a/modules/research-framework/research-hub/user-container/Dockerfile b/modules/research-framework/research-hub/user-container/Dockerfile new file mode 100644 index 0000000000..26bf413f90 --- /dev/null +++ b/modules/research-framework/research-hub/user-container/Dockerfile @@ -0,0 +1,12 @@ +FROM quay.io/jupyter/base-notebook:latest + +COPY init.sh /usr/local/bin/init.sh + +USER root +RUN chmod +x /usr/local/bin/init.sh +RUN apt-get update && apt-get install -y git && rm -rf /var/lib/apt/lists/* + +USER $NB_USER +RUN pip install ipywidgets jupyterlab-git + +CMD ["start-notebook.py"] \ No newline at end of file diff --git a/modules/research-framework/research-hub/user-container/Makefile b/modules/research-framework/research-hub/user-container/Makefile new file mode 100755 index 0000000000..4f74d1c5f0 --- /dev/null +++ b/modules/research-framework/research-hub/user-container/Makefile @@ -0,0 +1,3 @@ +deploy: + docker build --platform linux/x86_64 -t cybershuttle/jupyterlab-base . && \ + docker push cybershuttle/jupyterlab-base \ No newline at end of file diff --git a/modules/research-framework/research-hub/compose/user-container/init.sh b/modules/research-framework/research-hub/user-container/init.sh similarity index 100% rename from modules/research-framework/research-hub/compose/user-container/init.sh rename to modules/research-framework/research-hub/user-container/init.sh
