forked from gorenje/sysmlv2-jupyter-docker
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Dockerfile.jupyter
101 lines (78 loc) · 3.1 KB
/
Dockerfile.jupyter
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
FROM openjdk:17-slim
##
## This Dockerfile is specifically designed to be run with the API Server
## and started via docker-compose. It makes assumptions about the existence
## of an docker internal network.
##
## wget is used to retrieve Conda and SysML Release. Inkscape and LaTeX is
## required for rendering notebooks as PDFs.
RUN apt-get --quiet --yes update && apt-get install -yqq \
gcc \
g++ \
wget \
inkscape \
texlive-fonts-recommended \
texlive-base \
texlive-xetex
##
## Non-root user is a requirement of Binder:
## https://mybinder.readthedocs.io/en/latest/tutorials/dockerfile.html
##
ARG NB_USER=sysml
ARG NB_UID=1000
ENV USER ${NB_USER}
ENV NB_UID ${NB_UID}
ENV HOME /home/${NB_USER}
RUN adduser --disabled-password \
--gecos "Default user" \
--uid ${NB_UID} \
${NB_USER}
USER root
RUN chown -R ${NB_UID} ${HOME}
## Switch to the lowly user, no more root.
USER ${NB_USER}
WORKDIR ${HOME}
##
## Miniconda installation page:
## https://docs.conda.io/en/latest/miniconda.html#linux-installers
##
RUN wget -q https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh
## Defining the RELEASE down here ensures that the previous comamnds can
## be recycled since they're not affected by the release version.
ARG RELEASE=2022-10
##
## SysML page: https://github.com/Systems-Modeling/SysML-v2-Release
##
RUN wget -q https://github.com/Systems-Modeling/SysML-v2-Release/archive/${RELEASE}.tar.gz?ts=20220819Z023100+00 -O ${RELEASE}.tar.gz
## Install MiniConda
RUN chmod 755 ${HOME}/Miniconda3-latest-Linux-x86_64.sh
RUN mkdir ${HOME}/conda
RUN ${HOME}/Miniconda3-latest-Linux-x86_64.sh -f -b -p ${HOME}/conda
RUN ${HOME}/conda/condabin/conda init
## Unpack SysML
RUN tar xzf ${RELEASE}.tar.gz
WORKDIR ${HOME}/SysML-v2-Release-${RELEASE}/install/jupyter
## This is the path that conda init setups but conda init has no effect
## here, so setup the PATH by hand. Else install.sh won't work.
ENV PATH="${HOME}/conda/bin:${HOME}/conda/condabin:/usr/local/openjdk-17/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
## Install terminal notebook editor - https://github.com/joouha/euporie
RUN pip install euporie
## Install SysMLv2 as Jupyter Kernel
RUN ./install.sh
## Point the publish command to the local API server.
RUN sed s/sysml2.intercax.com:9000/sysmlapiserver:9000/ -i ${HOME}/conda/share/jupyter/kernels/sysml/kernel.json
## Uninstall the terminal feature for security reasons
RUN pip uninstall -y terminado
WORKDIR ${HOME}/SysML-v2-Release-${RELEASE}/
## Move any files in the top level directory to the doc directory
RUN find . -maxdepth 1 -type f -exec mv \{\} doc \;
## Copy example notebooks into the image
RUN mkdir notebooks
COPY --chown=${NB_USER} notebooks/ notebooks/
# Move some top level notebooks to the toplevel
RUN mv notebooks/*/StartHere.ipynb .
RUN mv notebooks/*.ipynb .
## Trust the notebooks so that the SVG images will be displayed.
RUN find . -name \*.ipynb -exec jupyter trust \{\} \;
EXPOSE 8888
ENTRYPOINT jupyter lab --ip sysmljupyter --port 8888