Skip to content

Commit bd6a682

Browse files
committed
feat: add kernel images
1 parent d735819 commit bd6a682

File tree

6 files changed

+219
-0
lines changed

6 files changed

+219
-0
lines changed

.github/workflows/publish-images.yml

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
name: Publish Kernel Images
2+
3+
on:
4+
push:
5+
tags:
6+
- v**
7+
workflow_dispatch: # Allows to trigger the workflow manually in GitHub UI
8+
9+
env:
10+
REGISTRY: ghcr.io
11+
12+
jobs:
13+
build-and-push-image:
14+
runs-on: ubuntu-latest
15+
permissions:
16+
contents: read
17+
packages: write
18+
attestations: write
19+
id-token: write
20+
steps:
21+
- name: Checkout repository
22+
uses: actions/checkout@v4
23+
- name: Log in to the Container registry
24+
uses: docker/login-action@v3.3.0
25+
with:
26+
registry: ${{ env.REGISTRY }}
27+
username: ${{ github.actor }}
28+
password: ${{ secrets.GITHUB_TOKEN }}
29+
- name: Extract base image metadata
30+
id: meta-base
31+
uses: docker/metadata-action@v5.6.1
32+
with:
33+
images: ${{ env.REGISTRY }}/ipython-kernel
34+
# semver has default priority 900, sha has default priority 100
35+
# ref has default priority 600
36+
# see <https://github.com/docker/metadata-action#priority-attribute>
37+
# also, sha has a default prefix of '-sha'
38+
# see <https://github.com/docker/metadata-action#typesha>
39+
tags: |
40+
type=semver,pattern={{version}}
41+
type=sha,priority=850,prefix=
42+
- name: Build and push base image
43+
id: push-base
44+
uses: docker/build-push-action@v6.10.0
45+
with:
46+
file: images/base/Dockerfile
47+
context: images/base
48+
push: true
49+
tags: ${{ steps.meta-base.outputs.tags }}
50+
labels: ${{ steps.meta-base.outputs.labels }}
51+
- name: Generate base artifact attestation
52+
uses: actions/attest-build-provenance@v1
53+
with:
54+
subject-name: ${{ env.REGISTRY }}/ipython-kernel
55+
subject-digest: ${{ steps.push-base.outputs.digest }}
56+
push-to-registry: true
57+
- name: Extract scipy image metadata
58+
id: meta-scipy
59+
uses: docker/metadata-action@v5.6.1
60+
with:
61+
images: ${{ env.REGISTRY }}/scipy-kernel
62+
# semver has default priority 900, sha has default priority 100
63+
# ref has default priority 600
64+
# see <https://github.com/docker/metadata-action#priority-attribute>
65+
# also, sha has a default prefix of '-sha'
66+
# see <https://github.com/docker/metadata-action#typesha>
67+
tags: |
68+
type=semver,pattern={{version}}
69+
type=sha,priority=850,prefix=
70+
- name: Build and push scipy image
71+
id: push-scipy
72+
uses: docker/build-push-action@v6.10.0
73+
with:
74+
file: images/scipy/Dockerfile
75+
context: images/scipy
76+
push: true
77+
tags: ${{ steps.meta-scipy.outputs.tags }}
78+
labels: ${{ steps.meta-scipy.outputs.labels }}
79+
- name: Generate scipy artifact attestation
80+
uses: actions/attest-build-provenance@v1
81+
with:
82+
subject-name: ${{ env.REGISTRY }}/scipy-kernel
83+
subject-digest: ${{ steps.push-scipy.outputs.digest }}
84+
push-to-registry: true
85+
- name: Extract scipy-zh-cn image metadata
86+
id: meta-scipy-zh-cn
87+
uses: docker/metadata-action@v5.6.1
88+
with:
89+
images: ${{ env.REGISTRY }}/scipy-kernel
90+
# semver has default priority 900, sha has default priority 100
91+
# ref has default priority 600
92+
# see <https://github.com/docker/metadata-action#priority-attribute>
93+
# also, sha has a default prefix of '-sha'
94+
# see <https://github.com/docker/metadata-action#typesha>
95+
tags: |
96+
type=semver,pattern={{version}}
97+
type=sha,priority=850,prefix=,suffix=-zh-cn
98+
- name: Build and push scipy-zh-cn image
99+
id: push-scipy-zh-cn
100+
uses: docker/build-push-action@v6.10.0
101+
with:
102+
file: images/scipy-zh-cn/Dockerfile
103+
context: images/scipy-zh-cn
104+
push: true
105+
tags: ${{ steps.meta-scipy-zh-cn.outputs.tags }}
106+
labels: ${{ steps.meta-scipy-zh-cn.outputs.labels }}
107+
- name: Generate scipy-zh-cn artifact attestation
108+
uses: actions/attest-build-provenance@v1
109+
with:
110+
subject-name: ${{ env.REGISTRY }}/scipy-kernel
111+
subject-digest: ${{ steps.push-scipy-zh-cn.outputs.digest }}
112+
push-to-registry: true

images/base/Dockerfile

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
FROM python:3.13-slim
2+
3+
ARG NB_USER="jovyan"
4+
ARG NB_UID="1000"
5+
ARG NB_GID="100"
6+
ENV HOME /home/$NB_USER
7+
8+
RUN pip install --no-cache-dir \
9+
ipykernel \
10+
ipython
11+
12+
RUN useradd --create-home --no-log-init --no-user-group --uid ${NB_UID} ${NB_USER}
13+
14+
USER $NB_UID

