From 337f2f6bec54d5142f1ea1276f737cc4060c1a35 Mon Sep 17 00:00:00 2001 From: Markus Scheidgen <markus.scheidgen@gmail.com> Date: Tue, 6 Dec 2022 13:44:29 +0100 Subject: [PATCH] Added a CI/CD build Dockerfile for jupyterlab to create an image with the current nomad-lab Python package. --- .gitlab-ci.yml | 23 +++++++++++++++++++++++ docker/jupyterlab/Dockerfile | 8 ++++++++ docker/jupyterlab/README.md | 11 ++++++++++- docker/jupyterlab/run | 2 +- tools.json | 2 +- 5 files changed, 43 insertions(+), 3 deletions(-) create mode 100644 .gitlab-ci.yml create mode 100644 docker/jupyterlab/Dockerfile diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000..31b2998 --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,23 @@ +# default installed image for docker executor is: python:3.6 +# using an image that can do git, docker, docker-compose +image: gitlab-registry.mpcdf.mpg.de/nomad-lab/nomad-fair/ci-runner:latest + +stages: + - build + +build: + stage: build + variables: + GIT_SUBMODULE_STRATEGY: recursive + GIT_SUBMODULE_UPDATE_FLAGS: --jobs 4 + DOCKER_BUILDKIT: 1 + before_script: + - docker --version + - echo "${CI_REGISTRY_PASSWORD}" | docker login ${CI_REGISTRY} --username ${CI_REGISTRY_USER} --password-stdin + script: + - docker build -t ${CI_REGISTRY_IMAGE}/jupyterlab:latest docker/jupyterlab + - docker push ${CI_REGISTRY_IMAGE}/jupyterlab:latest + rules: + - if: $CI_COMMIT_TAG + when: never + - when: on_success \ No newline at end of file diff --git a/docker/jupyterlab/Dockerfile b/docker/jupyterlab/Dockerfile new file mode 100644 index 0000000..27e2cb4 --- /dev/null +++ b/docker/jupyterlab/Dockerfile @@ -0,0 +1,8 @@ +# Create a build stage from the current nomad dev_python image to copy the nomad-lab +# distribution +FROM gitlab-registry.mpcdf.mpg.de/nomad-lab/nomad-fair/dev_python:develop AS dev_python + +FROM jupyter/datascience-notebook + +COPY --from=dev_python /app/dist/nomad-lab-*.tar.gz . +RUN pip install nomad-lab-*.tar.gz diff --git a/docker/jupyterlab/README.md b/docker/jupyterlab/README.md index f90c4d7..032a24d 100644 --- a/docker/jupyterlab/README.md +++ b/docker/jupyterlab/README.md @@ -1,4 +1,13 @@ ## JupyterLab -We are using the [jupyter/datascience-notebook](https://hub.docker.com/r/jupyter/datascience-notebook) image from DockerHub with some added arguments. This folder stores the docker run command we can use in the launch endpoint. +We are use a custom image based on [jupyter/datascience-notebook](https://hub.docker.com/r/jupyter/datascience-notebook). +We add the latest version of the `nomad-lab` Python package. The image is build by the +CI/CD and stored in the projects container registry. + +To build the image +``` +docker build -t gitlab-registry.mpcdf.mpg.de/nomad-lab/nomad-remote-tools-hub/jupyterlab:latest . +``` + +This folder stores the `Dockerfile` and a `run` command. There are also Python named string parameters to make the cmd a bit more dynamic. diff --git a/docker/jupyterlab/run b/docker/jupyterlab/run index 96235ce..9111ac9 100644 --- a/docker/jupyterlab/run +++ b/docker/jupyterlab/run @@ -1 +1 @@ -docker run -p {port}:8888 -v {mountpoint}:/home/jovyan/work --user 1000:1000 --group-add users jupyter/datascience-notebook start-notebook.sh --NotebookApp.base_url='{endpoint}' \ No newline at end of file +docker run -p {port}:8888 -v {mountpoint}:/home/jovyan/work --user 1000:1000 --group-add users gitlab-registry.mpcdf.mpg.de/nomad-lab/nomad-remote-tools-hub/jupyterlab:latest start-notebook.sh --NotebookApp.base_url='{endpoint}' \ No newline at end of file diff --git a/tools.json b/tools.json index 6765aad..b032ac7 100644 --- a/tools.json +++ b/tools.json @@ -2,7 +2,7 @@ "jupyter": { "short_description": "Basic jupyter run with an empty notebook or on given notebook file.", "description": "### **Jupyter Notebook**: The Classic Notebook Interface\n\nThe Jupyter Notebook is the original web application for creating and sharing computational documents. It offers a simple, streamlined, document-centric experience.", - "image": "jupyter/datascience-notebook", + "image": "gitlab-registry.mpcdf.mpg.de/nomad-lab/nomad-remote-tools-hub/jupyterlab:latest", "path_prefix": "tree", "mount_path": "/home/jovyan", "icon": "jupyter_logo.svg", -- GitLab