Skip to content

Commit 398aad4

Browse files
author
Kasper Peeters
committed
Add logic to automatically build and upload docker images which contain a Jupyter server with Cadabra kernel. Update documentation and web site.
1 parent 23aec21 commit 398aad4

File tree

8 files changed

+134
-4
lines changed

8 files changed

+134
-4
lines changed

.github/workflows/docker.yml

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
2+
# Build docker images with a Jupyter server with Cadabra
3+
# kernel whenever a commit is pushed to github.
4+
#
5+
# Lint this thing with
6+
#
7+
# yq eval docker.yml
8+
9+
name: Docker
10+
11+
on: [push]
12+
13+
jobs:
14+
build:
15+
runs-on: ubuntu-latest
16+
17+
# strategy:
18+
# fail-fast: false
19+
# matrix:
20+
# arch:
21+
# - amd64
22+
# - arm64
23+
24+
steps:
25+
- name: Prepare
26+
run: |
27+
platform=${{ matrix.platform }}
28+
echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV
29+
30+
- name: Set up QEMU
31+
uses: docker/setup-qemu-action@master
32+
33+
- uses: actions/checkout@v3
34+
35+
# - name: Exit if not on master branch
36+
# if: github.ref != 'refs/heads/master'
37+
# run: exit 1
38+
39+
- name: Log in to Docker Hub
40+
uses: docker/login-action@master
41+
with:
42+
username: ${{ secrets.DOCKER_USERNAME }}
43+
password: ${{ secrets.DOCKER_PASSWORD }}
44+
45+
- name: Extract metadata (tags, labels) for Docker
46+
id: meta
47+
uses: docker/metadata-action@master
48+
with:
49+
images: kpeeters/cadabra2-jupyter
50+
51+
- name: Set up Docker Buildx
52+
uses: docker/setup-buildx-action@master
53+
54+
- name: Build Docker image
55+
uses: docker/build-push-action@master
56+
with:
57+
platforms: linux/amd64, linux/arm64
58+
context: .
59+
file: docker/Dockerfile
60+
push: true
61+
#${{ github.ref == 'master' }}
62+
labels: ${{ steps.meta.outputs.labels }}
63+
tags: kpeeters/cadabra2-jupyter:latest
64+
# outputs: type=docker
65+
66+
# - name: Upload artifact to github assets
67+
# uses: actions/upload-artifact@main
68+
# with:
69+
# name: cadabra2-jupyter-${{ matrix.arch }}
70+
# path: cadabra2-jupyter-${{ matrix.arch }}.tar

.github/workflows/linux.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ jobs:
1010
steps:
1111
- uses: actions/checkout@v3
1212

13+
- name: Exit if not on devel branch
14+
if: github.ref != 'refs/heads/devel'
15+
run: exit 1
16+
1317
- name: setup python
1418
uses: actions/setup-python@v4
1519
with:

.github/workflows/macos.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ jobs:
1010
steps:
1111
- uses: actions/checkout@v4
1212

13+
- name: Exit if not on devel branch
14+
if: github.ref != 'refs/heads/devel'
15+
run: exit 1
16+
1317
- name: setup python
1418
uses: actions/setup-python@v5
1519
with:

docker/Dockerfile

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,15 @@ RUN apt update && apt install -y \
4141
&& rm -rf /var/lib/apt/lists/*
4242
RUN pip install jupyter
4343
COPY --from=builder /usr/local/bin/cadabra* /usr/local/bin/
44-
COPY --from=builder /usr/local/lib/python3.11/dist-packages /usr/local/lib/python3.11/dist-packages
44+
COPY --from=builder /usr/local/lib/python3.11/site-packages /usr/local/lib/python3.11/site-packages
4545
COPY --from=builder /usr/local/share/cadabra2 /usr/local/share/cadabra2
4646
COPY --from=builder /usr/local/share/jupyter/kernels/cadabra2 /usr/local/share/jupyter/kernels/cadabra2
4747

4848
# Cleanup things not necessary for running the container.
4949
RUN apt-get remove -y gcc && apt-get autoremove -y
5050

51-
ENV PYTHONPATH=${PYTHONPATH}:/usr/local/lib/python3.11/dist-packages
5251
EXPOSE 9057
5352
WORKDIR /home/cadabra
54-
ENTRYPOINT ["jupyter", "notebook", "--ip=0.0.0.0", "--port=9057", "--allow-root"]
53+
COPY docker/entrypoint.sh /entrypoint.sh
54+
RUN chmod +x /entrypoint.sh
55+
ENTRYPOINT ["/entrypoint.sh", "--port=9057"]

docker/entrypoint.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bin/sh
2+
3+
# amend python path
4+
export PYTHONPATH=${PYTHONPATH}:/usr/local/lib/python3.11/dist-packages
5+
jupyter notebook --ip=0.0.0.0 --allow-root $@

web2/cadabra2/source/download.html

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,20 @@ <h2>Binary packages</h2>
118118
</div>
119119
</div>
120120

121+
<div class="distrotype">
122+
<img src="static/images/docker-logo-blue.svg"/>
123+
<div class="distrotxt">
124+
If you only want to use Cadabra from within Jupyter, you can use
125+
the <a href="https://hub.docker.com/r/kpeeters/cadabra2-jupyter">official
126+
Docker image at DockerHub</a>. This container exposes the
127+
Jupyter server on a local URL which you can access using your
128+
browser, and stores notebooks in your home directory. Available
129+
for both AMD64 and ARM64 architectures. Be aware that you will
130+
miss out on some of the goodies of the Cadabra notebook
131+
interface.
132+
</div>
133+
</div>
134+
121135
<div class="distrotype">
122136
<img src="static/images/apple_logo.png"/>
123137
<div class="distronum">macOS</a></div>

web2/cadabra2/source/jupyter.html

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,18 @@ <h2>Installation</h2>
4242
to <a href="faq.html#q_01_01">adjust your <tt>PYTHONPATH</tt></a>.
4343
</p>
4444

45-
<!--<h2>Old Xeus-based kernel</h2>
45+
<h2>Docker version</h2>
46+
<p class="hyphenate">
47+
Alternatively, you can use
48+
the <a href="https://hub.docker.com/r/kpeeters/cadabra2-jupyter">official
49+
Docker image for Cadabra</a>, available from DockerHub, which
50+
contains a Jupyter server with the Cadabra kernel. This will not be
51+
able to see existing Python package installations on your system,
52+
but has the advantage of being easy to install (and easy to remove,
53+
if you ever want to do that).
54+
</p>
55+
56+
<!--<h2>Old Xeus-based kernel</h2>
4657
<p>
4758
To obtain the Cadabra kernel for Jupyter, you need to either install
4859
it from Anaconda,
Lines changed: 21 additions & 0 deletions
Loading

0 commit comments

Comments
 (0)