Skip to content

Commit

Permalink
Merge pull request #2 from jaytmiller/port-to-github
Browse files Browse the repository at this point in the history
Port back to GitHub
  • Loading branch information
jaytmiller authored Aug 1, 2023
2 parents bc9dec0 + cb6a6b9 commit 9be5ed6
Show file tree
Hide file tree
Showing 91 changed files with 4,230 additions and 6,621 deletions.
21 changes: 12 additions & 9 deletions deployments/common/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ RUN /opt/common-scripts/apt-install \
sysstat \
net-tools \
rename
# libexpat1
# libexpat1

# S/W Development Tools
RUN /opt/common-scripts/apt-install \
Expand All @@ -49,6 +49,7 @@ RUN /opt/common-scripts/apt-install \
automake \
libtool \
make \
cmake \
vim \
emacs-nox \
fftw3-dev \
Expand Down Expand Up @@ -87,10 +88,6 @@ RUN /opt/common-scripts/apt-install \
# apt-get remove --yes libpdfbox-java libfontbox-java && \
# apt autoremove --yes

# ------------------------------------------------------------------------
# This must be run after conda installs
RUN /opt/common-scripts/fix-certs

# ------------------------------------------------------------------------
RUN curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip" && \
unzip awscliv2.zip && \
Expand All @@ -112,7 +109,13 @@ USER root

COPY --chown=${NB_UID}:${NB_GID} common-scripts/ /opt/common-scripts
COPY --chown=${NB_UID}:${NB_GID} common-env/ /opt/common-env
RUN cat /opt/common-scripts/global_bashrc >> /etc/bash.bashrc

COPY bash.bashrc /tmp
RUN cat /tmp/bash.bashrc >> /etc/bash.bashrc

# For ENV_BASH definition for non-login shells
COPY bash.env /etc/bash.env
ENV BASH_ENV=/etc/bash.env

# ----------------------------------------------------------------------
# Common conda environments
Expand All @@ -128,11 +131,11 @@ COPY default-home-contents/ /etc/default-home-contents
# ----------------------------------------------------------------------
# YYYY SEC

RUN npm set config set cafile /etc/ssl/certs/stsci-tls-ca-bundle.pem

RUN npm install -g --prod yarn && \
npm install -g --prod yarn-audit-fix && \
npm install -g minimist && \
yarn config set cafile /etc/ssl/certs/stsci-tls-ca-bundle.pem && \
npm cache clean --force && \
yarn cache clean --force

COPY --chown=${NB_UID}:${NB_GID} tools/ /opt/tools/
COPY --chown=${NB_UID}:${NB_GID} VERSION /opt
44 changes: 44 additions & 0 deletions deployments/common/Dockerfile.base
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
ARG ROOT_CONTAINER=ubuntu:jammy
ARG BASE_CONTAINER=$ROOT_CONTAINER
FROM $BASE_CONTAINER

USER root

ARG TZ='America/New_York'
ARG DEBIAN_FRONTEND=noninteractive

ARG USE_FROZEN=1
ENV USE_FROZEN=$USE_FROZEN

ARG PIP_SWITCHES="--no-cache-dir"
ENV PIP_SWITCHES=$PIP_SWITCHES

# Enable easy swap of conda with e.g. mamba
ARG CONDA_VER=conda
ENV CONDA_VER=${CONDA_VER}

# Clearing caches at the end of each RUN saves image space
# but seems to mess up dependency debug tools like pipdeptree.
# NOT setting this is also a requirement of effective Docker
# buildkit cache use. ATM jupyter/docker-stacks will still wipe
# out caches created prior to the common base image regardless.
ARG CLEAR_PKG_CACHES="1"
ENV CLEAR_PKG_CACHES=${CLEAR_PKG_CACHES}

# These are duplicated in jupyter/docker-stacks so need to be changed
# in both locations. Better than hard coding in scripts though.
ENV NB_UID=1000
ENV NB_GID=100

# ------------------------------------------------------------------------

