Skip to content

Commit 8ba30b1

Browse files
committed
add dockerfile and workflow to build a jupyter
1 parent 60d6cad commit 8ba30b1

File tree

14 files changed

+554
-16
lines changed

14 files changed

+554
-16
lines changed

.github/workflows/docker-jupyter-image.yml

Lines changed: 37 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,39 @@
1-
name: ghcr
2-
#on:
3-
# push:
4-
# branches: [ "main" ]
5-
# pull_request:
6-
# branches: [ "main" ]
1+
name: ghcr-jupyter
2+
on:
3+
push:
4+
branches: [ "main" ]
5+
76
jobs:
8-
build:
7+
build-amd64:
98
runs-on: ubuntu-latest
9+
if: github.repository == 'stfc/janus-core'
10+
permissions:
11+
packages: write
12+
contents: read
13+
steps:
14+
- name: 'clone the repo'
15+
uses: actions/checkout@v4
16+
- name: 'login to ghcr'
17+
uses: docker/login-action@v3
18+
with:
19+
registry: ghcr.io
20+
username: ${{github.actor}}
21+
password: ${{secrets.GITHUB_TOKEN}}
22+
- name: Set up Docker Buildx
23+
uses: docker/setup-buildx-action@v3
24+
25+
- name: Build and push Docker image
26+
uses: docker/build-push-action@v5
27+
with:
28+
context: ./containers
29+
file: ./containers/Dockerfile.jupyter
30+
push: true
31+
tags: |
32+
ghcr.io/stfc/janus-core/jupyter:amd64-${{ github.sha }}
33+
ghcr.io/stfc/janus-core/jupyter:amd64-latest
34+
build-arm64:
35+
runs-on: ubuntu-latest-arm
36+
if: github.repository == 'stfc/janus-core'
1037
permissions:
1138
packages: write
1239
contents: read
@@ -26,8 +53,8 @@ jobs:
2653
uses: docker/build-push-action@v5
2754
with:
2855
context: ./containers
29-
file: ./containters/Dockerfile.jupyter
56+
file: ./containers/Dockerfile.jupyter
3057
push: true
3158
tags: |
32-
ghcr.io/stfc/janus-core/jupyter:${{ github.sha }}
33-
ghcr.io/stfc/janus-core/jupyter:latest
59+
ghcr.io/stfc/janus-core/jupyter:arm64-${{ github.sha }}
60+
ghcr.io/stfc/janus-core/jupyter:arm64-latest
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: ghcr-marimo
2+
on:
3+
push:
4+
branches: [ "main" ]
5+
6+
jobs:
7+
build-amd64:
8+
runs-on: ubuntu-latest
9+
if: github.repository == 'stfc/janus-core'
10+
permissions:
11+
packages: write
12+
contents: read
13+
steps:
14+
- name: 'clone the repo'
15+
uses: actions/checkout@v4
16+
- name: 'login to ghcr'
17+
uses: docker/login-action@v3
18+
with:
19+
registry: ghcr.io
20+
username: ${{github.actor}}
21+
password: ${{secrets.GITHUB_TOKEN}}
22+
- name: Set up Docker Buildx
23+
uses: docker/setup-buildx-action@v3
24+
25+
- name: Build and push Docker image
26+
uses: docker/build-push-action@v5
27+
with:
28+
context: ./containers
29+
file: ./containers/Dockerfile.marimo
30+
push: true
31+
tags: |
32+
ghcr.io/stfc/janus-core/marimo:amd64-${{ github.sha }}
33+
ghcr.io/stfc/janus-core/marimo:amd64-latest
34+
build-arm64:
35+
runs-on: ubuntu-latest-arm
36+
if: github.repository == 'stfc/janus-core'
37+
permissions:
38+
packages: write
39+
contents: read
40+
steps:
41+
- name: 'clone the repo'
42+
uses: actions/checkout@v4
43+
- name: 'login to ghcr'
44+
uses: docker/login-action@v3
45+
with:
46+
registry: ghcr.io
47+
username: ${{github.actor}}
48+
password: ${{secrets.GITHUB_TOKEN}}
49+
- name: Set up Docker Buildx
50+
uses: docker/setup-buildx-action@v3
51+
52+
- name: Build and push Docker image
53+
uses: docker/build-push-action@v5
54+
with:
55+
context: ./containers
56+
file: ./containers/Dockerfile.marimo
57+
push: true
58+
tags: |
59+
ghcr.io/stfc/janus-core/marimo:arm64-${{ github.sha }}
60+
ghcr.io/stfc/janus-core/marimo:arm64-latest

