Skip to content

Commit

Permalink
Bringing in image directory from deployment repo
Browse files Browse the repository at this point in the history
  • Loading branch information
shaneknapp committed Sep 23, 2024
2 parents 8718218 + 9be377e commit 0be26ba
Show file tree
Hide file tree
Showing 5 changed files with 210 additions and 0 deletions.
107 changes: 107 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
FROM rocker/geospatial:4.4.1

ENV NB_USER rstudio
ENV NB_UID 1000
ENV CONDA_DIR /srv/conda

# Set ENV for all programs...
ENV PATH ${CONDA_DIR}/bin:$PATH

# And set ENV for R! It doesn't read from the environment...
RUN echo "PATH=${PATH}" >> /usr/local/lib/R/etc/Renviron.site

# Add PATH to /etc/profile so it gets picked up by the terminal
RUN echo "PATH=${PATH}" >> /etc/profile
RUN echo "export PATH" >> /etc/profile

ENV HOME /home/${NB_USER}

WORKDIR ${HOME}

# Install packages needed by notebook-as-pdf
# nodejs for installing notebook / jupyterhub from source
# libarchive-dev for https://github.com/berkeley-dsep-infra/datahub/issues/1997
RUN apt-get update > /dev/null && \
apt-get install --yes \
less \
fonts-symbola \
libx11-xcb1 \
libxtst6 \
libxrandr2 \
libasound2 \
libpangocairo-1.0-0 \
libatk1.0-0 \
libatk-bridge2.0-0 \
libgtk-3-0 \
libnss3 \
libnspr4 \
libxss1 \
nodejs \
npm \
texlive-xetex \
texlive-fonts-extra \
texlive-latex-extra \
texlive-fonts-recommended \
texlive-lang-chinese \
texlive-plain-generic \
tini > /dev/null && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*

COPY install-mambaforge.bash /tmp/install-mambaforge.bash
RUN /tmp/install-mambaforge.bash

USER ${NB_USER}

COPY environment.yml /tmp/environment.yml
COPY infra-requirements.txt /tmp/infra-requirements.txt
RUN mamba env update -p ${CONDA_DIR} -f /tmp/environment.yml && \
mamba clean -afy

# DH-327, very similar to what was done for datahub in DH-164
ENV PLAYWRIGHT_BROWSERS_PATH ${CONDA_DIR}
RUN playwright install chromium

# Install IRKernel
RUN R --quiet -e "install.packages('IRkernel', quiet = TRUE)" && \
R --quiet -e "IRkernel::installspec(prefix='${CONDA_DIR}')"

# Install extra R packages
RUN install2.r --error --skipinstalled \
## general interest
anytime \
Hmisc \
lmtest \
lubridate \
latex2exp \
MASS \
patchwork \
stargazer \
tidymodels \
wooldridge \
## machine learning
caret \
parsnip \
torch \
## 241
AER \
randomizr \
## 271
fable \
feasts \
fpp3 \
gamlr \
plm \
lme4 \
Quandl \
quantmod \
tseries \
tsibble \
vcd \
vars \
zoo

# Use simpler locking strategy
COPY file-locks /etc/rstudio/file-locks

ENTRYPOINT ["tini", "--"]
23 changes: 23 additions & 0 deletions environment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: ischool

channels:
- conda-forge

dependencies:
- syncthing==1.25.0
- jupyter-rsession-proxy==2.2.0
# https://github.com/berkeley-dsep-infra/datahub/issues/5251
- nodejs=16 # code-server requires node < 17
- jupyter-server-proxy==4.2.0
- jupyter-vscode-proxy==0.5
- code-server==4.10.1
# bug w/notebook and traitlets: https://github.com/jupyter/notebook/issues/7048
- traitlets=5.9.*
- pip:
- -r /tmp/infra-requirements.txt
- otter-grader==3.1.4
# DH-327
- nbconvert[webpdf]==7.16.4
# for notebook exporting
- nb2pdf==0.6.2
- nbpdfexport==0.2.1
13 changes: 13 additions & 0 deletions file-locks
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# https://docs.rstudio.com/ide/server-pro/load_balancing/configuration.html#file-locking

# rocker sets this to advisory, but this might be causing NFS issues.
# lets set it to the default (default: linkbased)
lock-type=linkbased

# we'll also reduce the frequency by 1/3
refresh-rate=60
timeout-interval=90

# log attempts
# enable-logging=1
# log-file=/tmp/rstudio-locking.log
29 changes: 29 additions & 0 deletions infra-requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# WARNING: Original source at scripts/infra-packages/requirements.txt
# PLEASE DO NOT EDIT ELSEWHERE
# After editing scripts/infra-packages/requirements.txt, please run
# scripts/infra-packages/sync.bash.

# This file pins versions of notebook related python packages we want
# across all hubs. This makes sure we don't need to upgrade them
# everwhere one by one.

# FIXME: Freeze this to get exact versions of all dependencies
notebook==7.0.7
jupyterlab==4.0.11
nbgitpuller==1.2.1
jupyter-resource-usage==1.0.1
# Matches version in images/hub/Dockerfile
jupyterhub==4.1.6
appmode==0.8.0
ipywidgets==8.0.7
jupyter-tree-download==1.0.1
git-credential-helpers==0.2
# Measure popularity of different packages in our hubs
# https://discourse.jupyter.org/t/request-for-implementation-instrument-libraries-actively-used-by-users-on-a-jupyterhub/7994?u=yuvipanda
git+https://github.com/shaneknapp/python-popularity-contest.git@add-error-handling
# RISE is useful for presentations - see https://github.com/berkeley-dsep-infra/datahub/issues/2527
RISE==5.7.1
# syncthing for dropbox-like functionality
jupyter-syncthing-proxy==1.0.3
# jupyter archival tool for easy user downloads
jupyter-archive==3.4.0
38 changes: 38 additions & 0 deletions install-mambaforge.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/bin/bash
# This downloads and installs a pinned version of mambaforge
set -ex

cd $(dirname $0)
MAMBAFORGE_VERSION='23.1.0-1'

URL="https://github.com/conda-forge/miniforge/releases/download/${MAMBAFORGE_VERSION}/Mambaforge-${MAMBAFORGE_VERSION}-Linux-x86_64.sh"
INSTALLER_PATH=/tmp/mambaforge-installer.sh

wget --quiet $URL -O ${INSTALLER_PATH}
chmod +x ${INSTALLER_PATH}

bash ${INSTALLER_PATH} -b -p ${CONDA_DIR}
export PATH="${CONDA_DIR}/bin:$PATH"

# Do not attempt to auto update conda or dependencies
conda config --system --set auto_update_conda false
conda config --system --set show_channel_urls true

# empty conda history file,
# 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

# Clean things out!
conda clean --all -f -y

# Remove the big installer so we don't increase docker image size too much
rm ${INSTALLER_PATH}

# Remove the pip cache created as part of installing mambaforge
rm -rf /root/.cache

chown -R $NB_USER:$NB_USER ${CONDA_DIR}

conda list -n root

0 comments on commit 0be26ba

Please sign in to comment.