COPY --chown=${NB_UID}:${NB_GID} common-scripts/apt-install /opt/common-scripts/apt-install
RUN /opt/common-scripts/apt-install \
apt-utils \
tzdata \
ca-certificates \
openssl \
wget \
vim \
npm \
nodejs
75 changes: 0 additions & 75 deletions deployments/common/Dockerfile.certs

This file was deleted.

25 changes: 19 additions & 6 deletions deployments/common/Dockerfile.trailer
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
# ========================= vvvvv Generic vvvvv =========================

USER $NB_UID

# Fix JS encoding issue that prevents widgets from displaying properly in notebook mode
# See https://github.com/jupyter/notebook/issues/6033 for details
RUN sed -i 's/data-base-url="{{base_url | urlencode}}"/data-base-url="{{base_url}}"/g' `ls -1 ${CONDA_DIR}/lib/python*/site-packages/notebook/templates/notebook.html`

# ----------------------------------------------------------------------

USER $NB_UID
RUN /opt/common-scripts/kernel-setup # set up Ipython / JupyterLab kernels

# ----------------------------------------------------------------------
Expand All @@ -15,7 +16,7 @@ RUN /opt/common-scripts/kernel-setup # set up Ipython / JupyterLab kernels

USER root

RUN find /home/${NB_USER} ! -uid ${NB_UID} | xargs chown ${NB_UID}:${NB_GID}
RUN ( find /home/${NB_USER} ! -uid ${NB_UID} | xargs chown ${NB_UID}:${NB_GID} ) || true

# remove this step once nbgitpuller enabled; these contents will be in the
# jupyterhub-user-content repo. Install deployment-specific $HOME files.
Expand All @@ -24,20 +25,22 @@ RUN cp -r /home/jovyan/.local /etc/default-home-contents && \
cp -r /home/jovyan/.jupyter /etc/default-home-contents
COPY global_bashrc /home/jovyan
RUN cat /home/jovyan/global_bashrc >> /etc/bash.bashrc && \
cat /home/jovyan/global_bashrc >> /etc/bash.env && \
rm /home/jovyan/global_bashrc

# Fix certs in conda for application level SSL, e.g. pass image-test running on CI-node
RUN /opt/common-scripts/fix-certs

# Copy any remaining environments files not caught by more precise as-needed build copies
COPY --chown=${NB_UID}:${NB_GID} environments/ /opt/environments/

# ----------------------------------------------------------------------

COPY --chown=${NB_UID}:${NB_GID} MISSION_VERSION /opt

# ----------------------------------------------------------------------
# YYYY SEC

USER root
#RUN /opt/common-scripts/npm-audit /usr/share/npm/node_modules/socks-proxy-agent fix && \
RUN /opt/common-scripts/env-clean
#RUN /opt/common-scripts/env-clean

#RUN find /opt/conda -name yarn.lock | grep jupyterlab/staging | xargs rm -f || true

Expand All @@ -46,6 +49,16 @@ RUN /opt/common-scripts/env-clean
# common home directory files. post-start-hook may not include everything required
# for running on AWS, just common functions needed for both AWS and standalone/CI.

# Enable deletion of non-empty directories from lab GUI
RUN echo "-------------------------------- STSCI Config Overwrites --------------------------------" \
>> /etc/jupyter/jupyter_notebook_config.py &&\
echo "c.FileContentsManager.delete_to_trash = False" >> /etc/jupyter/jupyter_notebook_config.py &&\
echo "c.FileContentsManager.always_delete_dir = True" >> /etc/jupyter/jupyter_notebook_config.py &&\
echo "-------------------------------- STSCI Config Overwrites --------------------------------" \
>> /etc/jupyter/jupyter_server_config.py &&\
echo "c.FileContentsManager.delete_to_trash = False" >> /etc/jupyter/jupyter_server_config.py &&\
echo "c.FileContentsManager.always_delete_dir = True" >> /etc/jupyter/jupyter_server_config.py

USER $NB_USER
WORKDIR /home/$NB_USER
RUN /opt/environments/post-start-hook docker # docker == do not run hub-specific functions of hook
Expand Down
1 change: 1 addition & 0 deletions deployments/common/VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1.1.0
19 changes: 19 additions & 0 deletions deployments/common/bash.bashrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
export PS1="${debian_chroot:+($debian_chroot)}\u@notebook:\w\$ "

