Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions docker/jupyterlab/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Content

Container recipes derived from the Jupyter Docker Stacks at https://jupyter-docker-stacks.readthedocs.io

63 changes: 63 additions & 0 deletions docker/jupyterlab/jupyterlab-SurfaceTopography/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# Build from within repository root
#
# Modify conda enviornment running jupyter notebooks
FROM jupyter/minimal-notebook:latest

USER root

COPY --chown=${NB_UID}:${NB_GID} jupyterlab-SurfaceTopography/conda-requirements.in "/home/${NB_USER}/"
RUN pip install pip-tools
RUN pip-compile "/home/${NB_USER}/conda-requirements.in" > "/home/${NB_USER}/conda-requirements.txt"
RUN pip install --quiet --no-cache-dir --requirement "/home/${NB_USER}/conda-requirements.txt" && \
fix-permissions "${CONDA_DIR}" && \
fix-permissions "/home/${NB_USER}"

# FROM imkteksim/dtool-jupyter:latest
# Install from requirements.txt file
RUN apt-get --yes update && \
apt-get --yes install \
clang cmake curl g++ gdb git m4 wget \
libboost-test-dev \
libcurl4-openssl-dev \
libeigen3-dev \
libfftw3-dev \
libgmp-dev \
libnetcdf-dev \
libopenblas-base \
libopenblas-dev \
python3-pip \
python3-dev \
python3-netcdf4 && \
apt-get clean && \
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

# Workaround for building packages and introducing an ipykernel outside of the jupyterlab conda environment
RUN PATH=$(echo "$PATH" | sed -e 's|/opt/conda[^:]*:||g') && ( \
pip install --no-binary numpy SurfaceTopography && \
pip install ipykernel && \
python3 -m ipykernel install --name SurfaceTopography --display-name "Python (SurfaceTopography)") && \
fix-permissions "${CONDA_DIR}" && \
fix-permissions "/home/${NB_USER}"

# Workaround for modifying system python outside of the jupyterlab conda environment
COPY --chown=${NB_UID}:${NB_GID} jupyterlab-SurfaceTopography/requirements.txt "/home/${NB_USER}/"
RUN PATH="$(echo "$PATH" | sed -e 's|/opt/conda[^:]*:||g')" && ( \
pip install --quiet --no-cache-dir --requirement "/home/${NB_USER}/requirements.txt" )

COPY jupyterlab-SurfaceTopography/start-wrapper.sh /usr/local/bin/

# Custom fonts config
COPY jupyterlab-SurfaceTopography/etc/fonts.conf /etc/fonts/conf.avail/99-injected.conf
RUN ln -s /etc/fonts/conf.avail/99-injected.conf /etc/fonts/conf.d/99-injected.conf
RUN mkdir -p /fonts

# Install from requirements.txt file
RUN apt-get --yes update && \
apt-get --yes install fontconfig && \
apt-get clean && \
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

WORKDIR /home/${NB_USER}/work
USER ${NB_UID}

CMD ["start-wrapper.sh", "start-notebook.sh"]
161 changes: 161 additions & 0 deletions docker/jupyterlab/jupyterlab-SurfaceTopography/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@
# Sample setup jupyterlab-SurfaceTopography

## Changes to the container

