Skip to content

Commit

Permalink
text py-rocket with pangeo notebook
Browse files Browse the repository at this point in the history
  • Loading branch information
eeholmes committed Oct 20, 2024
1 parent f9d55dd commit b58116a
Show file tree
Hide file tree
Showing 4 changed files with 191 additions and 4 deletions.
30 changes: 30 additions & 0 deletions draft_images/pangeo/Dockerfile
Original file line number Diff line number Diff line change
@@ -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

79 changes: 79 additions & 0 deletions draft_images/pangeo/apt.txt
Original file line number Diff line number Diff line change
@@ -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
45 changes: 41 additions & 4 deletions draft_images/pangeo/environment.yml
Original file line number Diff line number Diff line change
@@ -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
41 changes: 41 additions & 0 deletions draft_images/pangeo/rocker.sh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit b58116a

Please sign in to comment.