Skip to content
Snippets Groups Projects
Verified Commit fd570766 authored by Olivier Benz's avatar Olivier Benz
Browse files

Merge branch 'main' into freeze-version

parents 002a5bf4 1355be64
No related branches found
No related tags found
No related merge requests found
# JupyterLab Mojo docker stack
# JupyterLab MAX/Mojo docker stack
<!-- markdownlint-disable line-length -->
[![minimal-readme compliant](https://img.shields.io/badge/readme%20style-minimal-brightgreen.svg)](https://github.com/RichardLitt/standard-readme/blob/master/example-readmes/minimal-readme.md) [![Project Status: Active – The project has reached a stable, usable state and is being actively developed.](https://www.repostatus.org/badges/latest/active.svg)](https://www.repostatus.org/#active) <a href="https://liberapay.com/benz0li/donate"><img src="https://liberapay.com/assets/widgets/donate.svg" alt="Donate using Liberapay" height="20"></a>
......@@ -6,6 +6,8 @@
Multi-arch (`linux/amd64`, `linux/arm64/v8`) docker images:
* [`glcr.b-data.ch/jupyterlab/max/base`](https://gitlab.b-data.ch/jupyterlab/max/base/container_registry)
* [`glcr.b-data.ch/jupyterlab/max/scipy`](https://gitlab.b-data.ch/jupyterlab/max/scipy/container_registry)
* [`glcr.b-data.ch/jupyterlab/mojo/base`](https://gitlab.b-data.ch/jupyterlab/mojo/base/container_registry)
* [`glcr.b-data.ch/jupyterlab/mojo/scipy`](https://gitlab.b-data.ch/jupyterlab/mojo/scipy/container_registry)
......@@ -29,6 +31,7 @@ base → scipy
* **Git**: A distributed version-control system for tracking changes in source
code.
* **Git LFS**: A Git extension for versioning large files.
* **MAX**: A high-performance generative AI framework.
* **Mojo**: A programming language for AI developers.
* **Neovim**: Vim-fork focused on extensibility and usability. (24.4.0+)
* **Pandoc**: A universal markup converter.
......@@ -45,6 +48,9 @@ base → scipy
:point_right: See the [Version Matrix](VERSION_MATRIX.md) for detailed
information.
:information_source: Regading [Magic](https://docs.modular.com/magic/), see
[[(JupyterLab) MAX/Mojo docker stack] Why is Magic not installed?](https://github.com/orgs/b-data/discussions/5)
The following extensions are pre-installed for **code-server**:
* [.gitignore Generator](https://github.com/piotrpalarz/vscode-gitignore-generator)
......@@ -129,10 +135,8 @@ latest:
```bash
cd base && docker build \
--build-arg MODULAR_VERSION=0.9.2 \
--build-arg MODULAR_AUTH_KEY=<your-modular-auth-key> \
--build-arg MOJO_VERSION=24.4.0 \
--build-arg PYTHON_VERSION=3.12.6 \
--build-arg MOJO_VERSION=24.5.0 \
--build-arg PYTHON_VERSION=3.12.8 \
-t jupyterlab/mojo/base \
-f latest.Dockerfile .
```
......@@ -141,7 +145,6 @@ version:
```bash
cd base && docker build \
--build-arg MODULAR_AUTH_KEY=<your-modular-auth-key> \
-t jupyterlab/mojo/base:MAJOR.MINOR.PATCH \
-f MAJOR.MINOR.PATCH.Dockerfile .
```
......@@ -189,6 +192,8 @@ docker run -it --rm \
`IMAGE` being one of
* [`glcr.b-data.ch/jupyterlab/max/base`](https://gitlab.b-data.ch/jupyterlab/max/base/container_registry)
* [`glcr.b-data.ch/jupyterlab/max/scipy`](https://gitlab.b-data.ch/jupyterlab/max/scipy/container_registry)
* [`glcr.b-data.ch/jupyterlab/mojo/base`](https://gitlab.b-data.ch/jupyterlab/mojo/base/container_registry)
* [`glcr.b-data.ch/jupyterlab/mojo/scipy`](https://gitlab.b-data.ch/jupyterlab/mojo/scipy/container_registry)
......@@ -289,7 +294,7 @@ This project follows the
## Support
Community support: Open a new disussion
Community support: Open a new discussion
[here](https://github.com/orgs/b-data/discussions). Commercial support: Contact
b-data by [email](mailto:support@b-data.ch).
......
## Supported Versions
Only the docker image with the latest version of Mojo is supported with security
updates.
Only the docker image with the latest version of MAX/Mojo is supported with
security updates.
## Reporting a Vulnerability
......@@ -10,10 +10,10 @@ To report a vulnerability in the latest docker image, email the maintainer
## Vulnerabilities in Prior Versions
Vulnerabilities in docker images with prior versions of Mojo are not fixed.
Vulnerabilities in docker images with prior versions of MAX/Mojo are not fixed.
Whenever a new version of Mojo is released, the previous version's docker image
is rebuilt once again and then frozen.
Whenever a new version of MAX/Mojo is released, the previous version's docker
image is rebuilt once again and then frozen.
Docker images *may* be rebuilt or extended if they fail to start or have runtime
issues.
# Version Matrix
Image tags = Mojo versions
Image tags = MAX/Mojo versions
Topmost entry = Tag `latest`
## All images
| Mojo | Python | Jupyter Hub | Jupyter Lab | code‑server (Code) | Neovim | Git | Git LFS | Pandoc | Linux distro |
|:-------|:-----------|:------------|:------------|:-------------------|:-------|:-------|:--------|:-------|:-------------|
| 24.4.0 | 3.12.6 | 5.1.0 | 4.2.5 | 4.92.2 (1.92.2) | 0.10.1 | 2.46.1 | 3.5.1 | 3.2 | Debian 12 |
| 24.3.0 | 3.12.4 | 5.0.0 | 4.2.1 | 4.89.1 (1.89.1) | n/a | 2.45.2 | 3.5.1 | 3.1.11 | Debian 12 |
| MAX/Mojo | Python | Jupyter Hub | Jupyter Lab | code‑server (Code) | Neovim | Git | Git LFS | Pandoc | Linux distro |
|:-----------|:-----------|:------------|:------------|:-------------------|:-------|:-------|:--------|:-------|:-------------|
| 24.5.0 | 3.12.8 | 5.2.1 | 4.2.6 | 4.95.3 (1.95.3) | 0.10.2 | 2.47.1 | 3.6.0 | 3.4 | Debian 12 |
| 24.4.0[^1] | 3.12.6 | 5.1.0 | 4.2.5 | 4.92.2 (1.92.2) | 0.10.1 | 2.46.1 | 3.5.1 | 3.2 | Debian 12 |
| 24.3.0[^1] | 3.12.4 | 5.0.0 | 4.2.1 | 4.89.1 (1.89.1) | n/a | 2.45.2 | 3.5.1 | 3.1.11 | Debian 12 |
[^1]: MAX images n/a
## scipy images
| Mojo | CTAN date | Quarto |
|:-------|:-----------|:--------|
| 24.4.0 | 2024-09-13 | 1.5.57 |
| 24.3.0 | 2024-06-07 | 1.4.555 |
| MAX/Mojo | CTAN date | Quarto |
|:---------|:-----------|:--------|
| 24.5.0 | | 1.6.39 |
| 24.4.0 | 2024-09-13 | 1.5.57 |
| 24.3.0 | 2024-06-07 | 1.4.555 |
.env:
variables:
MODULAR_VERSION: "0.9.2"
MOJO_VERSION: "24.4.0"
PYTHON_VERSION: "3.12.6"
TAG_VERSION_MAJ_MIN: "true"
MOJO_VERSION: "24.5.0"
MOJO_EXTENSION_VERSION: "24.5.6"
PYTHON_VERSION: "3.12.8"
TAG_VERSION_MAJ_MIN: "false"
TAG_VERSION_MAJ: "false"
.before-script-build: &before-script-build
......@@ -68,8 +68,8 @@ build:latest-linux-amd64:
--build-arg BASE_IMAGE
--build-arg BASE_IMAGE_TAG
--build-arg BUILD_ON_IMAGE
--build-arg MODULAR_VERSION
--build-arg MOJO_VERSION
--build-arg MOJO_EXTENSION_VERSION
--build-arg INSTALL_MAX
--build-arg PYTHON_VERSION
--build-arg CUDA_IMAGE_FLAVOR
......@@ -117,8 +117,8 @@ build:latest-linux-arm64v8:
--build-arg BASE_IMAGE
--build-arg BASE_IMAGE_TAG
--build-arg BUILD_ON_IMAGE
--build-arg MODULAR_VERSION
--build-arg MOJO_VERSION
--build-arg MOJO_EXTENSION_VERSION
--build-arg INSTALL_MAX
--build-arg PYTHON_VERSION
--build-arg CUDA_IMAGE_FLAVOR
......@@ -415,7 +415,7 @@ trigger-latest-build:
- apk upgrade --no-cache
- apk add --update --no-cache curl
script:
- curl -X POST -F token=$JUPYTERLAB_MOJO_SCIPY -F ref=main https://gitlab.b-data.ch/api/v4/projects/349/trigger/pipeline
- curl -X POST -F token=$JUPYTERLAB_MOJO_TRIGGER_TOKEN -F ref=main $JUPYTERLAB_MOJO_TRIGGER_URL
rules:
- if: $CUDA_IMAGE
when: never
......@@ -431,7 +431,7 @@ trigger-version-build:
- apk upgrade --no-cache
- apk add --update --no-cache curl
script:
- curl -X POST -F token=$JUPYTERLAB_MOJO_SCIPY -F ref=freeze-version https://gitlab.b-data.ch/api/v4/projects/349/trigger/pipeline
- curl -X POST -F token=$JUPYTERLAB_MOJO_TRIGGER_TOKEN -F ref=freeze-version $JUPYTERLAB_MOJO_TRIGGER_URL
rules:
- if: $CUDA_IMAGE
when: never
......
# Reset default PATH settings
PATH="/opt/modular/pkg/packages.modular.com_mojo/bin:/opt/code-server/bin:/usr/local/nvidia/bin:/usr/local/cuda/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
PATH="/opt/modular/bin:/opt/code-server/bin:/usr/local/nvidia/bin:/usr/local/cuda/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
export PATH
......@@ -3,7 +3,7 @@
"language_servers": {
"mojo": {
"argv": [
"/opt/modular/pkg/packages.modular.com_mojo/bin/mojo-lsp-server",
"/opt/modular/bin/mojo-lsp-server",
"--log=error"
],
"version": 2,
......
# Reset default PATH settings
PATH="/opt/modular/pkg/packages.modular.com_mojo/bin:/opt/code-server/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
PATH="/opt/modular/bin:/opt/code-server/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
export PATH
ARG BASE_IMAGE=debian
ARG BASE_IMAGE_TAG=12
ARG BUILD_ON_IMAGE=glcr.b-data.ch/python/ver
ARG MODULAR_VERSION
ARG MOJO_VERSION
ARG MOJO_EXTENSION_VERSION=${MOJO_VERSION}
ARG PYTHON_VERSION
ARG CUDA_IMAGE_FLAVOR
ARG NB_USER=jovyan
ARG NB_UID=1000
ARG JUPYTERHUB_VERSION=5.1.0
ARG JUPYTERLAB_VERSION=4.2.5
ARG JUPYTERHUB_VERSION=5.2.1
ARG JUPYTERLAB_VERSION=4.2.6
ARG CODE_BUILTIN_EXTENSIONS_DIR=/opt/code-server/lib/vscode/extensions
ARG CODE_SERVER_VERSION=4.92.2
ARG NEOVIM_VERSION=0.10.1
ARG GIT_VERSION=2.46.1
ARG GIT_LFS_VERSION=3.5.1
ARG PANDOC_VERSION=3.2
ARG CODE_SERVER_VERSION=4.95.3
ARG NEOVIM_VERSION=0.10.2
ARG GIT_VERSION=2.47.1
ARG GIT_LFS_VERSION=3.6.0
ARG PANDOC_VERSION=3.4
FROM ${BUILD_ON_IMAGE}${PYTHON_VERSION:+:}${PYTHON_VERSION}${CUDA_IMAGE_FLAVOR:+-}${CUDA_IMAGE_FLAVOR} AS files
ARG INSTALL_MAX
ARG NB_UID
ENV NB_GID=100
......@@ -44,13 +42,6 @@ RUN cp -a /files/etc/skel/. /files/var/backups/skel \
/files/usr/local/share/jupyter/lab/static/assets \
&& cp -a /files/opt/code-server/src/browser/media/fonts \
/files/usr/local/share/jupyter/lab/static/assets \
## Update Modular setup
&& if [ "${INSTALL_MAX}" = "1" -o "${INSTALL_MAX}" = "true" ]; then \
sed -i s/packages.modular.com_mojo/packages.modular.com_max/g \
/files/usr/local/etc/jupyter/jupyter_server_config.d/mojo-lsp-server.json; \
sed -i s/packages.modular.com_mojo/packages.modular.com_max/g \
/files/etc/profile.d/00-reset-path.sh; \
fi \
&& if [ -n "${CUDA_VERSION}" ]; then \
## Use entrypoint of CUDA image
mv /opt/nvidia/entrypoint.d /opt/nvidia/nvidia_entrypoint.sh \
......@@ -103,7 +94,7 @@ LABEL org.opencontainers.image.licenses="$IMAGE_LICENSE" \
org.opencontainers.image.authors="$IMAGE_AUTHORS"
ENV PARENT_IMAGE=${BUILD_ON_IMAGE}${PYTHON_VERSION:+:}${PYTHON_VERSION}${CUDA_IMAGE_FLAVOR:+-}${CUDA_IMAGE_FLAVOR} \
MODULAR_HOME=/opt/modular \
MODULAR_HOME=/opt/modular/share/max \
MOJO_VERSION=${MOJO_VERSION%%-*} \
NB_USER=${NB_USER} \
NB_UID=${NB_UID} \
......@@ -169,7 +160,7 @@ RUN dpkgArch="$(dpkg --print-architecture)" \
## Python: For h5py wheels (arm64)
libhdf5-dev \
## Python: Additional dev dependencies
&& if [ -z "$PYTHON_VERSION" ]; then \
&& if [ -z "${PYTHON_VERSION}" ]; then \
apt-get -y install --no-install-recommends \
python3-dev \
## Install Python package installer
......@@ -192,10 +183,16 @@ RUN dpkgArch="$(dpkg --print-architecture)" \
setuptools \
wheel; \
fi \
## Modular: Additional runtime dependencies
&& apt-get -y install --no-install-recommends \
libtinfo-dev \
libxml2-dev \
## MAX/Mojo: Additional runtime dependency
&& apt-get -y install --no-install-recommends libncurses-dev \
## mblack: Additional Python dependencies
&& export PIP_BREAK_SYSTEM_PACKAGES=1 \
&& pip install \
click \
mypy-extensions \
packaging \
pathspec \
platformdirs \
## Install font MesloLGS NF
&& mkdir -p /usr/share/fonts/truetype/meslo \
&& curl -sL https://github.com/romkatv/powerlevel10k-media/raw/master/MesloLGS%20NF%20Regular.ttf -o "/usr/share/fonts/truetype/meslo/MesloLGS NF Regular.ttf" \
......@@ -239,56 +236,118 @@ RUN dpkgArch="$(dpkg --print-architecture)" \
&& rm -rf /var/lib/apt/lists/* \
${HOME}/.cache
FROM base as modular
FROM base AS modular
ARG NB_GID=100
ARG MODULAR_VERSION
ARG MODULAR_NO_AUTH
ARG MODULAR_AUTH_KEY
ARG MOJO_VERSION
ARG MOJO_VERSION_FULL=${MOJO_VERSION}
ARG INSTALL_MAX
## Install Modular
RUN dpkgArch="$(dpkg --print-architecture)" \
&& apt-get update \
&& apt-get -y install --no-install-recommends \
libtinfo-dev \
libxml2-dev \
&& curl -sSL https://dl.modular.com/public/installer/deb/debian/pool/any-version/main/m/mo/modular_${MODULAR_VERSION}/modular-v${MODULAR_VERSION}-${dpkgArch}.deb \
-o modular.deb \
&& dpkg --ignore-depends=python3,python3-pip,python3-venv -i modular.deb \
&& rm modular.deb \
## Install Magic
RUN curl -ssL https://magic.modular.com | bash \
&& mv ${HOME}/.modular/bin/magic /usr/local/bin \
## Clean up
&& rm -rf /var/lib/apt/lists/*
## Install Mojo or MAX
RUN modular config-set telemetry.enabled=false \
&& modular config-set crash_reporting.enabled=false \
&& if [ "${MODULAR_NO_AUTH}" != "1" ] && [ "${MODULAR_NO_AUTH}" != "true" ]; then \
modular auth \
"${MODULAR_AUTH_KEY:-$(echo -n "${NB_USER}" | sha256sum | cut -c -8)}"; \
fi \
&& rm -rf ${HOME}/.modular \
&& rm -rf /usr/local/lib/python${PYTHON_VERSION%.*}/site-packages/* \
## Install MAX/Mojo
&& cd /tmp \
&& if [ "${INSTALL_MAX}" = "1" ] || [ "${INSTALL_MAX}" = "true" ]; then \
modular install --install-version "${MOJO_VERSION}" max; \
if [ "${MOJO_VERSION}" = "nightly" ]; then \
magic init -c conda-forge -c https://conda.modular.com/max-nightly; \
magic add max; \
else \
magic init -c conda-forge -c https://conda.modular.com/max; \
magic add max==${MOJO_VERSION}; \
fi \
else \
modular install --install-version "${MOJO_VERSION_FULL}" mojo; \
if [ "${MOJO_VERSION}" = "nightly" ]; then \
magic init -c conda-forge -c https://conda.modular.com/max-nightly; \
magic add mojo-jupyter; \
else \
magic init -c conda-forge -c https://conda.modular.com/max; \
magic add mojo-jupyter==${MOJO_VERSION}; \
fi \
fi \
&& chown -R root:${NB_GID} ${MODULAR_HOME} \
&& chmod -R g+w ${MODULAR_HOME} \
&& chmod -R g+rx ${MODULAR_HOME}/crashdb \
## Clean up
&& rm -rf ${MODULAR_HOME}/.*_cache
## Disable telemetry
&& magic telemetry --disable \
## Get rid of all the unnecessary stuff
## and move installation to /opt/modular
&& mkdir -p /opt/modular/bin \
&& mkdir -p /opt/modular/lib \
&& mkdir -p /opt/modular/share \
&& cd /tmp/.magic/envs \
&& if [ "${INSTALL_MAX}" = "1" ] || [ "${INSTALL_MAX}" = "true" ]; then \
cp -a default/bin/max /opt/modular/bin; \
cp -a default/lib/libDevice* \
default/lib/libGenericMLSupport* \
default/lib/libmodular* \
default/lib/libmof.so \
default/lib/*MOGG* \
default/lib/libmonnx.so \
default/lib/libmtorch.so \
default/lib/libServe* \
default/lib/libStock* \
default/lib/libTorch* \
/opt/modular/lib; \
fi \
&& if [ "${INSTALL_MAX}" = "1" ] || [ "${INSTALL_MAX}" = "true" ]; then \
cp -a default/lib/python${PYTHON_VERSION%.*}/site-packages/max* \
/usr/local/lib/python${PYTHON_VERSION%.*}/site-packages; \
fi \
&& cp -a default/bin/lldb* \
default/bin/mblack \
default/bin/modular* \
default/bin/mojo* \
/opt/modular/bin \
&& cp -a default/lib/libAsyncRT* \
default/lib/libCUDA* \
default/lib/libKGENCompilerRT* \
default/lib/liblldb* \
default/lib/libMojo* \
default/lib/libMSupport* \
default/lib/liborc_rt.a \
default/lib/lldb* \
default/lib/mojo* \
/opt/modular/lib \
&& cp -a default/lib/python${PYTHON_VERSION%.*}/site-packages/*mblack* \
default/lib/python${PYTHON_VERSION%.*}/site-packages/mblib* \
/usr/local/lib/python${PYTHON_VERSION%.*}/site-packages \
&& cp -a default/share/max /opt/modular/share \
&& cp -a default/test /opt/modular \
&& mkdir ${MODULAR_HOME}/crashdb \
&& rm ${MODULAR_HOME}/firstActivation \
## Fix Modular home for Mojo
&& sed -i "s|/tmp/.magic/envs/default|/opt/modular|g" \
${MODULAR_HOME}/modular.cfg \
## Fix Python path for mblack
&& sed -i "s|/tmp/.magic/envs/default|/usr/local|g" \
/opt/modular/bin/mblack \
## Fix permissions
&& chown -R root:${NB_GID} /opt/modular \
&& chmod -R g+w ${MODULAR_HOME}
## Install the Mojo kernel for Jupyter
RUN mkdir -p /usr/local/share/jupyter/kernels \
&& mv ${HOME}/.local/share/jupyter/kernels/mojo* \
&& mv /tmp/.magic/envs/default/share/jupyter/kernels/mojo* \
/usr/local/share/jupyter/kernels/ \
## Fix Modular home in the Mojo kernel for Jupyter
&& grep -rl ${HOME}/.local /usr/local/share/jupyter/kernels/mojo* | \
xargs sed -i "s|${HOME}/.local|/usr/local|g"
&& grep -rl /tmp/.magic/envs/default/share/jupyter /usr/local/share/jupyter/kernels/mojo* | \
xargs sed -i "s|/tmp/.magic/envs/default|/usr/local|g" \
&& grep -rl /usr/local/share/max /usr/local/share/jupyter/kernels/mojo* | \
xargs sed -i "s|/usr/local/share/max|/opt/modular/share/max|g" \
## Change display name in the Mojo kernel for Jupyter
&& sed -i "s|\"display_name\".*|\"display_name\": \"Mojo $MOJO_VERSION ${INSTALL_MAX:+(MAX)}\",|g" \
/usr/local/share/jupyter/kernels/mojo*/kernel.json \
&& if [ "${MOJO_VERSION}" = "nightly" ]; then \
cp -a /usr/local/share/jupyter/kernels/mojo*/nightly-logo-64x64.png \
/usr/local/share/jupyter/kernels/mojo*/logo-64x64.png; \
cp -a /usr/local/share/jupyter/kernels/mojo*/nightly-logo.svg \
/usr/local/share/jupyter/kernels/mojo*/logo.svg; \
fi
FROM base
ARG MOJO_EXTENSION_VERSION
ARG INSTALL_MAX
ENV PATH=/opt/code-server/bin:$PATH \
......@@ -313,8 +372,8 @@ RUN mkdir /opt/code-server \
&& code-server --extensions-dir ${CODE_BUILTIN_EXTENSIONS_DIR} --install-extension piotrpalarz.vscode-gitignore-generator-1.0.3.vsix \
&& curl -sLO https://dl.b-data.ch/vsix/mutantdino.resourcemonitor-1.0.7.vsix \
&& code-server --extensions-dir ${CODE_BUILTIN_EXTENSIONS_DIR} --install-extension mutantdino.resourcemonitor-1.0.7.vsix \
&& curl -sLO https://dl.b-data.ch/vsix/modular-mojotools.vscode-mojo-${MOJO_VERSION}.vsix \
&& code-server --extensions-dir ${CODE_BUILTIN_EXTENSIONS_DIR} --install-extension modular-mojotools.vscode-mojo-${MOJO_VERSION}.vsix \
&& curl -sLO https://dl.b-data.ch/vsix/modular-mojotools.vscode-mojo-${MOJO_EXTENSION_VERSION}.vsix \
&& code-server --extensions-dir ${CODE_BUILTIN_EXTENSIONS_DIR} --install-extension modular-mojotools.vscode-mojo-${MOJO_EXTENSION_VERSION}.vsix \
&& code-server --extensions-dir ${CODE_BUILTIN_EXTENSIONS_DIR} --install-extension alefragnani.project-manager \
&& code-server --extensions-dir ${CODE_BUILTIN_EXTENSIONS_DIR} --install-extension GitHub.vscode-pull-request-github \
&& code-server --extensions-dir ${CODE_BUILTIN_EXTENSIONS_DIR} --install-extension GitLab.gitlab-workflow \
......@@ -369,21 +428,41 @@ RUN export PIP_BREAK_SYSTEM_PACKAGES=1 \
&& rm -rf /tmp/* \
${HOME}/.cache
ARG MODULAR_PKG_BIN=${INSTALL_MAX:+$MODULAR_HOME/pkg/packages.modular.com_max/bin}
ARG MODULAR_PKG_BIN=${MODULAR_PKG_BIN:-$MODULAR_HOME/pkg/packages.modular.com_mojo/bin}
ENV PATH=${MODULAR_PKG_BIN}:$PATH
ENV PATH=/opt/modular/bin:$PATH
ENV MAGIC_NO_PATH_UPDATE=1
## Install Mojo or MAX
## Install MAX/Mojo
COPY --from=modular /opt /opt
## Install the Mojo kernel for Jupyter
COPY --from=modular /usr/local/share/jupyter /usr/local/share/jupyter
## Install the MAX Engine Python package or numpy
RUN export PIP_BREAK_SYSTEM_PACKAGES=1 \
## Install Python packages to the site library
COPY --from=modular /usr/local/lib/python${PYTHON_VERSION%.*}/site-packages \
/usr/local/lib/python${PYTHON_VERSION%.*}/site-packages
RUN curl -ssL https://magic.modular.com | grep '^MODULAR_HOME\|^BIN_DIR' \
> /tmp/magicenv \
&& cp /tmp/magicenv /var/tmp/magicenv.bak \
&& cp /tmp/magicenv /tmp/magicenv.mod \
&& chown ${NB_UID}:${NB_GID} /tmp/magicenv /tmp/magicenv.mod \
## Create the user's modular bin dir
&& . /tmp/magicenv \
&& mkdir -p ${BIN_DIR} \
## Append the user's modular bin dir to PATH
&& sed -i 's/\$HOME/\\$HOME/g' /tmp/magicenv.mod \
&& . /tmp/magicenv.mod \
&& echo "\n# Append the user's modular bin dir to PATH\nif [[ \"\$PATH\" != *\"${BIN_DIR}\"* ]] ; then\n PATH=\"\$PATH:${BIN_DIR}\"\nfi" | tee -a ${HOME}/.bashrc \
/etc/skel/.bashrc \
## Create the user's modular bin dir in the skeleton directory
&& HOME=/etc/skel . /tmp/magicenv \
&& mkdir -p ${BIN_DIR} \
## MAX/Mojo: Install Python dependencies
&& export PIP_BREAK_SYSTEM_PACKAGES=1 \
&& if [ "${INSTALL_MAX}" = "1" ] || [ "${INSTALL_MAX}" = "true" ]; then \
pip install --find-links \
${MODULAR_HOME}/pkg/packages.modular.com_max/wheels max-engine; \
packages=$(grep "Requires-Dist:" \
/usr/local/lib/python${PYTHON_VERSION%.*}/site-packages/max*.dist-info/METADATA | \
sed "s|Requires-Dist: \(.*\)|\1|" | \
tr -d "[:blank:]"); \
pip install $packages; \
else \
pip install numpy; \
fi \
......@@ -406,6 +485,16 @@ RUN sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master
&& ${HOME}/.oh-my-zsh/custom/themes/powerlevel10k/gitstatus/install -f \
&& sed -i 's/ZSH="\/home\/jovyan\/.oh-my-zsh"/ZSH="$HOME\/.oh-my-zsh"/g' ${HOME}/.zshrc \
&& sed -i 's/ZSH_THEME="robbyrussell"/ZSH_THEME="powerlevel10k\/powerlevel10k"/g' ${HOME}/.zshrc \
## Create the user's modular bin dir
&& . /tmp/magicenv \
&& mkdir -p ${BIN_DIR} \
## Append the user's modular bin dir to PATH
&& . /tmp/magicenv.mod \
&& echo "\n# Append the user's modular bin dir to PATH\nif [[ \"\$PATH\" != *\"${BIN_DIR}\"* ]] ; then\n PATH=\"\$PATH:${BIN_DIR}\"\nfi" | tee -a ${HOME}/.bashrc ${HOME}/.zshrc \
## Clean up
&& rm -rf /tmp/magicenv \
/tmp/magicenv.mod \
## Customise the bash/zsh run commands
&& echo "\n# set PATH so it includes user's private bin if it exists\nif [ -d \"\$HOME/bin\" ] && [[ \"\$PATH\" != *\"\$HOME/bin\"* ]] ; then\n PATH=\"\$HOME/bin:\$PATH\"\nfi" | tee -a ${HOME}/.bashrc ${HOME}/.zshrc \
&& echo "\n# set PATH so it includes user's private bin if it exists\nif [ -d \"\$HOME/.local/bin\" ] && [[ \"\$PATH\" != *\"\$HOME/.local/bin\"* ]] ; then\n PATH=\"\$HOME/.local/bin:\$PATH\"\nfi" | tee -a ${HOME}/.bashrc ${HOME}/.zshrc \
&& echo "\n# Update last-activity timestamps while in screen/tmux session\nif [ ! -z \"\$TMUX\" -o ! -z \"\$STY\" ] ; then\n busy &\nfi" >> ${HOME}/.bashrc \
......
#!/bin/bash
# Copyright (c) 2024 b-data GmbH.
# Distributed under the terms of the MIT License.
set -e
MODULAR_HOME_BAK="$MODULAR_HOME"
# Append the user's modular bin dir to PATH
if [ "$(id -u)" == 0 ] ; then
if ! grep -q "user's modular bin dir" "/home/$NB_USER${DOMAIN:+@$DOMAIN}/.bashrc"; then
(curl -ssL https://magic.modular.com || cat /var/tmp/magicenv.bak) \
| grep '^MODULAR_HOME\|^BIN_DIR' | tee /tmp/magicenv > /dev/null
. <(sed 's|\$HOME|/home/\$NB_USER\${DOMAIN:+@\$DOMAIN}|g' /tmp/magicenv)
run_user_group mkdir -p "${BIN_DIR}"
sed -i 's/\$HOME/\\$HOME/g' /tmp/magicenv
. /tmp/magicenv
echo -e "\n# Append the user's modular bin dir to PATH\nif [[ \"\$PATH\" != *\"${BIN_DIR}\"* ]] ; then\n PATH=\"\$PATH:${BIN_DIR}\"\nfi" >> "/home/$NB_USER${DOMAIN:+@$DOMAIN}/.bashrc"
rm /tmp/magicenv
fi
if ! grep -q "user's modular bin dir" "/home/$NB_USER${DOMAIN:+@$DOMAIN}/.zshrc"; then
(curl -ssL https://magic.modular.com || cat /var/tmp/magicenv.bak) \
| grep '^MODULAR_HOME\|^BIN_DIR' | tee /tmp/magicenv > /dev/null
. <(sed 's|\$HOME|/home/\$NB_USER\${DOMAIN:+@\$DOMAIN}|g' /tmp/magicenv)
run_user_group mkdir -p "${BIN_DIR}"
sed -i 's/\$HOME/\\$HOME/g' /tmp/magicenv
. /tmp/magicenv
echo -e "\n# Append the user's modular bin dir to PATH\nif [[ \"\$PATH\" != *\"${BIN_DIR}\"* ]] ; then\n PATH=\"\$PATH:${BIN_DIR}\"\nfi" >> "/home/$NB_USER${DOMAIN:+@$DOMAIN}/.zshrc"
rm /tmp/magicenv
fi
else
if ! grep -q "user's modular bin dir" "$HOME/.bashrc"; then
(curl -ssL https://magic.modular.com || cat /var/tmp/magicenv.bak) \
| grep '^MODULAR_HOME\|^BIN_DIR' | tee /tmp/magicenv > /dev/null
. /tmp/magicenv
mkdir -p "${BIN_DIR}"
sed -i 's/\$HOME/\\$HOME/g' /tmp/magicenv
. /tmp/magicenv
echo -e "\n# Append the user's modular bin dir to PATH\nif [[ \"\$PATH\" != *\"${BIN_DIR}\"* ]] ; then\n PATH=\"\$PATH:${BIN_DIR}\"\nfi" >> "$HOME/.bashrc"
rm /tmp/magicenv
fi
if ! grep -q "user's modular bin dir" "$HOME/.zshrc"; then
(curl -ssL https://magic.modular.com || cat /var/tmp/magicenv.bak) \
| grep '^MODULAR_HOME\|^BIN_DIR' | tee /tmp/magicenv > /dev/null
. /tmp/magicenv
mkdir -p "${BIN_DIR}"
sed -i 's/\$HOME/\\$HOME/g' /tmp/magicenv
. /tmp/magicenv
echo -e "\n# Append the user's modular bin dir to PATH\nif [[ \"\$PATH\" != *\"${BIN_DIR}\"* ]] ; then\n PATH=\"\$PATH:${BIN_DIR}\"\nfi" >> "$HOME/.zshrc"
rm /tmp/magicenv
fi
fi
MODULAR_HOME="$MODULAR_HOME_BAK"
unset MODULAR_HOME_BAK
# MAX SDK: Evaluate and set version
if [ "$(id -u)" == 0 ] ; then
if [ "${MOJO_VERSION}" = "nightly" ]; then
extDataDir=/home/$NB_USER${DOMAIN:+@$DOMAIN}/.local/share/code-server/User/globalStorage/modular-mojotools.vscode-mojo-nightly
sdkVersion=$(jq -r '.sdkVersion' /opt/code-server/lib/vscode/extensions/modular-mojotools.vscode-mojo*/package.json)
else
extDataDir=/home/$NB_USER${DOMAIN:+@$DOMAIN}/.local/share/code-server/User/globalStorage/modular-mojotools.vscode-mojo
sdkVersion=$MOJO_VERSION
fi
else
if [ "${MOJO_VERSION}" = "nightly" ]; then
extDataDir=$HOME/.local/share/code-server/User/globalStorage/modular-mojotools.vscode-mojo-nightly
sdkVersion=$(jq -r '.sdkVersion' /opt/code-server/lib/vscode/extensions/modular-mojotools.vscode-mojo*/package.json)
else
extDataDir=$HOME/.local/share/code-server/User/globalStorage/modular-mojotools.vscode-mojo
sdkVersion=$MOJO_VERSION
fi
fi
# MAX SDK: Create symlink to /opt/modular
if [ "$(id -u)" == 0 ] ; then
run_user_group mkdir -p "$extDataDir/magic-data-home/envs"
run_user_group ln -snf /opt/modular "$extDataDir/magic-data-home/envs/max"
run_user_group mkdir -p "$extDataDir/versionDone/$sdkVersion"
else
mkdir -p "$extDataDir/magic-data-home/envs"
ln -snf /opt/modular "$extDataDir/magic-data-home/envs/max"
mkdir -p "$extDataDir/versionDone/$sdkVersion"
fi
......@@ -3,7 +3,7 @@ ARG BASE_IMAGE_TAG=12
ARG BUILD_ON_IMAGE
ARG MOJO_VERSION
ARG NODE_VERSION=20.17.0
ARG NODE_VERSION=20.18.0
ARG CODE_BUILTIN_EXTENSIONS_DIR=/opt/code-server/lib/vscode/extensions
FROM glcr.b-data.ch/nodejs/nsi/${NODE_VERSION}/${BASE_IMAGE}:${BASE_IMAGE_TAG} as nsi
......
.env:
variables:
MOJO_VERSION: "24.4.0"
MOJO_VERSION: "24.5.0"
CTAN_REPO_BUILD_LATEST: "https://mirror.init7.net/ctan/systems/texlive/tlnet"
TAG_VERSION_MAJ_MIN: "true"
TAG_VERSION_MAJ_MIN: "false"
TAG_VERSION_MAJ: "false"
.before-script-build: &before-script-build
......
ARG BUILD_ON_IMAGE=glcr.b-data.ch/jupyterlab/mojo/base
ARG MOJO_VERSION
ARG CODE_BUILTIN_EXTENSIONS_DIR=/opt/code-server/lib/vscode/extensions
ARG QUARTO_VERSION=1.5.57
ARG QUARTO_VERSION=1.6.39
ARG CTAN_REPO=https://mirror.ctan.org/systems/texlive/tlnet
FROM ${BUILD_ON_IMAGE}${MOJO_VERSION:+:}${MOJO_VERSION}
......@@ -37,6 +37,9 @@ RUN dpkgArch="$(dpkg --print-architecture)" \
&& mkdir -p /opt/quarto \
&& tar -xzf quarto-${QUARTO_VERSION}-linux-${dpkgArch}.tar.gz -C /opt/quarto --no-same-owner --strip-components=1 \
&& rm quarto-${QUARTO_VERSION}-linux-${dpkgArch}.tar.gz \
## Exempt quarto from address space limit
&& sed -i 's/"${QUARTO_DENO}"/prlimit -v=unlimited: "${QUARTO_DENO}"/g' \
/opt/quarto/bin/quarto \
## Remove quarto pandoc
&& rm /opt/quarto/bin/tools/$(uname -m)/pandoc \
## Link to system pandoc
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment