/
Dockerfile
145 lines (126 loc) · 3.59 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
# Copyright (c) Jupyter Development Team.
# Distributed under the terms of the Modified BSD License.
ARG KERNEL_LANG=python
ARG PACKAGE_SOURCE=release
ARG BASE_CONTAINER=jupyter/docker-stacks-foundation:2022-11-15
FROM ${BASE_CONTAINER} AS kernel-base
ENV PATH=$PATH:$CONDA_DIR/bin
USER root
# Install appropriate kernels
# Python Kernel (ipykernel)
FROM kernel-base as kernel-python
ENV KERNEL_LANGUAGE=Python
RUN mamba install --quiet --yes \
'altair' \
'beautifulsoup4' \
'bokeh' \
'bottleneck' \
'cloudpickle' \
'conda-forge::blas=*=openblas' \
'cython' \
'dask' \
'dill' \
'h5py' \
'ipykernel'\
'ipympl'\
'ipywidgets' \
'matplotlib-base' \
'numba' \
'numexpr' \
'openpyxl' \
'pandas' \
'patsy' \
'protobuf' \
'pytables' \
'scikit-image' \
'scikit-learn' \
'scipy' \
'seaborn' \
'sqlalchemy' \
'statsmodels' \
'sympy' \
'widgetsnbextension'\
'xlrd' && \
mamba clean --all -f -y && \
fix-permissions "${CONDA_DIR}" && \
fix-permissions "/home/${NB_USER}"
# Scala Kernel (Apache Toree)
FROM kernel-base as kernel-scala
# Scala and JVM should be installed with Spark
ENV KERNEL_LANGUAGE=Scala
RUN pip install apache_toree
# R Kernel (IRKernel)
FROM kernel-base as kernel-r
ENV KERNEL_LANGUAGE=R
# R pre-requisites
RUN apt-get update --yes && \
apt-get install --yes --no-install-recommends \
fonts-dejavu \
unixodbc \
unixodbc-dev \
r-cran-rodbc \
gfortran \
gcc && \
apt-get clean && rm -rf /var/lib/apt/lists/*
# R packages including IRKernel which gets installed globally.
# r-e1071: dependency of the caret R package
RUN mamba install --quiet --yes \
'r-argparse' \
'r-base' \
'r-caret' \
'r-crayon' \
'r-devtools' \
'r-e1071' \
'r-forecast' \
'r-hexbin' \
'r-htmltools' \
'r-htmlwidgets' \
'r-irkernel' \
'r-nycflights13' \
'r-randomforest' \
'r-rcurl' \
'r-rmarkdown' \
'r-rodbc' \
'r-rsqlite' \
'r-shiny' \
'r-tidyverse' \
'unixodbc' && \
mamba clean --all -f -y && \
fix-permissions "${CONDA_DIR}" && \
fix-permissions "/home/${NB_USER}"
# `r-tidymodels` is not easy to install under arm
RUN set -x && \
arch=$(uname -m) && \
if [ "${arch}" == "x86_64" ]; then \
mamba install --quiet --yes \
'r-tidymodels' && \
mamba clean --all -f -y && \
fix-permissions "${CONDA_DIR}" && \
fix-permissions "/home/${NB_USER}"; \
fi;
# Select previous image based on KERNEL_LANG ARG value and continue
FROM kernel-${KERNEL_LANG} as kernel-image
ARG KERNEL_LANG
LABEL KERNEL_LANG=${KERNEL_LANG}
# Build images from appropriate source - release or local
FROM kernel-image AS package-release
# Install remote provisioners from PYPI
RUN pip install gateway_provisioners
# LOCAL (dev) build
FROM kernel-image AS package-local
# Install remote provisioners from local wheel
COPY gateway_provisioners*.whl /tmp/
RUN pip install /tmp/gateway_provisioners*.whl && \
rm -f /tmp/gateway_provisioners*.whl
FROM package-${PACKAGE_SOURCE} AS bootstrapped-image
# Select previous image based on PACKAGE_SOURCE ARG value and continue
ARG PACKAGE_SOURCE
ARG KERNEL_LANG
LABEL PACKAGE_SOURCE=${PACKAGE_SOURCE}
CMD /usr/local/bin/bootstrap-kernel.sh
# Install bootstrap and applicable launchers (per languages)
RUN jupyter image-bootstrap install --languages ${KERNEL_LANG}
RUN chown jovyan:users /usr/local/bin/bootstrap-kernel.sh && \
chmod 0755 /usr/local/bin/bootstrap-kernel.sh && \
chown -R jovyan:users /usr/local/bin/kernel-launchers
USER ${NB_UID}