images/scipy-zh-cn/Dockerfile

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
FROM python:3.13-slim
2+
3+
ARG NB_USER="jovyan"
4+
ARG NB_UID="1000"
5+
ARG NB_GID="100"
6+
ENV HOME=/home/$NB_USER
7+
8+
RUN pip install --no-cache-dir \
9+
ipykernel \
10+
ipython
11+
12+
# Packages are carefully selected from <https://github.com/jupyter/docker-stacks/blob/main/images/scipy-notebook/Dockerfile>
13+
# and its base images
14+
15+
RUN apt-get update \
16+
&& apt-get install -y --no-install-recommends \
17+
libopenblas-dev \
18+
# - Add Chinese fonts for matplotlib/seaborn
19+
fonts-noto-cjk \
20+
&& apt-get clean && rm -rf /var/lib/apt/lists /var/cache/apt/archives
21+
22+
COPY requirements.txt .
23+
RUN pip install --no-cache-dir \
24+
-r requirements.txt
25+
26+
RUN mplfonts init
27+
28+
ADD https://raw.githubusercontent.com/jupyter-server/enterprise_gateway/refs/heads/main/etc/kernel-launchers/bootstrap/bootstrap-kernel.sh /usr/local/bin/bootstrap-kernel.sh
29+
RUN chmod a+x /usr/local/bin/bootstrap-kernel.sh
30+
ADD https://raw.githubusercontent.com/jupyter-server/enterprise_gateway/refs/heads/main/etc/kernel-launchers/python/scripts/launch_ipykernel.py /usr/local/bin/kernel-launchers/python/scripts/launch_ipykernel.py
31+
32+
RUN useradd --create-home --no-log-init --no-user-group --uid ${NB_UID} ${NB_USER}
33+
34+
USER $NB_UID

images/scipy-zh-cn/requirements.txt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
matplotlib >=3.8.4,<4.0.0
2+
mplfonts >=0.0.8,<1.0.0
3+
numexpr >=2.8.4
4+
pandas >=2.2,<3.0.0
5+
scikit-learn >=1.0.0,<2.0.0
6+
scipy >=1.13.0,<2.0.0
7+
seaborn >=0.13.1,<1.0.0
8+
statsmodels >=0.10.0,<1.0.0
9+
tabulate >=0.9.0,<1.0.0
10+
openpyxl >=3.1.2,<4.0.0 # read xlsx files
11+
xlrd >= 2.0.1 # read xls files
12+
odfpy # read ods files

images/scipy/Dockerfile

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
FROM python:3.13-slim
2+
3+
ARG NB_USER="jovyan"
4+
ARG NB_UID="1000"
5+
ARG NB_GID="100"
6+
ENV HOME=/home/$NB_USER
7+
8+
RUN pip install --no-cache-dir \
9+
ipykernel \
10+
ipython
11+
12+
# Packages are carefully selected from <https://github.com/jupyter/docker-stacks/blob/main/images/scipy-notebook/Dockerfile>
13+
# and its base images
14+
15+
RUN apt-get update \
16+
&& apt-get install -y --no-install-recommends \
17+
libopenblas-dev \
18+
# - Add necessary fonts for matplotlib/seaborn
19+
# See https://github.com/jupyter/docker-stacks/pull/380 for details
20+
fonts-liberation \
21+
&& apt-get clean && rm -rf /var/lib/apt/lists /var/cache/apt/archives
22+
23+
COPY requirements.txt .
24+
RUN pip install --no-cache-dir \
25+
-r requirements.txt
26+
27+
ADD https://raw.githubusercontent.com/jupyter-server/enterprise_gateway/refs/heads/main/etc/kernel-launchers/bootstrap/bootstrap-kernel.sh /usr/local/bin/bootstrap-kernel.sh
28+
RUN chmod a+x /usr/local/bin/bootstrap-kernel.sh
29+
ADD https://raw.githubusercontent.com/jupyter-server/enterprise_gateway/refs/heads/main/etc/kernel-launchers/python/scripts/launch_ipykernel.py /usr/local/bin/kernel-launchers/python/scripts/launch_ipykernel.py
30+
31+
RUN useradd --create-home --no-log-init --no-user-group --uid ${NB_UID} ${NB_USER}
32+
33+
USER $NB_UID
34+
35+
CMD /usr/local/bin/bootstrap-kernel.sh

images/scipy/requirements.txt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
matplotlib >=3.8.4,<4.0.0
2+
mplfonts >=0.0.8,<1.0.0
3+
numexpr >=2.8.4
4+
pandas >=2.2,<3.0.0
5+
scikit-learn >=1.0.0,<2.0.0
6+
scipy >=1.13.0,<2.0.0
7+
seaborn >=0.13.1,<1.0.0
8+
statsmodels >=0.10.0,<1.0.0
9+
tabulate >=0.9.0,<1.0.0
10+
openpyxl >=3.1.2,<4.0.0 # read xlsx files
11+
xlrd >= 2.0.1 # read xls files
12+
odfpy # read ods files

0 commit comments

Comments
 (0)