From 131a74a4618a2ecde4fd6a0b7ff289f782b4f07b Mon Sep 17 00:00:00 2001 From: Mike Gottlieb Date: Thu, 16 May 2024 08:16:02 -0700 Subject: [PATCH] add hub image --- strain-hub/Dockerfile | 68 ++++++++++++++++++++++++++++++++++++++ strain-hub/build_docker.sh | 2 ++ strain-hub/environment.yml | 21 ++++++++++++ 3 files changed, 91 insertions(+) create mode 100644 strain-hub/Dockerfile create mode 100755 strain-hub/build_docker.sh create mode 100644 strain-hub/environment.yml diff --git a/strain-hub/Dockerfile b/strain-hub/Dockerfile new file mode 100644 index 0000000..7ab5d54 --- /dev/null +++ b/strain-hub/Dockerfile @@ -0,0 +1,68 @@ +FROM ghcr.io/earthscope/strain-processing-notebooks + +#from https://github.com/2i2c-org/coessing-image/blob/main/Dockerfile +USER root +#ENV DEBIAN_FRONTEND=noninteractive +#ENV PATH ${NB_PYTHON_PREFIX}/bin:$PATH + +#https://github.com/pangeo-data/pangeo-docker-images/blob/master/base-image/Dockerfile +# Setup environment to match variables set by repo2docker as much as possible +# The name of the conda environment into which the requested packages are installed +ENV CONDA_ENV=notebook \ + # Tell apt-get to not block installs by asking for interactive human input + DEBIAN_FRONTEND=noninteractive \ + # Set username, uid and gid (same as uid) of non-root user the container will be run as + NB_USER=jovyan \ + NB_UID=1000 \ + # Use /bin/bash as shell, not the default /bin/sh (arrow keys, etc don't work then) + SHELL=/bin/bash \ + # Setup locale to be UTF-8, avoiding gnarly hard to debug encoding errors + LANG=C.UTF-8 \ + LC_ALL=C.UTF-8 \ + # Install conda in the same place repo2docker does + #CONDA_DIR=/srv/conda + # Change to where docker stacks does https://github.com/EarthScope/strain-processing-notebooks/blob/aba9f9b5d2a199e75462c239ebf57a96dd33ffbf/docker-stacks-foundation/Dockerfile#L44C5-L44C25 + CONDA_DIR=/opt/conda +# All env vars that reference other env vars need to be in their own ENV block +# Path to the python environment where the jupyter notebook packages are installed +ENV NB_PYTHON_PREFIX=${CONDA_DIR}/envs/${CONDA_ENV} \ + # Home directory of our non-root user + HOME=/home/${NB_USER} + +# Add both our notebook env as well as default conda installation to $PATH +# Thus, when we start a `python` process (for kernels, or notebooks, etc), +# it loads the python in the notebook conda environment, as that comes +# first here. +ENV PATH=${NB_PYTHON_PREFIX}/bin:${CONDA_DIR}/bin:${PATH} + +# Ask dask to read config from ${CONDA_DIR}/etc rather than +# the default of /etc, since the non-root jovyan user can write +# to ${CONDA_DIR}/etc but not to /etc +ENV DASK_ROOT_CONFIG=${CONDA_DIR}/etc + +# Run conda activate each time a bash shell starts, so users don't have to manually type conda activate +# Note this is only read by shell, but not by the jupyter notebook - that relies +# on us starting the correct `python` process, which we do by adding the notebook conda environment's +# bin to PATH earlier ($NB_PYTHON_PREFIX/bin) +RUN echo ". ${CONDA_DIR}/etc/profile.d/conda.sh ; conda activate ${CONDA_ENV}" > /etc/profile.d/init_conda.sh + +# Needed for apt-key to work +RUN apt-get update -qq --yes > /dev/null && \ + apt-get install --yes -qq gnupg2 > /dev/null + +USER ${NB_USER} + +COPY environment.yml /tmp/ + +RUN mamba env update --name ${CONDA_ENV} -f /tmp/environment.yml + +# Remove nb_conda_kernels from the env for now +RUN mamba remove -n ${CONDA_ENV} nb_conda_kernels + +#COPY install-jupyter-extensions.bash /tmp/install-jupyter-extensions.bash +#RUN /tmp/install-jupyter-extensions.bash + +# Set bash as shell in terminado. +#ADD jupyter_notebook_config.py ${NB_PYTHON_PREFIX}/etc/jupyter/ +# Disable history. +#ADD ipython_config.py ${NB_PYTHON_PREFIX}/etc/ipython/ \ No newline at end of file diff --git a/strain-hub/build_docker.sh b/strain-hub/build_docker.sh new file mode 100755 index 0000000..e2ffc1d --- /dev/null +++ b/strain-hub/build_docker.sh @@ -0,0 +1,2 @@ +docker build --rm -f Dockerfile -t ghcr.io/earthscope/strain-hub . +docker push ghcr.io/earthscope/strain-hub \ No newline at end of file diff --git a/strain-hub/environment.yml b/strain-hub/environment.yml new file mode 100644 index 0000000..c30dd1e --- /dev/null +++ b/strain-hub/environment.yml @@ -0,0 +1,21 @@ +# This is the standard conda configuration file. Use this file to list +# the conda packages that you need installed in your environment. +channels: + - conda-forge + +dependencies: + - jupyter_contrib_nbextensions==0.5.1 + # Required until https://github.com/jupyterhub/repo2docker/pull/1196 is merged + - jupyterhub-singleuser>=3.0,<4.0 + # Set default python version to 3.10 - repo2docker sets it to 3.7 instead by default, + # which can limit us to older package versions + - python=3.10 + # extensions fail with notebook>7? https://stackoverflow.com/questions/76893872/modulenotfounderror-no-module-named-notebook-base-when-installing-nbextension + - notebook==6.4.12 + # Everyone wants to use nbgitpuller for everything, so let's do that + - nbgitpuller=1.1.* + # Add other packages here + - nb_conda_kernels + - pip + - pip: + - 'earthscopestraintools[mseed,tiledb]' \ No newline at end of file