From b58116a761962a15012a98f9547b650cc362f0ab Mon Sep 17 00:00:00 2001 From: Eli Holmes Date: Sat, 19 Oct 2024 17:18:25 -0700 Subject: [PATCH] text py-rocket with pangeo notebook --- draft_images/pangeo/Dockerfile | 30 +++++++++++ draft_images/pangeo/apt.txt | 79 +++++++++++++++++++++++++++++ draft_images/pangeo/environment.yml | 45 ++++++++++++++-- draft_images/pangeo/rocker.sh | 41 +++++++++++++++ 4 files changed, 191 insertions(+), 4 deletions(-) create mode 100644 draft_images/pangeo/apt.txt create mode 100644 draft_images/pangeo/rocker.sh diff --git a/draft_images/pangeo/Dockerfile b/draft_images/pangeo/Dockerfile index 74872d4..f6528e0 100644 --- a/draft_images/pangeo/Dockerfile +++ b/draft_images/pangeo/Dockerfile @@ -1 +1,31 @@ FROM pangeo/pangeo-notebook:latest + +USER root + +ENV REPO_DIR="/srv/repo" +RUN mkdir -p ${REPO_DIR} +COPY . ${REPO_DIR} + +# Install R, RStudio via Rocker scripts +ENV R_VERSION="4.4.1" +ENV R_DOCKERFILE="verse_${R_VERSION}" +RUN PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin && \ + chmod +x ${REPO_DIR}/rocker.sh && \ + ${REPO_DIR}/rocker.sh + +# Install extra cmd line packages after R installation +# The package_list part is reading the file and doing clean-up to just have the list of packages +RUN package_list=$(grep -v '^\s*#' ${REPO_DIR}/apt.txt | grep -v '^\s*$' | sed 's/\r//g; s/#.*//; s/^[[:space:]]*//; s/[[:space:]]*$//' | awk '{$1=$1};1') && \ + apt-get update && \ + apt-get install --yes --no-install-recommends $package_list && \ + apt-get autoremove --purge && \ + apt-get clean && \ + rm -rf /var/lib/apt/lists/* + +# Revert to default user +USER ${NB_USER} + +COPY environment.yml environment.yml +RUN mamba env update --name notebook -f environment.yml && mamba clean --all +RUN rm environment.yml + diff --git a/draft_images/pangeo/apt.txt b/draft_images/pangeo/apt.txt new file mode 100644 index 0000000..959a342 --- /dev/null +++ b/draft_images/pangeo/apt.txt @@ -0,0 +1,79 @@ +# Need to install after R installation + +# Basic unix tools +man +man-db +manpages-posix +manpages-dev +manpages-posix-dev + +# Download tools +curl +wget + +# Core text editors on a *nix box: vim and emacs +vim +emacs-nox +emacs-goodies-el + +# A couple of CLI editors that are easier than vim +# micro # currently not working on 18.04 +nano +jed +jed-extra + +# powerful terminal-based file manager, better than the one in JLab +mc + +# for easily managing multiple repositories with one command (perl-doc +# is needed for its help pages to work) +mr +perl-doc + +# Regular build tools for compiling common stuff +build-essential +gfortran + +# Dependencies for nbconvert and myst +# texlive is installed by R installation but not some of the common packages +texlive-latex-recommended + +# Other useful document-related tools +# pandoc installed by R installation +imagemagick + +# Some useful git utilities use basic Ruby +ruby + +# Other niceties for command-line work and life +ack # powerful grep-like tool +pydf # colorized disk usage +tmux +screen +htop +nnn # cmd line file manager +zsh +rsync +tig # console UI for git +multitail +tree + +## This section adds tools needed for desktop environment +dbus-x11 +xorg +xubuntu-icon-theme +xfce4 +xfce4-goodies +xclip +xsel + +# GUI text editors +emacs +vim-gtk3 +gedit + +# Git clients and tools +git-gui +gitg +qgit +meld \ No newline at end of file diff --git a/draft_images/pangeo/environment.yml b/draft_images/pangeo/environment.yml index 27f9e09..bf5fcc4 100644 --- a/draft_images/pangeo/environment.yml +++ b/draft_images/pangeo/environment.yml @@ -1,9 +1,46 @@ -name: pangeo +name: py-rocket-base + channels: - - conda-forge + - conda-forge + - nodefaults + dependencies: - - qgis - - pip + # This provides memory usage stats on JupyterLab and classic notebook + - jupyter-resource-usage~=1.0.1 + # https://syncthing.net/ provides a dropbox-like interface for syncing directories across users, + # hubs and machines. Used along with `jupyter-syncthing-proxy`. + # - jupyter-syncthing-proxy==1.0.3 + # - syncthing~=1.22.1 + # gh-scoped-creds allows users to securely push to GitHub from their repo. + # https://blog.jupyter.org/securely-pushing-to-github-from-a-jupyterhub-3ee42dfdc54f has + # some more information + - gh-scoped-creds==4.1 + # More git tools from github-cli + - gh~=2.32.1 + + # R/RStudio Support + - jupyter-rsession-proxy + + # VS Code support + - jupyter-vscode-proxy~=0.5 + - code-server~=4.23 + + + # JupyterBook Addons + - sphinx~=7.3 + - sphinxcontrib-bibtex + + # Resolves warning "No ICDs were found": https://github.com/CryoInTheCloud/hub-image/issues/50 + - ocl-icd-system + # needed for Linux desktop to work + - websockify>=0.10 + # Includes new subcommands (`switch` & `restore`) and vulnerability fixes + # over the version available via ubuntu sources + - git>=2.39 + + # Desktop server + # Not all packages will be available from conda-forge, we install from pip when we need to. + - pip~=23.3.2 - pip: # Access linux desktop from inside JupyterHub - jupyter-desktop-server==0.1.3 diff --git a/draft_images/pangeo/rocker.sh b/draft_images/pangeo/rocker.sh new file mode 100644 index 0000000..ea0a5c4 --- /dev/null +++ b/draft_images/pangeo/rocker.sh @@ -0,0 +1,41 @@ +#!/bin/bash +set -e + +# This script will copy in the rocker_scripts to install things and +# Install rocker-verse using the TAG_${R_VERSION}.Dockerfile file +# It will run just the ENV and RUN commands in that file +# Variables defined here will only be available in this script. + +# Copy in the rocker files. Work in ${REPO_DIR} to make sure I don't clobber anything +cd ${REPO_DIR} +ROCKER_DOCKERFILE_NAME="${R_DOCKERFILE}.Dockerfile" +# For degugging use: wget https://github.com/eeholmes/rocker-versioned2/archive/refs/tags/R4.4.1.tar.gz +wget https://github.com/rocker-org/rocker-versioned2/archive/refs/tags/R${R_VERSION}.tar.gz +tar zxvf R${R_VERSION}.tar.gz && \ +mv rocker-versioned2-R${R_VERSION}/scripts /rocker_scripts && \ +mv rocker-versioned2-R${R_VERSION}/dockerfiles/${ROCKER_DOCKERFILE_NAME} /rocker_scripts/original.Dockerfile && \ +rm R${R_VERSION}.tar.gz && \ +rm -rf rocker-versioned2-R${R_VERSION} + +cd / +# Read the Dockerfile and process each line +while IFS= read -r line; do + # Check if the line starts with ENV or RUN + if [[ "$line" == ENV* ]]; then + # Assign variable + var_assignment=$(echo "$line" | sed 's/^ENV //g') + # Replace ENV DEFAULT_USER="jovyan" + if [[ "$var_assignment" == DEFAULT_USER* ]]; then + var_assignment="DEFAULT_USER=${NB_USER}" + fi + # Run this way eval "export ..." otherwise the " will get turned to %22 + eval "export $var_assignment" + # Write the exported variable to env.txt + echo "export $var_assignment" >> ${REPO_DIR}/env.txt + elif [[ "$line" == RUN* ]]; then + # Run the command from the RUN line + cmd=$(echo "$line" | sed 's/^RUN //g') + echo "Executing: $cmd" + eval "$cmd" # || echo ${cmd}" encountered an error, but continuing..." + fi +done < /rocker_scripts/original.Dockerfile \ No newline at end of file