Skip to content

Commit 0ca5f69

Browse files
committed
Upgrade user image
- Bump to Ubuntu 20.04. This brings in lots of newer packages, but particularly Python 3.8 (https://phabricator.wikimedia.org/T265957). Many new packages are 3.7+ only. - Use upstream R deb packages (https://cran.r-project.org/bin/linux/ubuntu/), than those from Ubuntu. This is maintained by the same folks who do R in debian. This brings us R 4.x (https://phabricator.wikimedia.org/T268923), but more importantly enables binary package installation. - Use packagemanager.rstudio.com to install R packages. This is a huge benefit - it can install any version of packges, and it has binary package builds for most of them! These binary packages are built against focal + the upstream R debs. See announcement info here: https://blog.rstudio.com/2020/07/01/announcing-public-package-manager/. This reduces the user image build time a *lot* - Put R packages in /srv/r, to match /srv/paws for our venv. Users can more easily install R packages temporarily now, and we don't mess with things under `/usr`. It also simplifies our Dockerfile, reducing number of times we have to switch to root. - Redirect most stdout from apt-get to /dev/null. We still get stderr, so no real functionality lost. - Remove some explicit nbextension enable / install commands. These are no longer necessary. - Specify a loose pin for notebook & jupyterlab versions.
1 parent 485a36e commit 0ca5f69

File tree

5 files changed

+50
-62
lines changed

5 files changed

+50
-62
lines changed

images/singleuser/Dockerfile

Lines changed: 36 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM ubuntu:18.04
1+
FROM ubuntu:20.04
22

33
ENV EDITOR=/bin/nano
44
ENV PYWIKIBOT2_DIR=/srv/paws
@@ -21,14 +21,15 @@ RUN adduser --disabled-password \
2121
WORKDIR ${HOME}
2222

2323
# Base building utilities that'll always be required, probably
24-
RUN apt-get update --yes
25-
RUN apt-get install --yes \
24+
RUN apt-get update > /dev/null && \
25+
apt-get install --yes \
2626
git \
2727
locales \
2828
pkg-config \
2929
build-essential \
3030
gcc \
31-
apt-transport-https
31+
apt-transport-https > /dev/null
32+
3233
RUN echo "en_US.UTF-8 UTF-8" > /etc/locale.gen && \
3334
locale-gen
3435

@@ -40,16 +41,23 @@ ENV LANGUAGE en_US.UTF-8
4041
ADD node/nodesource.gpg.key /etc/apt/trusted.gpg.d/nodesource.gpg.key
4142
ADD node/nodesource.list /etc/apt/sources.list.d/nodesource.list
4243
RUN apt-key add /etc/apt/trusted.gpg.d/nodesource.gpg.key
43-
RUN apt-get update --yes
44+
45+
# Use newer version of R
46+
# Binary packages from packagemanager.rstudio.com work against this.
47+
# Base R from Focal is only 3.6.
48+
RUN apt-key adv --keyserver keyserver.ubuntu.com --recv-keys E298A3A825C0D65DFD57CBB651716619E084DAB9
49+
RUN echo "deb https://cloud.r-project.org/bin/linux/ubuntu focal-cran40/" > /etc/apt/sources.list.d/cran.list
4450

4551
# Install languages needed and their core dev packages
46-
RUN apt-get install --yes \
52+
RUN apt-get update --yes > /dev/null && \
53+
apt-get install --yes \
4754
python3 \
4855
python3-dev \
4956
python3-venv \
5057
r-recommended \
5158
r-base-dev \
52-
nodejs
59+
r-cran-littler \
60+
nodejs > /dev/null
5361

5462
# Utilities
5563
RUN apt-get install --yes \
@@ -61,7 +69,7 @@ RUN apt-get install --yes \
6169
links \
6270
nano \
6371
vim \
64-
mariadb-client
72+
mariadb-client > /dev/null
6573

6674
# Machine-learning type stuff
6775
RUN apt-get install --yes \
@@ -80,42 +88,49 @@ RUN apt-get install --yes \
8088
libzmq3-dev \
8189
libreadline-dev \
8290
# For R's mysql
83-
libmariadb-client-lgpl-dev \
91+
libmariadb-dev \
8492
# For R's curl
8593
libcurl4-openssl-dev \
8694
# For R's devtools
8795
libssl-dev \
8896
# For PDFs and stuff
8997
pandoc \
90-
texlive-xetex
98+
texlive-xetex > /dev/null
99+
100+
# Create user owned R libs dir
101+
# This lets users temporarily install packages
102+
ENV R_LIBS_USER /srv/r
103+
RUN install -d -o ${NB_USER} -g ${NB_USER} ${R_LIBS_USER}
104+
105+
# Create venv directory, and let users install into it
106+
ENV VENV_DIR /srv/paws
107+
RUN install -d -o ${NB_USER} -g ${NB_USER} ${VENV_DIR}
91108

92-
RUN mkdir -p /srv/paws && chown ${NB_USER}:${NB_USER} /srv/paws
93109
ENV PATH=/srv/paws/pwb:/srv/paws/bin:/srv/paws:$PATH
94110

95111
USER ${NB_USER}
96-
RUN python3.6 -m venv /srv/paws
112+
RUN python3 -m venv /srv/paws
97113

98114
# Install base notebook packages
99115
RUN pip install --no-cache-dir \
100116
jupyterhub==1.1.0 \
101-
notebook \
102-
jupyterlab \
117+
notebook==6.3.* \
118+
jupyterlab==3.* \
103119
bash_kernel
104120

105121
# Install the bash kernel
106122
RUN python -m bash_kernel.install --sys-prefix
107123

108-
# Install the R Kernel and libraries
109-
COPY install-r /usr/local/bin/install-r
124+
# Set CRAN mirror to rspm before we install anything
125+
COPY Rprofile.site /usr/lib/R/etc/Rprofile.site
110126

111-
# We need root simply to install the kernelspec lol
112-
# https://github.com/IRkernel/IRkernel/issues/495
113-
USER root
114-
RUN /usr/local/bin/install-r
127+
# Install the R Kernel
128+
RUN r -e "install.packages('IRkernel', version='1.1.1')" && \
129+
r -e "IRkernel::installspec(prefix='${VENV_DIR}')" && \
130+
rm -rf /tmp/downloaded_packages
115131

116132
# Install mass amount of python libraries!
117133
COPY --chown=tools.paws:tools.paws requirements.txt /tmp/requirements.txt
118-
USER ${NB_USER}
119134

120135
RUN pip --no-cache-dir install -r /tmp/requirements.txt
121136

@@ -130,12 +145,9 @@ RUN /usr/local/bin/install-pwb
130145
COPY install-extensions /usr/local/bin/
131146
RUN /usr/local/bin/install-extensions
132147

133-
134148
COPY banner /etc/bash.bashrc
135149

136150
# use custom css to hide clusters tab
137151
COPY --chown=tools.paws:tools.paws hide_clusters_tab.css /home/paws/.jupyter/custom/custom.css
138152

139-
USER ${NB_USER}
140-
141153
EXPOSE 8888

images/singleuser/Rprofile.site

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Use RStudio's CRAN mirror to get binary packages
2+
# 'latest' just means it has all available versions.
3+
# We can specify version numbers in devtools::install_version
4+
options(repos = c(CRAN = "https://packagemanager.rstudio.com/all/__linux__/focal/latest"))
5+
6+
# RStudio's CRAN mirror needs this to figure out which binary package to serve.
7+
# If not set properly, it will just serve up source packages
8+
# Quite hilarious, IMO.
9+
# See https://docs.rstudio.com/rspm/admin/binaries.html
10+
options(HTTPUserAgent = sprintf("R/%s R (%s)", getRversion(), paste(getRversion(), R.version$platform, R.version$arch, R.version$os)))

images/singleuser/install-extensions

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,16 @@
11
#!/bin/bash
2+
set -euo pipefail
3+
24
pip install --no-cache-dir \
35
pythreejs \
46
ipyleaflet \
57
bqplot \
68
RISE \
79
py-heat-magic \
8-
nbresuse \
10+
jupyter-resource-usage \
911
git+https://github.com/toolforge/nbpawspublic@main \
1012

1113

12-
jupyter nbextension install --py widgetsnbextension --sys-prefix
13-
jupyter nbextension enable --py widgetsnbextension --sys-prefix
14-
15-
jupyter nbextension install --py ipyleaflet --sys-prefix
16-
jupyter nbextension enable --py ipyleaflet --sys-prefix
17-
18-
jupyter nbextension install --py bqplot --sys-prefix
19-
jupyter nbextension enable --py bqplot --sys-prefix
20-
21-
jupyter nbextension install --py pythreejs --sys-prefix
22-
jupyter nbextension enable --py pythreejs --sys-prefix
23-
24-
jupyter nbextension install --py rise --sys-prefix
25-
jupyter nbextension enable --py rise --sys-prefix
26-
27-
jupyter serverextension enable --py nbresuse --sys-prefix
28-
jupyter nbextension enable --py nbresuse --sys-prefix
29-
30-
jupyter serverextension enable --py jupyterlab --sys-prefix
31-
3214
jupyter nbextension install --py nbpawspublic --sys-prefix
3315
jupyter nbextension enable --py nbpawspublic --sys-prefix
3416

images/singleuser/install-r

Lines changed: 0 additions & 16 deletions
This file was deleted.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
deb https://deb.nodesource.com/node_10.x bionic main
1+
deb https://deb.nodesource.com/node_14.x focal main
22

0 commit comments

Comments
 (0)