-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
133 lines (111 loc) · 4.34 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
# Dockerfile based on:
# https://github.com/jupyterhub/repo2docker/tree/2f1914d8d66395e151c82453290f51d8c0894bf4
FROM ubuntu:18.04
# ---- SETUP ----
ENV DEBIAN_FRONTEND=noninteractive
# Set up locales properly
# Set up certificates etc properly
RUN apt-get -qq update && \
apt-get -qq install --yes --no-install-recommends locales \
wget gnupg2 ca-certificates > /dev/null && \
update-ca-certificates && \
apt-get -qq purge && \
apt-get -qq clean && \
rm -rf /var/lib/apt/lists/*
RUN echo "en_US.UTF-8 UTF-8" > /etc/locale.gen && \
locale-gen
ENV LC_ALL en_US.UTF-8
ENV LANG en_US.UTF-8
ENV LANGUAGE en_US.UTF-8
# Use bash as default shell, rather than sh
ENV SHELL /bin/bash
# Set up user
ARG NB_USER
ARG NB_UID
ENV USER ${NB_USER}
ENV HOME /home/${NB_USER}
RUN groupadd \
--gid ${NB_UID} \
${NB_USER} && \
useradd \
--comment "Default user" \
--create-home \
--gid ${NB_UID} \
--no-log-init \
--shell /bin/bash \
--uid ${NB_UID} \
${NB_USER}
RUN wget --quiet -O - https://deb.nodesource.com/gpgkey/nodesource.gpg.key | apt-key add - && \
DISTRO="bionic" && \
echo "deb https://deb.nodesource.com/node_14.x $DISTRO main" >> /etc/apt/sources.list.d/nodesource.list && \
echo "deb-src https://deb.nodesource.com/node_14.x $DISTRO main" >> /etc/apt/sources.list.d/nodesource.list
# install some base packages
RUN apt-get -qq update && \
apt-get -qq install --yes --no-install-recommends \
less unzip curl git \
xz-utils avahi-daemon netbase libgl1-mesa-glx libfontconfig1 libasound2 \
build-essential && \
apt-get -qq purge && \
apt-get -qq clean && \
rm -rf /var/lib/apt/lists/*
EXPOSE 8888
# Environment variables required for build
ENV APP_BASE /srv
ENV CONDA_DIR ${APP_BASE}/conda
ENV WOLFRAM_DIR ${APP_BASE}/wolfram
ENV WOLFRAMSCRIPT_ENTITLEMENTID O-WSDS-9826-V6NRZS7WMDZMK
ENV NB_PYTHON_PREFIX ${CONDA_DIR}/envs/notebook
ENV KERNEL_PYTHON_PREFIX ${NB_PYTHON_PREFIX}
ENV PATH ${NB_PYTHON_PREFIX}/bin:${CONDA_DIR}/bin:${PATH}
# Copy build scripts
COPY --chown=1000:1000 build-scripts/activate-conda.sh /etc/profile.d/activate-conda.sh
COPY --chown=1000:1000 build-scripts/environment.py-3.8.yml /tmp/environment.yml
COPY --chown=1000:1000 build-scripts/install-miniforge.bash /tmp/install-miniforge.bash
# ---- JUPYTER INSTALLATION: MAMBA ----
RUN TIMEFORMAT='time: %3R' && \
chmod +x /tmp/install-miniforge.bash && \
bash -c 'time /tmp/install-miniforge.bash' && \
rm /tmp/install-miniforge.bash /tmp/environment.yml
ARG REPO_DIR=${HOME}
ENV REPO_DIR ${REPO_DIR}
WORKDIR ${REPO_DIR}
RUN chown ${NB_USER}:${NB_USER} ${REPO_DIR}
ENV PATH ${HOME}/.local/bin:${REPO_DIR}/.local/bin:${PATH}
ENV CONDA_DEFAULT_ENV ${KERNEL_PYTHON_PREFIX}
COPY --chown=1000:1000 ./environment.yml ${REPO_DIR}/environment.yml
USER ${NB_USER}
RUN TIMEFORMAT='time: %3R' \
bash -c 'time mamba env update -p ${NB_PYTHON_PREFIX} -f "environment.yml" && \
time mamba clean --all -f -y && \
mamba list -p ${NB_PYTHON_PREFIX} \
'
# ---- WOLFRAM ENGINE ----
# Currently download url points to 12.2.0 - consider switching back to docker images for reproducibility
# https://hub.docker.com/r/wolframresearch/wolframengine
USER root
RUN mkdir -p ${WOLFRAM_DIR} && \
chown -R ${NB_USER}:${NB_USER} ${WOLFRAM_DIR} && \
wget https://account.wolfram.com/download/public/wolfram-engine/desktop/LINUX \
-O /tmp/Install-WolframEngine.sh && \
chmod +x /tmp/Install-WolframEngine.sh && \
/tmp/Install-WolframEngine.sh -- -auto -verbose && \
rm -f /tmp/Install-WolframEngine.sh
# add wolframengine jupyter kernel
USER ${NB_USER}
RUN cd ${WOLFRAM_DIR} && \
git clone https://github.com/okofish/WolframLanguageForJupyter.git && \
cd WolframLanguageForJupyter && \
git checkout 1429f1c86b60ba79794eace378eae4f5941fc9cf -b feature/OnDemandLicensing && \
./configure-jupyter.wls add && \
jupyter kernelspec list
# ---- WRAP UP ----
# Execute postBuild
COPY --chown=1000:1000 ./postBuild ${REPO_DIR}/postBuild
RUN chmod +x postBuild
RUN ./postBuild
# Add entrypoint
COPY --chown=1000:1000 build-scripts/repo2docker-entrypoint /usr/local/bin/repo2docker-entrypoint
RUN chmod +x /usr/local/bin/repo2docker-entrypoint
ENTRYPOINT ["/usr/local/bin/repo2docker-entrypoint"]
# Specify the default command to run
CMD ["jupyter", "notebook", "--ip", "0.0.0.0"]