This docker image bases on the [Jupyter Docker Stacks](https://jupyter-docker-stacks.readthedocs.io/en/latest/).
These base images use condato run a JupyterLab instance. Extensions to the Jupyter ecosystem (i.e. `jupytext`)
must hence go into the `conda-requirements.in` file.

`SurfaceTopography` does not work well within a conda environment. Instead, this image introduces a separate
ipython kernel `SurfaceTopography` that just uses the container-internal system Python and a few system libraries,
i.e. `numpy`. Anything needed for production in connection with `SurfaceTopography` goes in `requirements.in` or
into `requirements.txt` directly. When modifying `requirements.in`, regenerate `requirments.txt`with pinned versions
as described below.

If in need to quickly modify the `SurfaceTopography` kernel environment at runtime, pay attention to
breaking out of the default conda enviornment in the shell

* `conda deactivate`, and
* removing any conda-related artifacts from the `$PATH`, i.e. with `export PATH=$(echo "$PATH" | sed -e 's|/opt/conda[^:]*:||g')`

The latter is necessary to avoid conda compiler interfering with custom build steps when compiling against system libraries.

## Python requirements

To (re-)generate a `requirements.txt` with fixed package versions, use

```console
python3 -m venv venv
source venv/bin/activate

pip install --upgrade pip
pip install wheel
pip install pip-tools

pip-compile requirements.in > requirements.txt
```

## Build container

Build container from parent directory (`docker/jupyterlab`) with

docker build -t imteksim/jupyterlab-surfacetopography -f jupyterlab-SurfaceTopography/Dockerfile .

or write directly to tar for transfer with

docker build --output type=tar,dest=imteksim-jupyterlab-SurfaceTopography.tar -t imteksim/jupyterlab-surfacetopography -f jupyterlab-SurfaceTopography/Dockerfile .

and load at target destination with

docker load --input imteksim-jupyterlab-SurfaceTopography.tar

## Certificates with acme.sh

Identify the public hostname used for issuing SSL certificates, i.e.

export HOSTNAME="SOME-UUID.fr.bw-cloud-instance.org"

for a public bw-cloud instance and a seecure directory to hold certificates, i.e.

export CERTDIR=${HOME}/acme.sh

and use

mkdir -p acme.sh

# zerossl
docker run -v "${CERTDIR}:/acme.sh" --rm neilpang/acme.sh:latest \
acme.sh --register-account -m ${MY_EMAIL_ADDRESS}
docker run -v "${CERTDIR}:/acme.sh" -p 80:80 --rm neilpang/acme.sh:latest \
acme.sh --issue -d "${HOSTNAME}" --standalone --force

# or, letsencrypt
docker run -v "${CERTDIR}:/acme.sh" --rm neilpang/acme.sh:latest \
acme.sh --server letsencrypt --register-account -m ${MY_EMAIL_ADDRESS}
docker run -v "${CERTDIR}:/acme.sh" -p 80:80 --rm neilpang/acme.sh:latest \
acme.sh --server letsencrypt --issue -d "${HOSTNAME}" --standalone --force

sudo chown -R $USER:$USER $HOME/acme.sh

to (re-)issue certiicates.

## Fonts

Microsoft fonts can be installed with

sudo apt-get install -y fontconfig
sudo apt-get install -y ttf-mscorefonts-installer
sudo fc-cache -f

Check with

$ fc-match Arial
LiberationSans-Regular.ttf: "Liberation Sans" "Regular"

Find location of installed fonts with

$ dpkg-query -L ttf-mscorefonts-installer
/.
/usr
/usr/lib
/usr/lib/msttcorefonts
/usr/lib/msttcorefonts/update-ms-fonts
/usr/share
/usr/share/doc
/usr/share/doc/ttf-mscorefonts-installer
/usr/share/doc/ttf-mscorefonts-installer/README.Debian
/usr/share/doc/ttf-mscorefonts-installer/changelog.gz
/usr/share/doc/ttf-mscorefonts-installer/copyright
/usr/share/fonts
/usr/share/fonts/truetype
/usr/share/lintian
/usr/share/lintian/overrides
/usr/share/lintian/overrides/ttf-mscorefonts-installer
/usr/share/package-data-downloads
/usr/share/package-data-downloads/ttf-mscorefonts-installer
/var
/var/lib
/var/lib/msttcorefonts

## Run Jupyter Lab

Identify a persistent workspace directory, i.e.

export WORKDIR=${HOME}/work

and, optionally, a directory of additional fonts to make available to matplotlib, i.e. as above

export FONTDIR=/usr/share/fonts/truetype/msttcorefonts

Run public Jupyter Lab on default https port with fixed password

docker run -d --rm -p 443:443 \
-v ${WORKDIR}:/home/jovyan/work \
-v ${FONTDIR}:/fonts \
-v ${CERTDIR}/${HOSTNAME}:/etc/ssl/notebook \
imteksim/jupyterlab-surfacetopography \
start-notebook.sh \
--ServerApp.keyfile=/etc/ssl/notebook/${HOSTNAME}.key \
--ServerApp.certfile=/etc/ssl/notebook/${HOSTNAME}.cer \
--ServerApp.password='argon2:$argon2id$v=19$m=10240,t=10,p=8$Jg1gFoiE0ybmBCVG+1s6uA$Jxz4/1591Z7so7JK2M1lRA' \
--ServerApp.ip='*' \
--ServerApp.port=443

Note that the hash of the password is passed.

argon2:$argon2id$v=19$m=10240,t=10,p=8$Jg1gFoiE0ybmBCVG+1s6uA$Jxz4/1591Z7so7JK2M1lRA

corresponds to password `imtek-simulation` and has been generated with

from notebook.auth import passwd
passwd()

Add

--user root -e GRANT_SUDO=yes -e NB_GID=100 -e NB_USER=jovyan

to the docker command line arguments if you need passwordless `sudo` within the container.

## Access Jupyter Lab web interface

Make sure `https` port 443 is reachable, navigate browser to `https://${HOSTNAME}` and log in with password specified on Jupyter Lab launch.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
jupyterlab_autorun_cells
jupytext
6 changes: 6 additions & 0 deletions docker/jupyterlab/jupyterlab-SurfaceTopography/etc/fonts.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<!-- ~/.fonts.conf for per-user font configuration -->
<fontconfig>
<dir>/fonts</dir>
</fontconfig>
36 changes: 36 additions & 0 deletions docker/jupyterlab/jupyterlab-SurfaceTopography/requirements.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
click
pep517
tomli
adhesion
ase
asgiref
contactmechanics
cycler
dtool
dtool_lookup_api
dtoolcore
dtool-s3
gromacs
GromacsWrapper
imteksimfw
ipython
ipywidgets
Jinja2
matplotlib
MDAnalysis
miniball
nglview
numpy
openpyxl
ovito<=3.6.0
pandas
panedr
ParmEd
pymongo
pytest
PySide2
PyYAML
scipy
scikit-learn
seaborn
git+https://github.com/IMTEK-Simulation/code-snippets.git
Loading