/
Dockerfile
81 lines (66 loc) · 2.62 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
# The Dockerfile tells Docker how to construct the image.
FROM python:3
LABEL maintainer="Melle Sieswerda <m.sieswerda@iknl.nl>"
# ------------------------------------------------------------------------------
# Preliminaries
# ------------------------------------------------------------------------------
# Create a default user
ARG NB_USER=jupyter
ARG NB_UID=1000
ENV USER ${NB_USER}
ENV NB_UID ${NB_UID}
ENV HOME /home/${NB_USER}
ENV THOMAS_DIR /home/${NB_USER}/thomas
RUN adduser --disabled-password \
--gecos "Default user" \
--uid ${NB_UID} \
${NB_USER}
# Make sure ~/.local/bin exists and is in PATH
RUN mkdir -p ${HOME}/.local/bin
ENV PATH="${PATH}:${HOME}/.local/bin"
# Set the root password
USER root
RUN echo "root:root" | chpasswd
# Install nodejs >= 12
RUN curl -sL https://deb.nodesource.com/setup_12.x | bash -
RUN apt-get update
RUN apt-get install -y nodejs
# Install yarn properly. The version of yarn that's available by default is
# just weird.
RUN apt-get remove cmdtest
RUN npm install --global yarn
# ------------------------------------------------------------------------------
# JupyterLab settings (specifically: keyboard shortcuts & port)
# ------------------------------------------------------------------------------
COPY lab ${HOME}/.jupyter/lab
EXPOSE 8888
# ------------------------------------------------------------------------------
# Python package installation
# ------------------------------------------------------------------------------
COPY notebooks ${THOMAS_DIR}/thomas-core/notebooks
COPY tests ${THOMAS_DIR}/thomas-core/tests
COPY thomas ${THOMAS_DIR}/thomas-core/thomas
COPY setup.py ${THOMAS_DIR}/thomas-core
COPY utest.py ${THOMAS_DIR}/thomas-core
COPY test.sh ${THOMAS_DIR}/thomas-core
COPY README.md ${THOMAS_DIR}/thomas-core
# Make sure files are owned by
RUN chown -R ${NB_UID}:${USER} ${HOME}
RUN chown -R ${NB_UID}:${USER} ${THOMAS_DIR}/thomas-core/
# ------------------------------------------------------------------------------
# Run as ${USER} !
# ------------------------------------------------------------------------------
USER ${USER}
ENV PATH="${PATH}:${USER}/.local/bin"
WORKDIR ${THOMAS_DIR}/thomas-core
RUN pip install -e .
# Install the BayesianNetworkWidget (for use in JupyterLab) and the client.
# These are referenced
# RUN pip install git+https://github.com/mellesies/thomas-jupyter-widget@jupyter3
# RUN pip install git+https://github.com/mellesies/thomas-client
RUN pip install thomas-jupyter-widget
RUN pip install thomas-client
RUN ./utest.py
# WORKDIR ${HOME}/notebooks
RUN jupyter serverextension enable jupyterlab
CMD jupyter lab --ip=0.0.0.0 --allow-root --LabApp.token=''