-
Notifications
You must be signed in to change notification settings - Fork 33
/
Dockerfile
278 lines (218 loc) · 7.27 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
FROM ubuntu:22.04
ENV PYWIKIBOT_VERSION=8.1.2
ENV EDITOR=/bin/nano
ENV PYWIKIBOT_DIR=/srv/paws
ENV DEBIAN_FRONTEND=noninteractive
## Begin minimal setup ##
# Use bash as default shell, rather than sh
ENV SHELL /bin/bash
# Set up user
ENV NB_USER tools.paws
ENV NB_UID 52771
ENV HOME /home/paws
RUN adduser --disabled-password \
--gecos "Default user" \
--uid ${NB_UID} \
--home ${HOME} \
--force-badname \
${NB_USER}
WORKDIR ${HOME}
RUN apt-get update && \
apt-get install --yes \
python3-venv \
pip \
python3
ENV LC_ALL en_US.UTF-8
ENV LANG en_US.UTF-8
ENV LANGUAGE en_US.UTF-8
# Create venv directory, and let users install into it
ENV VENV_DIR /srv/paws
RUN install -d -o ${NB_USER} -g ${NB_USER} ${VENV_DIR}
ENV PATH=/srv/paws/pwb:/srv/paws/bin:/srv/paws:$PATH
USER ${NB_USER}
RUN python3 -m venv /srv/paws
RUN pip --no-cache-dir install -U pip setuptools wheel
# Install base notebook packages
RUN pip install --prefix=/srv/paws --no-cache-dir \
jupyterhub==4.0.0 \
notebook==6.4.12 \
jupyterlab==3.4.8
## End minimal setup ##
USER root
# Setup nodesource, because node on Ubuntu is far too old to be useful
ADD node/nodesource.gpg /etc/apt/trusted.gpg.d/nodesource.gpg
ADD node/nodesource.list /etc/apt/sources.list.d/nodesource.list
# Base building utilities that'll always be required, probably
RUN apt-get update && \
apt-get install --yes \
git \
locales \
pkg-config \
build-essential \
gcc \
apt-transport-https
RUN apt-get update --yes && \
apt-get install --yes \
python3-dev \
openjdk-11-jdk \
nodejs
# Utilities
RUN apt-get install --yes \
curl \
wget \
less \
dnsutils \
emacs \
links \
nano \
vim \
lsof \
mariadb-client
# pyaudio
RUN apt-get install --yes \
portaudio19-dev
RUN echo "en_US.UTF-8 UTF-8" > /etc/locale.gen && \
locale-gen
## Install R ##
# Use newer version of R
# Binary packages from packagemanager.rstudio.com work against this.
# Base R from Focal is only 3.6.
ADD r/cran.gpg /etc/apt/trusted.gpg.d/cran.gpg
ADD r/cran.list /etc/apt/sources.list.d/cran.list
# Install languages needed and their core dev packages
RUN apt-get update --yes && \
apt-get install --yes \
r-recommended \
r-base-dev \
r-cran-littler \
git \
curl \
gdebi \
# For R's mysql
libmariadb-dev \
# For R's curl
libcurl4-openssl-dev \
# for ipython kernels
libzmq3-dev \
# For R's devtools
libssl-dev
# Install RStudio
# give access to libssl1.1 for rstudio-server
RUN echo "deb http://archive.ubuntu.com/ubuntu/ focal main restricted" > /etc/apt/sources.list.d/focal.list
RUN apt-get update
ENV RSTUDIO_SERVER_URL https://download2.rstudio.org/server/bionic/amd64/rstudio-server-2022.02.3-492-amd64.deb
RUN curl --silent --location --fail ${RSTUDIO_SERVER_URL} > /tmp/rstudio-server.deb
RUN gdebi -n /tmp/rstudio-server.deb && rm /tmp/rstudio-server.deb
# remove focal repo
RUN rm /etc/apt/sources.list.d/focal.list && apt-get update
# Create user owned R libs dir
# This lets users temporarily install packages
ENV R_LIBS_USER /srv/r
RUN install -d -o ${NB_USER} -g ${NB_USER} ${R_LIBS_USER}
# R_LIBS_USER is set by default in /etc/R/Renviron, which RStudio loads.
# We uncomment the default, and set what we wanna - so it picks up
# the packages we install. Without this, RStudio doesn't see the packages
# that R does.
# Stolen from https://github.com/jupyterhub/repo2docker/blob/6a07a48b2df48168685bb0f993d2a12bd86e23bf/repo2docker/buildpacks/r.py
RUN sed -i -e '/^R_LIBS_USER=/s/^/#/' /etc/R/Renviron && \
echo "R_LIBS_USER=${R_LIBS_USER}" >> /etc/R/Renviron
USER ${NB_USER}
RUN pip install --no-cache-dir \
jupyter-server-proxy \
rpy2 \
git+https://github.com/toolforge/jupyter-rsession-proxy.git@57d89b4
# Set CRAN mirror to rspm before we install anything
COPY r/Rprofile.site /usr/lib/R/etc/Rprofile.site
# RStudio needs its own config
COPY r/rsession.conf /etc/rstudio/rsession.conf
# Install the R Kernel
RUN r -e "install.packages('IRkernel', version='1.3.2')" && \
r -e "IRkernel::installspec(prefix='${VENV_DIR}')" && \
rm -rf /tmp/downloaded_packages
## Done installing R
USER root
## Setup OpenRefine
ENV OPENREFINE_DIR /srv/openrefine
ENV PATH=$PATH:$OPENREFINE_DIR
RUN mkdir -p ${OPENREFINE_DIR} && cd ${OPENREFINE_DIR} && \
curl -L 'https://github.com/OpenRefine/OpenRefine/releases/download/3.7.3/openrefine-linux-3.7.3.tar.gz' | tar xzf - --strip=1
USER root
RUN apt-get install --yes unzip
USER ${NB_USER}
ENV REFINE_DIR /home/paws
RUN pip install --no-cache-dir \
git+https://github.com/innovationOUtside/nb_serverproxy_openrefine@f10677f15cab1f1a0f6a4e80ee65e3598a041fae
USER root
RUN wget https://github.com/OpenRefine/CommonsExtension/releases/download/v0.1.1/openrefine-commons-0.1.1.zip -O /tmp/openrefine-commonsextension.zip
RUN unzip /tmp/openrefine-commonsextension.zip -d ${OPENREFINE_DIR}/webapp/extensions/
## Done setting up OpenRefine
USER root
# Machine-learning type stuff
RUN apt-get update && \
apt-get install --yes \
# For scipy & friends
libblas-dev \
liblapack-dev \
libquadmath0 \
gfortran \
# for lxml
libxml2-dev \
libxslt1-dev \
# for matplotlib
libfreetype6-dev \
libpng-dev \
# for ipython kernels
libzmq3-dev \
libreadline-dev \
# For PDFs and stuff
pandoc \
texlive-xetex
## Install Julia
# Install Julia directories and depot path
ENV PATH=$PATH:/srv/julia/bin
ENV JULIA_DEPOT_PATH /srv/julia-depot/
RUN install -d -o ${NB_USER} -g ${NB_USER} /srv/julia
RUN install -d -o ${NB_USER} -g ${NB_USER} ${JULIA_DEPOT_PATH}
USER ${NB_USER}
# install julia and julia kernel
COPY install-julia /tmp/install-julia
RUN /tmp/install-julia
## Done Installing Julia
RUN pip install --no-cache-dir \
jupyterlab-link-share>=0.2.4 \
nbgitpuller \
# voila # 0.4.0 downgrades jupyter-server to 1.24.0 appears to work on 2.0 from 0.5.0, though not yet released.
bash_kernel
# Install the bash kernel
RUN python -m bash_kernel.install --sys-prefix
# Install mass amount of python libraries!
COPY --chown=tools.paws:tools.paws requirements.txt /tmp/requirements.txt
RUN pip --no-cache-dir install -r /tmp/requirements.txt
# Install pywikibot
RUN git clone \
--branch $PYWIKIBOT_VERSION \
--depth 1 \
--recurse-submodules \
--shallow-submodules \
https://gerrit.wikimedia.org/r/pywikibot/core.git \
/srv/paws/pwb
RUN pip install --no-cache-dir \
/srv/paws/pwb[eventstreams,graphviz,google,isbn,memento,mysql,mwoauth,html]
COPY --chown=tools.paws:tools.paws user-config.py /srv/paws/
COPY --chown=tools.paws:tools.paws user-fixes.py /srv/paws/
COPY install-extensions /usr/local/bin/
RUN /usr/local/bin/install-extensions
COPY banner /etc/bash.bashrc
# use custom css to hide clusters tab
COPY --chown=tools.paws:tools.paws hide_clusters_tab.css /home/paws/.jupyter/custom/custom.css
## Install SPARQL
USER root
RUN apt-get update && \
apt-get install --yes \
# For sparql kernel
graphviz
USER ${NB_USER}
RUN pip install --no-cache-dir sparqlkernel
RUN python3 -m jupyter sparqlkernel install --sys-prefix
## End SPARQL Install
EXPOSE 8888