diff --git a/.github/workflows/build-and-publish.yml b/.github/workflows/build-and-publish.yml index a0d11e6..64b3576 100644 --- a/.github/workflows/build-and-publish.yml +++ b/.github/workflows/build-and-publish.yml @@ -16,7 +16,8 @@ on: branches: [ main ] env: REGISTRY: ghcr.io - IMAGE_NAME: ${{ github.repository }} + IMAGE_NAME_1: mbi-div-b-notebook-base + IMAGE_NAME_2: mbi-div-b-notebook-cuda jobs: push_to_registry: name: Push Docker image to GitHub Container Registry @@ -35,17 +36,36 @@ jobs: username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - - name: Extract metadata (tags, labels) for Docker - id: meta - uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7 + - name: Extract metadata (tags, labels) for Docker 1st image + id: meta1 + uses: docker/metadata-action@v4.6.0 with: - images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + images: ${{ env.REGISTRY }}/${{ github.repository_owner }}/${{ env.IMAGE_NAME_1 }} - - name: Build and push Docker image - uses: docker/build-push-action@3b5e8027fcad23fda98b2e3ac259d8d67585f671 + - name: Build and push 1st Docker image + uses: docker/build-push-action@v4.1.1 with: - context: . - file: ./Dockerfile + context: ${{ env.IMAGE_NAME_1 }} + file: ${{ env.IMAGE_NAME_1 }}/Dockerfile push: ${{ github.event_name != 'pull_request' }} - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} + tags: ${{ steps.meta1.outputs.tags }} + labels: ${{ steps.meta1.outputs.labels }} + + - name: Extract metadata (tags, labels) for Docker 2nd image + id: meta2 + uses: docker/metadata-action@v4.6.0 + with: + images: ${{ env.REGISTRY }}/${{ github.repository_owner }}/${{ env.IMAGE_NAME_2 }} + + - name: Build and push 2nd Docker image + uses: docker/build-push-action@v4.1.1 + with: + context: ${{ env.IMAGE_NAME_2 }} + build-args: | + BASE_REPO=${{ github.repository_owner }} + REGISTRY=${{ env.REGISTRY }} + }} + file: ${{ env.IMAGE_NAME_2 }}/Dockerfile + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.meta2.outputs.tags }} + labels: ${{ steps.meta2.outputs.labels }} diff --git a/VERSION b/VERSION index 9faa1b7..0ea3a94 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.1.5 +0.2.0 diff --git a/.dockerignore b/mbi-div-b-notebook-base/.dockerignore similarity index 100% rename from .dockerignore rename to mbi-div-b-notebook-base/.dockerignore diff --git a/mbi-div-b-notebook-base/Dockerfile b/mbi-div-b-notebook-base/Dockerfile new file mode 100644 index 0000000..ba6515d --- /dev/null +++ b/mbi-div-b-notebook-base/Dockerfile @@ -0,0 +1,127 @@ +# Copyright (c) Jupyter Development Team. +# Distributed under the terms of the Modified BSD License. +# uses ubuntu:22.04 as the root container. +ARG BASE_CONTAINER=jupyter/minimal-notebook +FROM $BASE_CONTAINER + +LABEL maintainer="@lrlunin" +LABEL description="Docker image for the MBI div B JupyterHub" +# Fix: https://github.com/hadolint/hadolint/wiki/DL4006 +# Fix: https://github.com/koalaman/shellcheck/wiki/SC3014 +COPY data/Fira_Sans.zip /tmp/Fira_Sans.zip +COPY scripts /tmp/scripts +SHELL ["/bin/bash", "-o", "pipefail", "-c"] + +USER root + +RUN apt-get update --yes && \ + apt-get install --yes --no-install-recommends \ + # for cython: https://cython.readthedocs.io/en/latest/src/quickstart/install.html + build-essential \ + # for latex labels + cm-super \ + dvipng \ + fontconfig \ + # for slsdetectorlib + cmake \ + libzmq5-dev \ + libtiff5-dev \ + # user requests + imagemagick \ + # for matplotlib anim + ffmpeg && \ + apt-get clean && rm -rf /var/lib/apt/lists/* + +RUN chmod +x /tmp/scripts/install-mbistyles-fonts.sh && /tmp/scripts/install-mbistyles-fonts.sh +RUN chmod +x /tmp/scripts/install-slsdetector-package.sh && /tmp/scripts/install-slsdetector-package.sh + + + +# RUN chmod -R 777 /home/${NB_USER}/.jupyter/ + +USER ${NB_UID} +#Install Python 3 packages +RUN mamba install --yes \ + 'altair' \ + 'beautifulsoup4' \ + 'bokeh' \ + 'bottleneck' \ + 'cloudpickle' \ + 'conda-forge::blas=*=openblas' \ + 'cython' \ + 'dask' \ + 'dill' \ + 'h5py' \ + 'ipympl=0.9.3' \ + 'ipywidgets=8.0.6' \ + 'jupyterlab-git' \ + 'matplotlib-base=3.7.1' \ + 'numba' \ + 'numexpr' \ + 'openpyxl' \ + 'pandas' \ + 'patsy' \ + 'protobuf' \ + 'pytables' \ + 'scikit-image' \ + 'scikit-learn' \ + 'scipy' \ + 'seaborn' \ + 'sqlalchemy' \ + 'statsmodels' \ + 'sympy' \ + 'widgetsnbextension' \ + 'xlrd' \ + 'conda-forge::pyfai' \ + 'jupyterlab-h5web' \ + 'xarray' \ + 'netCDF4' \ + 'conda-forge::dask-labextension' && \ + mamba clean --all -f -y && \ + fix-permissions "${CONDA_DIR}" && \ + fix-permissions "/home/${NB_USER}" + +# Install packages missing in mamba with pip +# ultrafastfitfunctions need to be installed from git and commit after accepting the pull request +# https://github.com/EmCeBeh/ultrafastFitFunctions/pull/2 +RUN pip install --no-cache-dir udkm1Dsim \ + pyEvalData \ + git+https://github.com/lrlunin/ultrafastFitFunctions@5bd30901b405dab1b161f59c7c1d5238c2f12991 \ + git+https://github.com/MBI-Div-B/mbistyles.git \ + nbdime \ + jupyterlab-fasta \ + jupyterlab-geojson \ + jupyterlab-katex \ + jupyterlab-mathjax2 \ + jupyterlab-vega3 \ + jupyterlab-code-formatter \ + black && \ + fix-permissions "${CONDA_DIR}" && \ + fix-permissions "/home/${NB_USER}" + +# copying "new default" settings like black code formatter +COPY --chown=${NB_UID}:${NB_UID} data/user-settings /home/${NB_USER}/.jupyter/lab/user-settings + +# jupyterlab-code-formatter needs to be configured +# https://jupyterlab-code-formatter.readthedocs.io/configuration.html +# see more for jupyterhub https://jupyterlab-code-formatter.readthedocs.io/jupyterhub.html +# potentially: +# RUN jupyter serverextension enable --py jupyterlab_code_formatter --sys-prefix + +# Install facets which does not have a pip or conda package at the moment +WORKDIR /tmp +RUN git clone https://github.com/PAIR-code/facets.git && \ + jupyter nbextension install facets/facets-dist/ --sys-prefix && \ + rm -rf /tmp/facets && \ + fix-permissions "${CONDA_DIR}" && \ + fix-permissions "/home/${NB_USER}" + +# Import matplotlib the first time to build the font cache. +ENV XDG_CACHE_HOME="/home/${NB_USER}/.cache/" + +RUN MPLBACKEND=Agg python -c "import matplotlib.pyplot" && \ + fix-permissions "/home/${NB_USER}" + +USER ${NB_UID} + +WORKDIR "${HOME}" \ No newline at end of file diff --git a/data/Fira_Sans.zip b/mbi-div-b-notebook-base/data/Fira_Sans.zip similarity index 100% rename from data/Fira_Sans.zip rename to mbi-div-b-notebook-base/data/Fira_Sans.zip diff --git a/data/user-settings/@jupyter-widgets/jupyterlab-manager/plugin.jupyterlab-settings b/mbi-div-b-notebook-base/data/user-settings/@jupyter-widgets/jupyterlab-manager/plugin.jupyterlab-settings similarity index 100% rename from data/user-settings/@jupyter-widgets/jupyterlab-manager/plugin.jupyterlab-settings rename to mbi-div-b-notebook-base/data/user-settings/@jupyter-widgets/jupyterlab-manager/plugin.jupyterlab-settings diff --git a/data/user-settings/@jupyterlab/shortcuts-extension/shortcuts.jupyterlab-settings b/mbi-div-b-notebook-base/data/user-settings/@jupyterlab/shortcuts-extension/shortcuts.jupyterlab-settings similarity index 100% rename from data/user-settings/@jupyterlab/shortcuts-extension/shortcuts.jupyterlab-settings rename to mbi-div-b-notebook-base/data/user-settings/@jupyterlab/shortcuts-extension/shortcuts.jupyterlab-settings diff --git a/data/user-settings/jupyterlab_code_formatter/settings.jupyterlab-settings b/mbi-div-b-notebook-base/data/user-settings/jupyterlab_code_formatter/settings.jupyterlab-settings similarity index 100% rename from data/user-settings/jupyterlab_code_formatter/settings.jupyterlab-settings rename to mbi-div-b-notebook-base/data/user-settings/jupyterlab_code_formatter/settings.jupyterlab-settings diff --git a/scripts/install-mbistyles-fonts.sh b/mbi-div-b-notebook-base/scripts/install-mbistyles-fonts.sh old mode 100755 new mode 100644 similarity index 100% rename from scripts/install-mbistyles-fonts.sh rename to mbi-div-b-notebook-base/scripts/install-mbistyles-fonts.sh diff --git a/scripts/install-slsdetector-package.sh b/mbi-div-b-notebook-base/scripts/install-slsdetector-package.sh old mode 100755 new mode 100644 similarity index 100% rename from scripts/install-slsdetector-package.sh rename to mbi-div-b-notebook-base/scripts/install-slsdetector-package.sh diff --git a/mbi-div-b-notebook-cuda/.dockerignore b/mbi-div-b-notebook-cuda/.dockerignore new file mode 100644 index 0000000..b142023 --- /dev/null +++ b/mbi-div-b-notebook-cuda/.dockerignore @@ -0,0 +1,3 @@ +# Documentation +README.md +VERSION diff --git a/Dockerfile b/mbi-div-b-notebook-cuda/Dockerfile similarity index 61% rename from Dockerfile rename to mbi-div-b-notebook-cuda/Dockerfile index a02254d..2607520 100644 --- a/Dockerfile +++ b/mbi-div-b-notebook-cuda/Dockerfile @@ -1,42 +1,20 @@ -# Copyright (c) Jupyter Development Team. -# Distributed under the terms of the Modified BSD License. -# uses ubuntu:22.04 as the root container. -ARG BASE_CONTAINER=jupyter/minimal-notebook -FROM $BASE_CONTAINER +ARG BASE_REPO +ARG REGISTRY +FROM $REGISTRY/$BASE_REPO/mbi-div-b-notebook-base LABEL maintainer="@lrlunin" -LABEL description="Docker image for the MBI div B JupyterHub" -# Fix: https://github.com/hadolint/hadolint/wiki/DL4006 -# Fix: https://github.com/koalaman/shellcheck/wiki/SC3014 -COPY data/Fira_Sans.zip /tmp/Fira_Sans.zip -COPY scripts /tmp/scripts +LABEL description="Docker image for the MBI div B JupyterHub with cuda API" + SHELL ["/bin/bash", "-o", "pipefail", "-c"] USER root +# for cuda installation RUN apt-get update --yes && \ apt-get install --yes --no-install-recommends \ - # for cython: https://cython.readthedocs.io/en/latest/src/quickstart/install.html - build-essential \ - # for latex labels - cm-super \ - dvipng \ - fontconfig \ - # for slsdetectorlib - cmake \ - libzmq5-dev \ - libtiff5-dev \ - # for cuda installation - apt-utils \ - # user requests - imagemagick \ - # for matplotlib anim - ffmpeg && \ + apt-utils && \ apt-get clean && rm -rf /var/lib/apt/lists/* -RUN /tmp/scripts/install-mbistyles-fonts.sh -RUN /tmp/scripts/install-slsdetector-package.sh - # cuda installation like https://hub.docker.com/layers/nvidia/cuda/11.7.0-cudnn8-devel-ubuntu22.04/images/sha256-cf262ed40aa17b168184fd9a8d0ac2ae932e2c6d0fe4f08e0598ab50db08a07d?context=explore # took instructions from its installation steps @@ -138,91 +116,10 @@ RUN mkdir /opt/mumax3 && cd /opt/mumax3 && \ #rm mumax3-2020.10.01-Linux.tar.gz && \ #ln -s /opt/mumax3/mumax3 /usr/local/bin/mumax3 - USER ${NB_UID} -#Install Python 3 packages -RUN mamba install --yes \ - 'altair' \ - 'beautifulsoup4' \ - 'bokeh' \ - 'bottleneck' \ - 'cloudpickle' \ - 'conda-forge::blas=*=openblas' \ - 'cython' \ - 'dask' \ - 'dill' \ - 'h5py' \ - 'ipympl=0.9.3' \ - 'ipywidgets=8.0.6' \ - 'jupyterlab-git' \ - 'matplotlib-base=3.7.1' \ - 'numba' \ - 'numexpr' \ - 'openpyxl' \ - 'pandas' \ - 'patsy' \ - 'protobuf' \ - 'pytables' \ - 'scikit-image' \ - 'scikit-learn' \ - 'scipy' \ - 'seaborn' \ - 'sqlalchemy' \ - 'statsmodels' \ - 'sympy' \ - 'widgetsnbextension' \ - 'xlrd' \ - 'conda-forge::pyfai' \ - 'jupyterlab-h5web' \ - 'xarray' \ - 'netCDF4' \ - 'conda-forge::dask-labextension' && \ - mamba clean --all -f -y && \ - fix-permissions "${CONDA_DIR}" && \ - fix-permissions "/home/${NB_USER}" - -# Install packages missing in mamba with pip -# ultrafastfitfunctions need to be installed from git and commit after accepting the pull request -# https://github.com/EmCeBeh/ultrafastFitFunctions/pull/2 -RUN pip install --no-cache-dir udkm1Dsim \ - pyEvalData \ - git+https://github.com/lrlunin/ultrafastFitFunctions@5bd30901b405dab1b161f59c7c1d5238c2f12991 \ - git+https://github.com/MBI-Div-B/mbistyles.git \ - nbdime \ - jupyterlab-fasta \ - jupyterlab-geojson \ - jupyterlab-katex \ - jupyterlab-mathjax2 \ - jupyterlab-vega3 \ - jupyterlab-code-formatter \ - black && \ - fix-permissions "${CONDA_DIR}" && \ - fix-permissions "/home/${NB_USER}" - -# jupyterlab-code-formatter needs to be configured -# https://jupyterlab-code-formatter.readthedocs.io/configuration.html -# see more for jupyterhub https://jupyterlab-code-formatter.readthedocs.io/jupyterhub.html -# potentially: -# RUN jupyter serverextension enable --py jupyterlab_code_formatter --sys-prefix - -# Install facets which does not have a pip or conda package at the moment -WORKDIR /tmp -RUN git clone https://github.com/PAIR-code/facets.git && \ - jupyter nbextension install facets/facets-dist/ --sys-prefix && \ - rm -rf /tmp/facets && \ - fix-permissions "${CONDA_DIR}" && \ - fix-permissions "/home/${NB_USER}" - -# Import matplotlib the first time to build the font cache. -ENV XDG_CACHE_HOME="/home/${NB_USER}/.cache/" - -RUN MPLBACKEND=Agg python -c "import matplotlib.pyplot" && \ +RUN fix-permissions "${CONDA_DIR}" && \ fix-permissions "/home/${NB_USER}" -# copying "new default" settings like black code formatter -COPY data/user-settings /home/${NB_USER}/.jupyter/lab/user-settings - USER ${NB_UID} - WORKDIR "${HOME}" \ No newline at end of file