From 38ef04318308fc3ba204cbd90b69b0face151296 Mon Sep 17 00:00:00 2001
From: ben0i0d <ben0i0d@foxmail.com>
Date: Sat, 11 May 2024 16:40:27 +0800
Subject: [PATCH] switch to bookworm && remove mojo && repair sage

---
 README.md             |  2 +-
 README_CN.md          |  2 +-
 build.sh              | 27 +++++++++++++++++++++++++++
 mojo/Dockerfile       | 15 ---------------
 push.sh               | 17 +++++++++++++++++
 python/cpu/Dockerfile |  4 +---
 python/gpu/Dockerfile |  4 +---
 sagemath/Dockerfile   | 10 +++++-----
 scipy/cpu/Dockerfile  |  2 +-
 scipy/gpu/Dockerfile  |  1 -
 10 files changed, 54 insertions(+), 30 deletions(-)
 create mode 100644 build.sh
 delete mode 100644 mojo/Dockerfile
 create mode 100644 push.sh

diff --git a/README.md b/README.md
index 4358f2b..f99a434 100644
--- a/README.md
+++ b/README.md
@@ -27,7 +27,7 @@ Specify the image in the profile of the singleuser
 ### List of images that are currently being built
 * Upstream: Mirror upstream, benchmarking against the jupyter official minimal-notebook image
     * Description
-        1. Upstream has switched to `debian:trixie-slim`, and GPU upstream images are also built based on `debian:trixie`
+        1. Upstream has switched to `debian:bookworm-slim`, and GPU upstream images are also built based on `debian:bookworm`
         2. By default, we add the domain certificate of eoelab.org, which does not pose any security issues
         3. Sudo is added for passwordless use. In scenarios with high security requirements, do not allow privilege escalation
         4. Provided packages: file compression/extraction (.zip), project management (git), Chinese fonts (fonts-wqy-zenhei)
diff --git a/README_CN.md b/README_CN.md
index 2cbbc4d..03e490b 100644
--- a/README_CN.md
+++ b/README_CN.md
@@ -35,7 +35,7 @@ plt.rcParams["font.family"] = zh_font.get_name()
 ### 当前构建镜像清单
 * Upstream: 镜像上游,对标jupyter官方的minimal-notebook镜像
     * 说明
-        1. 上游已经切换到`debian:trixie`,GPU上游镜像也基于`debian:trixie`二次构建了镜像
+        1. 上游已经切换到`debian:bookworm-slim`,GPU上游镜像也基于`debian:bookworm`二次构建了镜像
         2. 默认情况下我们添加了eoelab.org的域名证书,这不会带来安全问题
         3. 添加了sudo的无密码使用,在安全要求较高的场景中,不要允许特权提升
         4. 提供软件包:文件压缩/解压(.zip),项目管理(git),中文字体(fonts-wqy-zenhei)
