Skip to content

Commit

Permalink
Merge pull request #39 from uc-cdis/feat/jupyter-nb7
Browse files Browse the repository at this point in the history
HP-1589 Feat/jupyter nb7
  • Loading branch information
mfshao authored Oct 29, 2024
2 parents 632d538 + 77fefb4 commit 8bf11e3
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 36 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ A "slim" build of jupyter notebook images
## Run locally

```
docker-compose -f ./jupytersuperslim.yaml up
docker compose -f ./jupytersuperslim.yaml up
```

Then connect to http://localhost:9880/lw-workspace/proxy/
Then connect to http://localhost:9888/lw-workspace/proxy/

## Deploy to hatchery

Expand Down
34 changes: 16 additions & 18 deletions jupyter-superslim-rkernel/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,18 @@ USER root
# (ARGS are in lower case to distinguish them from ENV)
# Check https://github.com/conda-forge/miniforge/releases
# Conda version
ARG conda_version="4.10.3"
ARG conda_version="24.7.1"
# Miniforge installer patch version
ARG miniforge_patch_number="3"
ARG miniforge_patch_number="2"
# Package Manager and Python implementation to use (https://github.com/conda-forge/miniforge)
# - conda only: either Miniforge3 to use Python or Miniforge-pypy3 to use PyPy
# - conda + mamba: either Mambaforge to use Python or Mambaforge-pypy3 to use PyPy
ARG miniforge_python="Mambaforge"
ARG miniforge_python="Miniforge3"
# Miniforge archive to install
ARG miniforge_version="${conda_version}-${miniforge_patch_number}"


# Install all OS dependencies for notebook server that starts but lacks all
# features (e.g., download as all possible file formats)
ENV DEBIAN_FRONTEND noninteractive
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update --yes && \
apt-get install --yes --no-install-recommends \
tini \
Expand All @@ -61,7 +59,7 @@ ENV CONDA_DIR=/opt/conda \
LC_ALL=en_US.UTF-8 \
LANG=en_US.UTF-8 \
LANGUAGE=en_US.UTF-8 \
R_BASE_VERSION=4.1.0
R_BASE_VERSION=4.3.3

ENV PATH="${CONDA_DIR}/bin:${PATH}" \
HOME="/home/${NB_USER}" \
Expand All @@ -72,11 +70,6 @@ ENV PATH="${CONDA_DIR}/bin:${PATH}" \
COPY resources/scripts/fix-permissions /usr/local/bin/fix-permissions
RUN chmod a+rx /usr/local/bin/fix-permissions

# Use overrides.json file to change the default settings
RUN mkdir -p /opt/conda/share/jupyter/lab/settings
COPY resources/overrides.json /opt/conda/share/jupyter/lab/settings


# Enable prompt color in the skeleton .bashrc before creating the default NB_USER
# hadolint ignore=SC2016
RUN sed -i 's/^#force_color_prompt=yes/force_color_prompt=yes/' /etc/skel/.bashrc && \
Expand All @@ -97,12 +90,12 @@ RUN echo "auth requisite pam_deny.so" >> /etc/pam.d/su && \
fix-permissions "${CONDA_DIR}"

USER ${NB_UID}
ARG PYTHON_VERSION=default
ARG PYTHON_VERSION=3.9

# Install conda as jovyan and check the sha256 sum provided on the download site
WORKDIR /tmp

# Prerequisites installation: conda, mamba, pip, tini
# Prerequisites installation: conda, pip, tini
RUN set -x && \
# Miniforge installer
miniforge_arch=$(uname -m) && \
Expand All @@ -117,19 +110,25 @@ RUN set -x && \
rm "${miniforge_installer}" && \
# Conda configuration see https://conda.io/projects/conda/en/latest/configuration.html
echo "conda ${CONDA_VERSION}" >> "${CONDA_DIR}/conda-meta/pinned" && \
conda update -n base -c defaults conda && \
conda config --system --set auto_update_conda false && \
conda config --system --set show_channel_urls true && \
if [[ "${PYTHON_VERSION}" != "default" ]]; then conda install --yes python="${PYTHON_VERSION}"; fi && \
conda list python | grep '^python ' | tr -s ' ' | cut -d ' ' -f 1,2 >> "${CONDA_DIR}/conda-meta/pinned" && \
conda install --quiet --yes \
"conda=${CONDA_VERSION}" \
"python=${PYTHON_VERSION}" \
'pip' && \
conda update --all --quiet --yes && \
conda clean --all -f -y && \
rm -rf "/home/${NB_USER}/.cache/yarn" && \
fix-permissions "${CONDA_DIR}" && \
fix-permissions "/home/${NB_USER}"

# Use overrides.json file to change the default settings
RUN mkdir -p /opt/conda/share/jupyter/lab/settings
COPY resources/overrides.json /opt/conda/share/jupyter/lab/settings