# Enable conda
. "/opt/conda/etc/profile.d/conda.sh"

# Activate base by default
conda activate base

#export PATH="/opt/TurboVNC/bin:$PATH"

# Utility scripts for users, mainly python environment management
export PATH="/opt/tools:$PATH"

export LD_LIBRARY_PATH=/usr/local/lib

# make non-login shell (notebook !) use same environment, picking up default kernel
export BASH_ENV=/etc/bash.bashrc

alias ls="ls --color=auto"
33 changes: 33 additions & 0 deletions deployments/common/bash.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# System-wide .bashrc file for non-login bash(1) shells.

# if the command-not-found package is installed, use it
if [ -x /usr/lib/command-not-found -o -x /usr/share/command-not-found/command-not-found ]; then
function command_not_found_handle {
# check because c-n-f could've been removed in the meantime
if [ -x /usr/lib/command-not-found ]; then
/usr/lib/command-not-found -- "$1"
return $?
elif [ -x /usr/share/command-not-found/command-not-found ]; then
/usr/share/command-not-found/command-not-found -- "$1"
return $?
else
printf "%s: command not found\n" "$1" >&2
return 127
fi
}
fi

# Enable conda
. "/opt/conda/etc/profile.d/conda.sh"

# Activate base by default
conda activate base

#export PATH="/opt/TurboVNC/bin:$PATH"

# Utility scripts for users, mainly python environment management
export PATH="/opt/tools:$PATH"

export LD_LIBRARY_PATH=/usr/local/lib

alias ls="ls --color=auto"
5 changes: 3 additions & 2 deletions deployments/common/common-env/jupyter.pip
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@ jupyterlab-pygments
jupyter-server
bqplot-image-gl
jupyter-server-proxy
jupyter_bokeh
jupyter-packaging
ipywidgets_bokeh
ipyevents
ipympl
ipyvolume
Expand All @@ -27,3 +25,6 @@ ipywebrtc
ipykernel
jupyter-resource-usage
git+https://github.com/spacetelescope/nersc-refresh-announcements@octarine-updates
sidecar
y-py
ypy-websocket
7 changes: 7 additions & 0 deletions deployments/common/common-env/required.pip
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# packages required for the framework to work

# needed to install a kernel
ipykernel

# needed to run headless notebook tests
papermill
22 changes: 22 additions & 0 deletions deployments/common/common-scripts/copy-default-home
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#! /bin/bash -e

# This script conditionally initializes user $HOME, once.
# To re-init you must rm ${HOME}/.sp-initialized

if [ ! -f ${HOME}/.sp-initialized ]; then
echo "Initializing $HOME with config defaults."
#echo "Deleting initial config directories to remove user added files."
#( cd /etc/default-home-contents/; find . -type d ) | xargs rm -rf || true
echo "Copying initial config files."
rsync -r /etc/default-home-contents/ ${HOME}
cat > ${HOME}/.sp-initialized <<EOF
Remove this file to re-initialize default configuration. The only
configuration which will be affected can be seen in
/etc/default-home-contents/, so you may need to remove custom
configuration files yourself, if you've added any. Our policy is not
to delete anything from your home directory.
EOF
else
echo "Skipping default config init, $HOME already initialized."
fi

3 changes: 2 additions & 1 deletion deployments/common/common-scripts/env-clean
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@ if [[ "${CLEAR_PKG_CACHES}" == "1" ]]; then
${CONDA_VER} clean -fya
# ${CONDA_VER} build purge-all
rm -rf $HOME/.cache/pip
rm -rf $HOME/.cache/pip-tools
echo "===== Clearing jupyterlab and npm caches..."
jupyter lab clean -y
npm cache clean --force
yarn cache clean --force
rm -rf "/home/${NB_USER}/.node-gyp"
rm -rf $HOME/.node-gyp
fi
Loading

0 comments on commit 9be5ed6

Please sign in to comment.