diff --git a/build.sh b/build.sh
new file mode 100644
index 0000000..a2b1e8c
--- /dev/null
+++ b/build.sh
@@ -0,0 +1,27 @@
+# auto build image
+
+remote="docker.io/ben0i0d/jupyter"
+
+arch="amd64"
+
+# Python
+source=(python/cpu python/gpu scipy/cpu scipy/gpu scrpy pyflink pyspark pyai/cpu pyai/gpu)
+target=(py-c py-g scipy-c scipy-g scrpy pyflink pyspark pyai-c pyai-g)
+
+for arch in $arch; do
+    for i in {0..9}; do
+        podman build --arch=$arch -t $remote:${target[i]} ${source[i]}
+    done
+done
+
+# Other
+source=(julia maple mathematica matlab/minimal matlab/mcm sagemath octave r sagemath scilab)
+target=(julia maple mma matlab-minimal matlab-mcm sage octave r sage scilab)
+
+for arch in $arch; do
+    for i in {0..9}; do
+        podman build --arch=$arch -t $remote:${target[i]} ${source[i]}
+    done
+done
+
+
diff --git a/mojo/Dockerfile b/mojo/Dockerfile
deleted file mode 100644
index af10b90..0000000
--- a/mojo/Dockerfile
+++ /dev/null
@@ -1,15 +0,0 @@
-FROM ben0i0d/jupyter:py-c
-
-USER root
-
-ENV MODULAR_HOME="/opt/modular" \
-    PATH="$PATH:/opt/modular/pkg/packages.modular.com_mojo/bin"
-
-RUN apt-get update && apt-get install --yes --no-install-recommends curl libedit2 && apt-get clean && rm -rf /var/lib/apt/lists/* && \
-    mkdir /opt/modular && \
-    curl https://get.modular.com | MODULAR_AUTH=mut_631a7d7cd03d4185b786385c42384278 sh - && \
-    modular auth mut_631a7d7cd03d4185b786385c42384278 && modular install mojo 
-    
-USER ${NB_UID}
-
-RUN python /opt/modular/pkg/packages.modular.com_mojo/jupyter/manage_kernel.py install
\ No newline at end of file
diff --git a/push.sh b/push.sh
new file mode 100644
index 0000000..17ceedd
--- /dev/null
+++ b/push.sh
@@ -0,0 +1,17 @@
+# auto push image
+
+remote="docker.io/ben0i0d/jupyter"
+
+# Python
+target=(py-c py-g scipy-c scipy-g scrpy pyflink pyspark pyai-c pyai-g)
+
+for i in {0..9}; do
+    podman push $remote:${target[i]}
+done
+
+# Other
+target=(julia maple mma matlab-minimal matlab-mcm sage octave r sage scilab)
+
+for i in {0..9}; do
+    podman push $remote:${target[i]}
+done
\ No newline at end of file
diff --git a/python/cpu/Dockerfile b/python/cpu/Dockerfile
index 368f88e..8aca066 100644
--- a/python/cpu/Dockerfile
+++ b/python/cpu/Dockerfile
@@ -1,9 +1,7 @@
-FROM debian:trixie-slim
+FROM debian:bookworm-slim
 
 EXPOSE 8888
 
-SHELL ["/bin/bash", "-o", "pipefail", "-c"]
-
 USER root
 
 # Configure environment
diff --git a/python/gpu/Dockerfile b/python/gpu/Dockerfile
index 12fc645..fa6c263 100644
--- a/python/gpu/Dockerfile
+++ b/python/gpu/Dockerfile
@@ -1,9 +1,7 @@
-FROM ben0i0d/cuda:12.2.0-devel-debian13
+FROM ben0i0d/cuda:12.2.0-devel-debian12
 
 EXPOSE 8888
 
-SHELL ["/bin/bash", "-o", "pipefail", "-c"]
-
 USER root
 
 # Configure environment
diff --git a/sagemath/Dockerfile b/sagemath/Dockerfile
index c40404c..59329d0 100644
--- a/sagemath/Dockerfile
+++ b/sagemath/Dockerfile
@@ -1,13 +1,13 @@
 FROM ben0i0d/jupyter:py-c
 
+ENV BASE_DIR=/opt/base
+
 USER root
 
-# Sage pre-requisites and jq for manipulating json
+# Sage install
 RUN apt-get update && \
-    apt-get install -y --no-install-recommends sagemath sagemath-jupyter sagemath-doc && \
-    fix-permissions "${CONDA_DIR}" && \
-    fix-permissions "/home/${NB_USER}" && \
-    rm -rf /var/lib/apt/lists/*
+    apt-get install -y --no-install-recommends sagemath && apt-get clean && rm -rf /var/lib/apt/lists/* && \
+    sage -c 'from sage.repl.ipython_kernel.install import SageKernelSpec; SageKernelSpec.update(prefix=os.environ["BASE_DIR"])'
 
 USER $NB_UID
 
diff --git a/scipy/cpu/Dockerfile b/scipy/cpu/Dockerfile
index 0034ea3..7f292ed 100644
--- a/scipy/cpu/Dockerfile
+++ b/scipy/cpu/Dockerfile
@@ -5,7 +5,7 @@ RUN pip install  \
     # Data analysis and visualization
     'pandas' 'matplotlib' \
     # Machine learning and data mining
-    'scikit-learn' 'jax' \
+    'scikit-learn' \
     # Scientific calculations and statistical analysis
     'scipy' 'numpy' &&\
     pip cache purge  && \
diff --git a/scipy/gpu/Dockerfile b/scipy/gpu/Dockerfile
index d136588..86b2659 100644
--- a/scipy/gpu/Dockerfile
+++ b/scipy/gpu/Dockerfile
@@ -8,6 +8,5 @@ RUN pip install \
     'scikit-learn' \
     # Scientific calculations and statistical analysis
     'scipy' 'numpy' &&\
-    pip install --upgrade "jax[cuda12_pip]" -f https://storage.googleapis.com/jax-releases/jax_cuda_releases.html && \
     pip cache purge && \
     MPLBACKEND=Agg python -c "import matplotlib.pyplot"