# Install Jupyter Notebook, Lab, Hub and R packages
# R packages including IRKernel which gets installed globally.
# See https://github.com/rocker-org/rocker/blob/master/r-base/Dockerfile
Expand All @@ -138,7 +137,7 @@ RUN set -x && \
# Correct permissions
# Do all this in a single RUN command to avoid duplicating all of the
# files across image layers when the permissions change
RUN conda install --quiet --yes \
RUN conda install --quiet --yes python="${PYTHON_VERSION}" \
'notebook' \
'jupyterhub' \
'jupyterlab' \
Expand All @@ -162,9 +161,8 @@ RUN conda install --quiet --yes \
'r-gplots' \
'r-gtools' \
'r-catools' \
'jupyterhub=2' \
'jupyterhub-base=2' \
'jupyter_server=1' \
'jupyterhub-base' \
'jupyter_server' \
&& conda clean --all -f -y && \
npm cache clean --force && \
jupyter notebook --generate-config && \
Expand Down
14 changes: 12 additions & 2 deletions jupyter-superslim-rkernel/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
gen3==4.17.2
gen3
cdiserrors
pandas
numpy
jupyter_server_ydoc
tornado>=6.3.3 # not directly required, pinned by Snyk to avoid a vulnerability
# begin jupyter plugins and utilities section
jupyter-lsp
jupyterlab-lsp
jupyterlab-search-replace
jupyterlab-git
jupyter_server_ydoc
altair[all]
lckr_jupyterlab_variableinspector
ripgrep
frictionless
# end jupyter plugins and utilities section
23 changes: 11 additions & 12 deletions jupyter-superslim/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,18 @@ USER root
# (ARGS are in lower case to distinguish them from ENV)
# Check https://github.com/conda-forge/miniforge/releases
# Conda version
ARG conda_version="4.10.3"
ARG conda_version="24.7.1"
# Miniforge installer patch version
ARG miniforge_patch_number="3"
ARG miniforge_patch_number="2"
# Package Manager and Python implementation to use (https://github.com/conda-forge/miniforge)
# - conda only: either Miniforge3 to use Python or Miniforge-pypy3 to use PyPy
# - conda + mamba: either Mambaforge to use Python or Mambaforge-pypy3 to use PyPy
ARG miniforge_python="Mambaforge"
ARG miniforge_python="Miniforge3"
# Miniforge archive to install
ARG miniforge_version="${conda_version}-${miniforge_patch_number}"


# Install all OS dependencies for notebook server that starts but lacks all
# features (e.g., download as all possible file formats)
ENV DEBIAN_FRONTEND noninteractive
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update --yes && \
apt-get install --yes --no-install-recommends \
tini \
Expand Down Expand Up @@ -91,13 +89,13 @@ RUN echo "auth requisite pam_deny.so" >> /etc/pam.d/su && \
fix-permissions "${CONDA_DIR}"

USER ${NB_UID}
ARG PYTHON_VERSION=default
ARG PYTHON_VERSION=3.9


# Install conda as jovyan and check the sha256 sum provided on the download site
WORKDIR /tmp

# Prerequisites installation: conda, mamba, pip, tini
# Prerequisites installation: conda, pip, tini
RUN set -x && \
# Miniforge installer
miniforge_arch=$(uname -m) && \
Expand All @@ -112,12 +110,14 @@ RUN set -x && \
rm "${miniforge_installer}" && \
# Conda configuration see https://conda.io/projects/conda/en/latest/configuration.html
echo "conda ${CONDA_VERSION}" >> "${CONDA_DIR}/conda-meta/pinned" && \
conda update -n base -c defaults conda && \
conda config --system --set auto_update_conda false && \
conda config --system --set show_channel_urls true && \
if [[ "${PYTHON_VERSION}" != "default" ]]; then conda install --yes python="${PYTHON_VERSION}"; fi && \
conda list python | grep '^python ' | tr -s ' ' | cut -d ' ' -f 1,2 >> "${CONDA_DIR}/conda-meta/pinned" && \
conda install --quiet --yes \
"conda=${CONDA_VERSION}" \
"python=${PYTHON_VERSION}" \
'pip' && \
conda update --all --quiet --yes && \
conda clean --all -f -y && \
Expand All @@ -135,13 +135,12 @@ COPY resources/overrides.json /opt/conda/share/jupyter/lab/settings
# Correct permissions
# Do all this in a single RUN command to avoid duplicating all of the
# files across image layers when the permissions change
RUN conda install --quiet --yes \
RUN conda install --quiet --yes python="${PYTHON_VERSION}" \
'notebook' \
'jupyterhub' \
'jupyterlab' \
'jupyterhub=2' \
'jupyterhub-base=2' \
'jupyter_server=1' \
'jupyterhub-base' \
'jupyter_server' \
&& conda clean --all -f -y && \
npm cache clean --force && \
jupyter notebook --generate-config && \
Expand Down
13 changes: 11 additions & 2 deletions jupyter-superslim/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
gen3==4.17.2
gen3
cdiserrors
pandas
numpy
jupyter_server_ydoc
tornado>=6.3.3 # not directly required, pinned by Snyk to avoid a vulnerability
zipp>=3.19.1 # not directly required, pinned by Snyk to avoid a vulnerability
# begin jupyter plugins and utilities section
jupyter-lsp
jupyterlab-lsp
jupyterlab-search-replace
jupyterlab-git
altair[all]
lckr_jupyterlab_variableinspector
ripgrep
frictionless
# end jupyter plugins and utilities section

0 comments on commit 8bf11e3

Please sign in to comment.