README.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ Tools for machine learnt interatomic potentials
1717
- [Features](#features)
1818
- [Python interface](#python-interface)
1919
- [Command line interface](#command-line-interface)
20+
- [Docker/Podman images](#dockerpodman-images)
2021
- [Development](#development)
2122
- [License](#license)
2223
- [Funding](#funding)
@@ -294,6 +295,41 @@ This will run a singlepoint energy calculation on `KCl.cif` using the [MACE-MP](
294295
Minimal and full example configuration files for all calculations can be found
295296
[here](https://stfc.github.io/janus-core/examples/index.html).
296297

298+
## Docker/Podman images
299+
300+
You can use `janus_core` in a JupyterHub or marimo environment using [docker](https://www.docker.com) or [podman](https://podman.io/). We provide regularly updated docker/podman images, which can be dowloaded by running:
301+
302+
```shell
303+
docker pull ghcr.io/stfc/janus-core/jupyter:amd64-latest
304+
305+
docker pull ghcr.io/stfc/janus-core/marimo:amd64-latest
306+
```
307+
or using podman
308+
309+
```shell
310+
podman pull ghcr.io/stfc/janus-core/jupyter-amd64:latest
311+
312+
podman pull ghcr.io/stfc/janus-core/marimo-amd64:latest
313+
```
314+
315+
for amd64 architecture, if you require arm64 replace amd64 with arm64 above, and next instructions.
316+
317+
To start, for marimo run:
318+
319+
```shell
320+
321+
podman run --rm --security-opt seccomp=unconfined -p 8842:8842 ghcr.io/stfc/janus-core/marimo:amd64-latest
322+
323+
```
324+
or for JupyterHub, run:
325+
326+
```
327+
podman run --rm --security-opt seccomp=unconfined -p 8888:8888 ghcr.io/stfc/janus-core/jupyter:amd64-latest
328+
```
329+
330+
For more details on how to share your filesystem and so on you can refer to this documentation: https://summer.ccp5.ac.uk/introduction.html#run-locally.
331+
332+
297333

298334
## Development
299335

containers/Dockerfile.jupyter

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,40 @@ RUN set -x && \
105105
fix-permissions "${CONDA_DIR}" && \
106106
fix-permissions "/home/${NB_USER}"
107107

108+
# setup the notebook... pretty basic stuff
109+
USER ${NB_UID}
110+
111+
WORKDIR /tmp
112+
RUN mamba install --yes \
113+
'jupyterhub-singleuser' \
114+
'jupyterlab' \
115+
'nbclassic' \
116+
# Sometimes, when the new version of `jupyterlab` is released, latest `notebook` might not support it for some time
117+
# Old versions of `notebook` (<v7) didn't have a restriction on the `jupyterlab` version, and old `notebook` is getting installed
118+
# That's why we have to pin the minimum notebook version
119+
# More info: https://github.com/jupyter/docker-stacks/pull/2167
120+
'notebook>=7.2.2' && \
121+
jupyter server --generate-config && \
122+
mamba clean --all -f -y && \
123+
jupyter lab clean && \
124+
rm -rf "/home/${NB_USER}/.cache/yarn" && \
125+
fix-permissions "${CONDA_DIR}" && \
126+
fix-permissions "/home/${NB_USER}"
127+
128+
ENV JUPYTER_PORT=8888
129+
EXPOSE $JUPYTER_PORT
130+
131+
# Configure container startup
132+
CMD ["start-notebook.py"]
133+
134+
# Copy local files as late as possible to avoid cache busting
135+
COPY start-notebook.py start-notebook.sh start-singleuser.py start-singleuser.sh /usr/local/bin/
136+
COPY jupyter_server_config.py /etc/jupyter/
137+
138+
# Fix permissions on /etc/jupyter as root
139+
USER root
140+
RUN fix-permissions /etc/jupyter/
141+
108142
RUN rm -rf "/home/${NB_USER}/.cache/"
109143

110144
# Switch back to jovyan to avoid accidental container runs as root
@@ -156,8 +190,8 @@ RUN mamba install --yes \
156190
'sympy' \
157191
'widgetsnbextension'\
158192
'xlrd' \
159-
'meson' \
160-
'spglib' && \
193+
'gxx' \
194+
'spglib' 'jupyter-server-proxy' 'jupyter-collaboration' && \
161195
mamba clean --all -f -y && \
162196
fix-permissions "${CONDA_DIR}" && \
163197
fix-permissions "/home/${NB_USER}"
@@ -183,5 +217,6 @@ RUN . /opt/conda/bin/activate && \
183217
mamba clean --all -f -y && \
184218
rm -rf "/home/${NB_USER}/.cache"
185219

220+
EXPOSE 8888
186221

187222
WORKDIR "${HOME}"

containers/Dockerfile.marimo

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
FROM python:3.12-slim
2+
3+
COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/
4+
5+
LABEL maintainer="Alin Elena <[email protected]>"
6+
ARG UID="1001"
7+
ARG GID="100"
8+
9+
ENV user=drFaustroll
10+
ENV group=drFaustroll
11+
RUN useradd -m ${user}
12+
WORKDIR /app
13+
14+
USER root
15+
16+
ENV DEBIAN_FRONTEND=noninteractive
17+
RUN apt update --yes && \
18+
apt upgrade --yes && \
19+
apt install --yes --no-install-recommends \
20+
ca-certificates \
21+
locales \
22+
sudo \
23+
tini \
24+
wget bzip2 curl git gcc g++ make cmake && \
25+
apt clean && rm -rf /var/lib/apt/lists/* && \
26+
echo "en_US.UTF-8 UTF-8" > /etc/locale.gen && \
27+
locale-gen
28+
29+
30+
ARG marimo_version=0.16.2
31+
ENV MARIMO_SKIP_UPDATE_CHECK=1
32+
ENV UV_SYSTEM_PYTHON=1
33+
RUN uv pip install --no-cache-dir marimo==${marimo_version} && \
34+
mkdir -p /app/data && \
35+
chown -R ${user}:${group} /app
36+
37+
COPY --chown=${user}:${group} assets/tutorials tutorials
38+
39+
ENV PORT=8842
40+
EXPOSE $PORT
41+
42+
ENV HOST=0.0.0.0
43+
44+
RUN uv pip install --no-cache-dir marimo[recommended,lsp,sql] altair pandas python-lsp-server websockets \
45+
duckdb \
46+
sqlglot \
47+
vegafusion vl-convert-python \
48+
ruff \
49+
openai \
50+
nbformat \
51+
pytest
52+
RUN uv pip install --no-cache-dir 'janus-core[all]@git+https://github.com/stfc/janus-core.git@main'
53+
RUN uv pip install --no-cache-dir cuequivariance==0.5.1 \
54+
cuequivariance-torch==0.5.1 \
55+
cuequivariance-ops-torch-cu12==0.5.1 \
56+
torchvision \
57+
pack-mm \
58+
seaborn \
59+
data-tutorials \
60+
pymatviz \
61+
opentsne \
62+
pymatgen \
63+
pymatviz \
64+
git+https://github.com/imagdau/aseMolec@main
65+
66+
CMD marimo edit --no-token -p $PORT --host $HOST

0 commit comments

Comments
 (0)