From 6b1bc50e83e1ca3d544fa002447fa0bb2bb4c2df Mon Sep 17 00:00:00 2001 From: Ryan Lovett Date: Thu, 9 Jan 2025 15:33:38 -0800 Subject: [PATCH] Update for Spring 2025. --- Dockerfile | 29 ++++---- class-libs.R | 20 ------ environment.yml | 40 +++++++---- ...-mambaforge.bash => install-miniforge.bash | 14 ++-- install-r-packages.r | 66 +++++++++++++++++++ r-packages/2024-fall-stat-20.r | 48 -------------- 6 files changed, 114 insertions(+), 103 deletions(-) delete mode 100644 class-libs.R rename install-mambaforge.bash => install-miniforge.bash (71%) create mode 100644 install-r-packages.r delete mode 100644 r-packages/2024-fall-stat-20.r diff --git a/Dockerfile b/Dockerfile index b63cf59..36bdcaf 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ -FROM rocker/geospatial:4.4.1 -# https://github.com/rocker-org/rocker-versioned2/wiki/geospatial_e06f866673fa +FROM rocker/geospatial:4.4.2 +# https://github.com/rocker-org/rocker-versioned2/wiki/geospatial_69e6b17dd7e3 ENV NB_USER=rstudio ENV NB_UID=1000 @@ -43,7 +43,7 @@ RUN apt-get update && \ # While quarto is included with rocker/verse, we sometimes need different # versions than the default. For example a newer version might fix bugs. -ENV _QUARTO_VERSION=1.4.549 +ENV _QUARTO_VERSION=1.6.40 RUN curl -L -o /tmp/quarto.deb https://github.com/quarto-dev/quarto-cli/releases/download/v${_QUARTO_VERSION}/quarto-${_QUARTO_VERSION}-linux-amd64.deb RUN apt-get update > /dev/null && \ apt-get install /tmp/quarto.deb > /dev/null && \ @@ -51,7 +51,7 @@ RUN apt-get update > /dev/null && \ rm -rf /var/lib/apt/lists/* && \ rm -f /tmp/quarto.deb -ENV SHINY_SERVER_URL=https://download3.rstudio.org/ubuntu-18.04/x86_64/shiny-server-1.5.21.1012-amd64.deb +ENV SHINY_SERVER_URL=https://download3.rstudio.org/ubuntu-18.04/x86_64/shiny-server-1.5.22.1017-amd64.deb RUN curl --silent --location --fail ${SHINY_SERVER_URL} > /tmp/shiny-server.deb && \ apt install --no-install-recommends --yes /tmp/shiny-server.deb && \ rm /tmp/shiny-server.deb @@ -66,18 +66,21 @@ RUN wget --quiet -O /tmp/chrome.deb https://dl.google.com/linux/direct/google-ch RUN install -d -o ${NB_USER} -g ${NB_USER} ${CONDA_DIR} +# Install conda environment as our user USER ${NB_USER} -COPY install-mambaforge.bash /tmp/install-mambaforge.bash -RUN /tmp/install-mambaforge.bash +COPY --chown=1000:1000 install-miniforge.bash /tmp/install-miniforge.bash +RUN /tmp/install-miniforge.bash +RUN rm -f /tmp/install-miniforge.bash USER root RUN rm -rf ${HOME}/.cache USER ${NB_USER} -COPY environment.yml /tmp/environment.yml +COPY --chown=1000:1000 environment.yml /tmp/environment.yml RUN mamba env update -p ${CONDA_DIR} -f /tmp/environment.yml && \ mamba clean -afy +RUN rm -f /tmp/environment.yml # Prepare VS Code extensions USER root @@ -93,14 +96,14 @@ RUN ${CONDA_DIR}/bin/code-server --extensions-dir ${VSCODE_EXTENSIONS} --install RUN ${CONDA_DIR}/bin/code-server --extensions-dir ${VSCODE_EXTENSIONS} --install-extension ms-python.python RUN ${CONDA_DIR}/bin/code-server --extensions-dir ${VSCODE_EXTENSIONS} --install-extension quarto.quarto -# Install IRKernel -RUN R --quiet -e "install.packages('IRkernel', quiet = TRUE)" && \ - R --quiet -e "IRkernel::installspec(prefix='${CONDA_DIR}')" +# Install R libraries as our user +USER ${NB_USER} -COPY class-libs.R /tmp/class-libs.R +COPY install-r-packages.r /tmp/ +RUN Rscript /tmp/install-r-packages.r -COPY r-packages/2024-fall-stat-20.r /tmp/r-packages/ -RUN r /tmp/r-packages/2024-fall-stat-20.r +# Install IRKernel kernel +RUN R --quiet -e "IRkernel::installspec(prefix='${CONDA_DIR}')" # Configure locking behavior COPY file-locks /etc/rstudio/file-locks diff --git a/class-libs.R b/class-libs.R deleted file mode 100644 index 1c93435..0000000 --- a/class-libs.R +++ /dev/null @@ -1,20 +0,0 @@ -#!/usr/bin/env Rscript - -class_libs_install_version <- function(class_name, class_libs) { - print(paste("Installing packages for", class_name)) - for (i in seq(1, length(class_libs), 2)) { - installed_packages <- rownames(installed.packages()) - package_name = class_libs[i] - version = class_libs[i+1] - # Only install packages if they haven't already been installed! - # devtools doesn't do that by default - if (!package_name %in% installed_packages) { - print(paste("Installing", package_name, version)) - devtools::install_version(package_name, version, quiet=TRUE) - } else { - # FIXME: This ignores version incompatibilities :'( - print(paste("Not installing", package_name, " as it is already installed")) - } - } - print(paste("Done installing packages for", class_name)) -} diff --git a/environment.yml b/environment.yml index c767a33..c327ae2 100644 --- a/environment.yml +++ b/environment.yml @@ -6,25 +6,38 @@ channels: dependencies: # Matches version in images/hub/Dockerfile - jupyterhub==4.1.6 -- jupyterlab==4.2.5 + +- jupyterlab==4.3.4 +- notebook==7.3.2 +- ipykernel = 6.29.5 +- ipywidgets==8.1.5 +- nbgitpuller==1.2.1 +- appmode==1.0.0 +- jupyter-resource-usage==1.1.0 - jupyter-server-proxy==4.4.0 - jupyter-rsession-proxy==2.2.1 +- jupyterlab-git==0.50.2 +- python==3.12.* + +# syncthing for dropbox-like functionality - jupyter-syncthing-proxy==1.0.3 + +# jupyter archival tool for easy user downloads - jupyter-archive==3.4.0 -- jupyter-resource-usage==1.1.0 + +# vscode - jupyter-vscode-proxy==0.6 -- notebook==7.2.2 -- nbconvert==7.6.0 -- nbgitpuller==1.2.1 -- ipywidgets==8.0.7 -# bug w/notebook and traitlets: https://github.com/jupyter/notebook/issues/7048 -#- traitlets=5.9.* -- matplotlib==3.8.3 -- shiny==1.0.0 -- appmode==1.0.0 -- syncthing==1.22.2 +- code-server==4.96.2 + +# jupyterbook +- mystmd==1.3.19 + +# gh-scoped-creds needs a newer version of git than what jammy provides - gh-scoped-creds==4.1 -- code-server==4.23.1 +- git==2.47.0 + +- matplotlib=3.10.* +- shiny==1.2.1 - pip - pip: - git-credential-helpers==0.2 @@ -35,3 +48,4 @@ dependencies: - jupyterlab-quarto==0.3.5 - nb2pdf==0.6.2 - nbpdfexport==0.2.1 + - nbconvert[webpdf] diff --git a/install-mambaforge.bash b/install-miniforge.bash similarity index 71% rename from install-mambaforge.bash rename to install-miniforge.bash index 928c481..e875a7d 100755 --- a/install-mambaforge.bash +++ b/install-miniforge.bash @@ -1,16 +1,12 @@ #!/bin/bash -# This downloads and installs a pinned version of mambaforge +# This downloads and installs a pinned version of miniforge set -ex cd $(dirname $0) -MAMBAFORGE_VERSION=24.9.2-0 +MINIFORGE_VERSION='24.11.2-1' -URL="https://github.com/conda-forge/miniforge/releases/download/${MAMBAFORGE_VERSION}/Miniforge3-${MAMBAFORGE_VERSION}-Linux-x86_64.sh" -INSTALLER_PATH=/tmp/mambaforge-installer.sh - -# make sure we don't do anything funky with user's $HOME -# since this is run as root -#unset HOME +URL="https://github.com/conda-forge/miniforge/releases/download/${MINIFORGE_VERSION}/Miniforge3-${MINIFORGE_VERSION}-Linux-x86_64.sh" +INSTALLER_PATH=/tmp/miniforge-installer.sh export XDG_CACHE_HOME=$(mktemp) @@ -28,7 +24,7 @@ conda config --system --set show_channel_urls true # which seems to result in some effective pinning of packages in the initial env, # which we don't intend. # this file must not be *removed*, however -echo '' > ${CONDA_DIR}/conda-meta/history +echo > ${CONDA_DIR}/conda-meta/history # Clean things out! conda clean --all -f -y diff --git a/install-r-packages.r b/install-r-packages.r new file mode 100644 index 0000000..170b1f2 --- /dev/null +++ b/install-r-packages.r @@ -0,0 +1,66 @@ +#!/usr/bin/env Rscript + +# Function to install R packages +install_packages_with_versions <- function(packages) { + available <- available.packages() + to_install <- names(packages)[!(names(packages) %in% rownames(installed.packages()))] + + if (length(to_install) > 0) { + install.packages(to_install, available = available, + versions = packages[to_install], + dependencies = TRUE) + } else { + cat("All packages are already installed.\n") + } +} + +# List of packages to ensure are installed +required_packages <- c("remotes", "devtools") + +# Check and install required packages +new_packages <- required_packages[!sapply(required_packages, requireNamespace, quietly = TRUE)] +if (length(new_packages) > 0) { + install.packages(new_packages) +} + + +packages = list( + "fivethirtyeight" = "0.6.2", + "gapminder" = "1.0.0", + "janitor" = "2.2.1", + "openintro" = "2.5.0", + "pagedown" = "0.22", + "palmerpenguins" = "0.1.1", + "patchwork" = "1.3.0", + "showtext" = "0.9-7", + "swirl" = "2.4.5", + "tidycensus" = "1.6.7", + "tidymodels" = "1.2.0", + "tigris" = "2.1", + "unvotes" = "0.3.0", + "xaringanthemer" = "0.4.3", + "rmarkdown" = "2.29", + "plotly" = "4.10.4", + "reshape2" = "1.4.4", + "kableExtra" = "1.4.0", + "infer" = "1.0.7", + "countdown" = "0.4.0", + "ggrepel" = "0.9.6", + "ggthemes" = "5.1.0", + "latex2exp" = "0.9.6", + "markdown" = "1.13", + "downlit" = "0.4.4", + "xml2" = "1.3.6", + "gt" = "0.11.1", + "quarto" = "1.4.4", + "fs" = "1.6.5", + "rsample" = "1.2.1", + "IRkernel" = "1.3.2" +) + +install_packages_with_versions(packages) + +devtools::install_github("mdbeckman/dcData", ref="a900560") +devtools::install_github("hadley/emo@3f03b11") +devtools::install_github("andrewpbray/boxofdata@8afd934") +devtools::install_github("stat20/stat20data@2536a78") diff --git a/r-packages/2024-fall-stat-20.r b/r-packages/2024-fall-stat-20.r deleted file mode 100644 index 0d12bbc..0000000 --- a/r-packages/2024-fall-stat-20.r +++ /dev/null @@ -1,48 +0,0 @@ -#!/usr/bin/env Rscript - -source("/tmp/class-libs.R") - -class_name = "2024 Fall Stat 20" - -class_libs = c( - "fivethirtyeight", "0.6.2", - "gapminder", "0.3.0", - "janitor", "2.2.0", - "openintro", "2.4.0", - "pagedown", "0.16", - "palmerpenguins", "0.1.1", - "patchwork", "1.1.2", - "showtext", "0.9-4", - "swirl", "2.4.5", - "tidycensus", "1.1", - "tidymodels", "0.1.4", - "tigris", "1.5", - "unvotes", "0.3.0", - "xaringanthemer", "0.4.1", - "rmarkdown", "2.22", - "plotly", "4.10.1", - "reshape2", "1.4.4", - "kableExtra", "1.3.4", - "infer", "1.0.4", - "countdown", "0.4.0", - "ggrepel", "0.9.3", - "ggthemes", "4.2.4", - "latex2exp", "0.9.6", - "markdown", "1.7", - "downlit", "0.4.3", - "xml2", "1.3.4", - "gt", "0.9.0", - "quarto", "1.2", - "fs", "1.6.3", - "rsample", "1.2.1" -) - -class_libs_install_version(class_name, class_libs) - -devtools::install_github("mdbeckman/dcData", ref="56888a6") -devtools::install_github("hadley/emo@3f03b11") -devtools::install_github("andrewpbray/boxofdata@8afd934") -devtools::install_github("tidymodels/infer@2806a69") -devtools::install_github("stat20/stat20data@2536a78") - -print(paste("Done installing packages for",class_name))