This commit is contained in:
@@ -9,14 +9,6 @@ jobs:
|
||||
"Build Jupyter Sage docker images":
|
||||
runs-on: woryzen
|
||||
steps:
|
||||
-
|
||||
name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v3
|
||||
-
|
||||
name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
with:
|
||||
driver: docker-container
|
||||
-
|
||||
name: Login to Gitea container registry
|
||||
uses: docker/login-action@v3
|
||||
@@ -28,10 +20,12 @@ jobs:
|
||||
name: Build and push jupyter-sage image
|
||||
uses: docker/build-push-action@v5.3.0
|
||||
with:
|
||||
builder: multiplatform-builder
|
||||
context: "{{defaultContext}}:jupyter-sage"
|
||||
platforms: linux/amd64,linux/arm64
|
||||
platforms: linux/amd64
|
||||
push: true
|
||||
pull: true
|
||||
tags: gitea.woggioni.net/woggioni/jupyter-sage:latest
|
||||
cache-from: type=registry,ref=gitea.woggioni.net/woggioni/jupyter-sage:buildx
|
||||
cache-to: type=registry,mode=max,compression=zstd,image-manifest=true,oci-mediatypes=true,ref=gitea.woggioni.net/woggioni/jupyter-sage:buildx
|
||||
build-args: "VERSION=10.8"
|
||||
ssh: default=/home/luser/.ssh/id_ed25519
|
||||
tags: |
|
||||
gitea.woggioni.net/woggioni/jupyter-sage:latest
|
||||
gitea.woggioni.net/woggioni/jupyter-sage:10.8
|
||||
|
||||
@@ -1,36 +1,44 @@
|
||||
FROM debian:latest
|
||||
RUN apt-get update && apt-get upgrade
|
||||
RUN apt-get install -y bc binutils bzip2 ca-certificates cliquer cmake curl \
|
||||
ecl eclib-tools fflas-ffpack g++ gap gcc gengetopt gfan gfortran \
|
||||
glpk-utils gmp-ecm lcalc libatomic-ops-dev libboost-dev \
|
||||
libbraiding-dev libbrial-dev libbrial-groebner-dev libbz2-dev \
|
||||
libcdd-dev libcdd-tools libcliquer-dev libcurl4-openssl-dev libec-dev \
|
||||
libecm-dev libffi-dev libflint-dev libfplll-dev libfreetype-dev \
|
||||
libgap-dev libgc-dev libgd-dev libgf2x-dev libgiac-dev libgivaro-dev \
|
||||
libglpk-dev libgmp-dev libgsl-dev libhomfly-dev libiml-dev \
|
||||
liblfunction-dev liblinbox-dev liblrcalc-dev liblzma-dev libm4ri-dev \
|
||||
libm4rie-dev libmpc-dev libmpfi-dev libmpfr-dev libncurses5-dev \
|
||||
libntl-dev libopenblas-dev libpari-dev libplanarity-dev libppl-dev \
|
||||
libprimesieve-dev libpython3-dev libqhull-dev libreadline-dev \
|
||||
librw-dev libsingular4-dev libsqlite3-dev libssl-dev \
|
||||
libsuitesparse-dev libsymmetrica2-dev libz-dev libzmq3-dev m4 make \
|
||||
maxima maxima-sage meson nauty ninja-build openssl palp pari-doc \
|
||||
pari-elldata pari-galdata pari-galpol pari-gp2c pari-seadata patch \
|
||||
patchelf perl pkg-config planarity ppl-dev python3 python3-setuptools \
|
||||
python3-venv singular singular-doc sqlite3 sympow tachyon tar texinfo \
|
||||
tox xcas xz-utils git
|
||||
RUN apt-get install -y default-jdk dvipng ffmpeg fonts-freefont-otf \
|
||||
imagemagick latexmk libavdevice-dev libjpeg-dev pandoc tex-gyre \
|
||||
texlive-fonts-recommended texlive-lang-cyrillic texlive-lang-english \
|
||||
texlive-lang-european texlive-lang-french texlive-lang-german \
|
||||
texlive-lang-italian texlive-lang-japanese texlive-lang-polish \
|
||||
texlive-lang-portuguese texlive-lang-spanish texlive-latex-extra \
|
||||
texlive-luatex texlive-xetex xindy
|
||||
RUN useradd jovyan -u 1000 -s /bin/bash -m -h /home/jovyan
|
||||
FROM debian:stable AS build
|
||||
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
|
||||
--mount=type=cache,target=/var/lib/apt,sharing=locked \
|
||||
apt update &&\
|
||||
apt install -y python3 python3-dev pipx gcc g++ libffi-dev cargo cmake autoconf swig ninja-build patchelf meson python3-faiss adduser
|
||||
RUN adduser -u 1000 --system --shell /bin/sh --home /home/jovyan jovyan
|
||||
USER jovyan
|
||||
WORKDIR /home/jovyan
|
||||
COPY build.sh build.sh
|
||||
RUN git clone -c core.symlinks=true --filter blob:none \
|
||||
--origin upstream --branch master --tags \
|
||||
https://github.com/sagemath/sage.git
|
||||
RUN export srcdir=/home/jovyan/sage source build.sh && prepare && build
|
||||
RUN python3 -m venv venv
|
||||
RUN --mount=type=cache,target=/home/jovyan/.cache/pip,uid=1000,gid=1000 venv/bin/pip install sagemath
|
||||
RUN --mount=type=cache,target=/home/jovyan/.cache/pip,uid=1000,gid=1000 venv/bin/pip install jupyter-core
|
||||
RUN --mount=type=cache,target=/home/jovyan/.cache/pip,uid=1000,gid=1000 venv/bin/pip install jupyterhub
|
||||
RUN --mount=type=cache,target=/home/jovyan/.cache/pip,uid=1000,gid=1000 venv/bin/pip install jupyterlab
|
||||
RUN --mount=type=cache,target=/home/jovyan/.cache/pip,uid=1000,gid=1000 venv/bin/pip install notebook
|
||||
RUN --mount=type=cache,target=/home/jovyan/.cache/pip,uid=1000,gid=1000 venv/bin/pip install ipywidgets
|
||||
RUN --mount=type=cache,target=/home/jovyan/.cache/pip,uid=1000,gid=1000 venv/bin/pip install jupyterlab-lsp
|
||||
RUN --mount=type=cache,target=/home/jovyan/.cache/pip,uid=1000,gid=1000 venv/bin/pip install python-lsp-server[yapf,rope,pyflakes]
|
||||
RUN --mount=type=cache,target=/home/jovyan/.cache/pip,uid=1000,gid=1000 venv/bin/pip install jupyter-ai
|
||||
RUN --mount=type=cache,target=/home/jovyan/.cache/pip,uid=1000,gid=1000 venv/bin/pip install langchain-openai langchain_ollama
|
||||
|
||||
ENV PATH="/home/jovyan/venv/bin/:$PATH"
|
||||
|
||||
FROM debian:stable
|
||||
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
|
||||
--mount=type=cache,target=/var/lib/apt,sharing=locked \
|
||||
apt update &&\
|
||||
apt install -y python3 adduser
|
||||
RUN adduser -u 1000 --system --shell /bin/sh --home /home/jovyan jovyan
|
||||
USER jovyan
|
||||
COPY --from=build /home/jovyan /home/jovyan
|
||||
COPY jupyter_server_config.py docker_healthcheck.py /etc/jupyter/
|
||||
COPY start-notebook.py start-singleuser.py /usr/local/bin/
|
||||
RUN mkdir /home/jovyan/work
|
||||
WORKDIR /home/jovyan/work
|
||||
ENV JUPYTER_PORT=8888
|
||||
EXPOSE $JUPYTER_PORT
|
||||
ENV PATH="/home/jovyan/venv/bin/:$PATH"
|
||||
CMD ["start-notebook.py"]
|
||||
|
||||
# HEALTHCHECK documentation: https://docs.docker.com/engine/reference/builder/#healthcheck
|
||||
# This healtcheck works well for `lab`, `notebook`, `nbclassic`, `server`, and `retro` jupyter commands
|
||||
# https://github.com/jupyter/docker-stacks/issues/915#issuecomment-1068528799
|
||||
HEALTHCHECK --interval=3s --timeout=1s --start-period=3s --retries=3 \
|
||||
CMD /etc/jupyter/docker_healthcheck.py || exit 1
|
||||
|
||||
@@ -1,15 +1,18 @@
|
||||
#!/usr/bin/env sh
|
||||
set -e
|
||||
|
||||
pkgs=(standard
|
||||
bliss
|
||||
coxeter3
|
||||
mcqd
|
||||
meataxe
|
||||
sirocco
|
||||
tdlib)
|
||||
# pkgs=(
|
||||
# standard
|
||||
# bliss
|
||||
# coxeter3
|
||||
# mcqd
|
||||
# meataxe
|
||||
# sirocco
|
||||
# tdlib
|
||||
# )
|
||||
|
||||
prepare(){
|
||||
cd sage
|
||||
prepare() {
|
||||
cd "${srcdir}"
|
||||
# use correct latte-count binary name
|
||||
# patch -p1 -i ../latte-count.patch
|
||||
# update to tdlib 0.9 (Fedora)
|
||||
@@ -23,29 +26,17 @@ prepare(){
|
||||
}
|
||||
|
||||
build() {
|
||||
export SAGE_NUM_THREADS=$(($(nproc)/2))
|
||||
export PYTHONPATH="$PWD"/sage/pkgs/sage-setup
|
||||
|
||||
for _pkg in ${_pkgs[@]}; do
|
||||
cd "$srcdir"/sage/pkgs/sagemath-$_pkg
|
||||
python setup.py build
|
||||
done
|
||||
#export SAGE_NUM_THREADS=$(($(nproc)/2))
|
||||
#export PYTHONPATH="$PWD"/sage/pkgs/sage-setup
|
||||
python3 -m build --wheel --no-isolation -C setup-args=-Dbuild-docs=false
|
||||
}
|
||||
|
||||
package() {
|
||||
for _pkg in ${_pkgs[@]}; do
|
||||
cd "$srcdir"/sage/pkgs/sagemath-$_pkg
|
||||
python setup.py install --root="$pkgdir" --optimize=1
|
||||
done
|
||||
|
||||
# fix symlinks to assets
|
||||
# _pythonpath=`python -c "from sysconfig import get_path; print(get_path('platlib'))"`
|
||||
# for _i in $(ls "$srcdir"/sage/src/sage/ext_data/notebook-ipython); do
|
||||
# rm "$pkgdir"/usr/share/jupyter/kernels/sagemath/$_i
|
||||
# ln -s $_pythonpath/sage/ext_data/notebook-ipython/$_i "$pkgdir"/usr/share/jupyter/kernels/sagemath/
|
||||
# done
|
||||
|
||||
# adjust threejs version
|
||||
# rm "$pkgdir"$_pythonpath/sage/ext_data/threejs/threejs-version.txt
|
||||
# ln -s /usr/share/threejs-sage/version "$pkgdir"$_pythonpath/sage/ext_data/threejs/threejs-version.txt
|
||||
python -m installer dist/*.whl
|
||||
}
|
||||
|
||||
# prepare
|
||||
|
||||
build
|
||||
|
||||
package
|
||||
|
||||
44
jupyter-sage/start-notebook.py
Executable file
44
jupyter-sage/start-notebook.py
Executable file
@@ -0,0 +1,44 @@
|
||||
#!/usr/bin/env python
|
||||
# Copyright (c) Jupyter Development Team.
|
||||
# Distributed under the terms of the Modified BSD License.
|
||||
import os
|
||||
import shlex
|
||||
import sys
|
||||
|
||||
# If we are in a JupyterHub, we pass on to `start-singleuser.py` instead so it does the right thing
|
||||
if "JUPYTERHUB_API_TOKEN" in os.environ:
|
||||
print(
|
||||
"WARNING: using start-singleuser.py instead of start-notebook.py to start a server associated with JupyterHub."
|
||||
)
|
||||
command = ["/usr/local/bin/start-singleuser.py"] + sys.argv[1:]
|
||||
os.execvp(command[0], command)
|
||||
|
||||
|
||||
# Entrypoint is start.sh
|
||||
command = []
|
||||
|
||||
# If we want to survive restarts, launch the command using `run-one-constantly`
|
||||
if os.environ.get("RESTARTABLE") == "yes":
|
||||
command.append("run-one-constantly")
|
||||
|
||||
# We always launch a jupyter subcommand from this script
|
||||
command.append("jupyter")
|
||||
|
||||
# Launch the configured subcommand.
|
||||
# Note that this should be a single string, so we don't split it.
|
||||
# We default to `lab`.
|
||||
jupyter_command = os.environ.get("DOCKER_STACKS_JUPYTER_CMD", "lab")
|
||||
command.append(jupyter_command)
|
||||
|
||||
# Append any optional NOTEBOOK_ARGS we were passed in.
|
||||
# This is supposed to be multiple args passed on to the notebook command,
|
||||
# so we split it correctly with shlex
|
||||
if "NOTEBOOK_ARGS" in os.environ:
|
||||
command += shlex.split(os.environ["NOTEBOOK_ARGS"])
|
||||
|
||||
# Pass through any other args we were passed on the command line
|
||||
command += sys.argv[1:]
|
||||
|
||||
# Execute the command!
|
||||
print("Executing: " + " ".join(command))
|
||||
os.execvp(command[0], command)
|
||||
Reference in New Issue
Block a user