-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add matlab-jupyter image (#454)
- Loading branch information
Showing
3 changed files
with
133 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,6 +38,7 @@ jobs: | |
- docker/cuda/Dockerfile | ||
- docker/vnc/Dockerfile | ||
- docker/matlab/Dockerfile | ||
- docker/matlab-jupyter/Dockerfile | ||
- docker/julia/Dockerfile | ||
- docker/batch/Dockerfile | ||
- docker/qgis/Dockerfile | ||
|
@@ -347,7 +348,6 @@ jobs: | |
build-py-ext: | ||
needs: build-py | ||
runs-on: ubuntu-latest | ||
|
||
strategy: | ||
fail-fast: true | ||
matrix: | ||
|
@@ -396,6 +396,55 @@ jobs: | |
provenance: false | ||
platforms: linux/amd64,linux/arm64 | ||
|
||
build-matlab-ext: | ||
needs: build-py | ||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: true | ||
matrix: | ||
include: | ||
- EXTENSION: matlab-jupyter | ||
PYTHON_VERSION: "3.10" | ||
- EXTENSION: matlab-jupyter | ||
PYTHON_VERSION: "3.11" | ||
steps: | ||
- name: Docker Login | ||
uses: Azure/docker-login@v1 | ||
with: | ||
username: ${{ secrets.RENKU_DOCKER_USERNAME }} | ||
password: ${{ secrets.RENKU_DOCKER_PASSWORD }} | ||
- uses: actions/checkout@v4 | ||
- name: Set outputs | ||
id: vars | ||
run: | | ||
sha_short=$(git rev-parse --short HEAD) | ||
echo "sha_short=$sha_short" >> $GITHUB_OUTPUT | ||
- name: Set up QEMU | ||
uses: docker/[email protected] | ||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
- name: Docker meta | ||
id: meta | ||
uses: docker/metadata-action@v5 | ||
with: | ||
images: ${{ env.DOCKER_PREFIX }}-${{ matrix.EXTENSION }} | ||
tags: | | ||
type=sha,prefix=${{ matrix.PYTHON_VERSION }}- | ||
type=semver,pattern={{version}},prefix=${{ matrix.PYTHON_VERSION }}- | ||
type=raw,value=latest,enable=${{ github.ref == 'refs/heads/main' }},prefix=${{ matrix.PYTHON_VERSION }}- | ||
- name: Build and push | ||
uses: docker/build-push-action@v5 | ||
with: | ||
build-args: | | ||
RENKU_BASE=${{ env.DOCKER_PREFIX }}-py:${{ matrix.PYTHON_VERSION }}-${{ steps.vars.outputs.sha_short }} | ||
context: docker/${{ matrix.EXTENSION }} | ||
labels: ${{ steps.meta.outputs.labels }} | ||
push: true | ||
tags: ${{ steps.meta.outputs.tags }} | ||
cache-from: type=gha | ||
provenance: false | ||
platforms: linux/amd64 | ||
|
||
build-vnc-ext: | ||
needs: build-py-ext | ||
runs-on: ubuntu-latest | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
# define build arguments | ||
ARG RENKU_BASE=renku/renkulab-py:latest | ||
ARG BASE_IMAGE=mathworks/matlab:r2024a | ||
|
||
# define base images | ||
FROM $RENKU_BASE as renku_base | ||
FROM $BASE_IMAGE | ||
|
||
LABEL maintainer="Swiss Data Science Center <[email protected]>" | ||
|
||
USER root | ||
|
||
ENV NB_USER matlab | ||
ENV NB_UID 1000 | ||
ENV NB_GID 100 | ||
ENV VENV_DIR /srv/venv | ||
ENV HOME /home/${NB_USER} | ||
ENV SHELL bash | ||
ENV CONDA_PATH /opt/conda | ||
SHELL [ "/bin/bash", "-c", "-o", "pipefail" ] | ||
|
||
# prepend conda and local/bin to PATH | ||
ENV PATH ${HOME}/.local/bin:${CONDA_PATH}/bin:${HOME}/.renku/bin:$PATH | ||
|
||
# Add Tini | ||
ENV TINI_VERSION v0.18.0 | ||
ADD https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini /tini | ||
RUN chmod +x /tini && ln -s /tini /usr/bin/ | ||
|
||
# install dependencies | ||
RUN apt-get update --fix-missing && \ | ||
apt-get install -yq --no-install-recommends \ | ||
bzip2 \ | ||
ca-certificates \ | ||
curl \ | ||
git \ | ||
gpg-agent \ | ||
rclone \ | ||
vim && \ | ||
apt-get purge && \ | ||
apt-get clean && \ | ||
apt-get autoremove --yes && \ | ||
rm -rf /var/lib/apt/lists/* && \ | ||
curl -L -s https://github.com/git-lfs/git-lfs/releases/download/v3.3.0/git-lfs-linux-"$(dpkg --print-architecture)"-v3.3.0.tar.gz -o /tmp/git-lfs-linux-"$(dpkg --print-architecture)"-v3.3.0.tar.gz && \ | ||
tar -zxvf /tmp/git-lfs-linux-"$(dpkg --print-architecture)"-v3.3.0.tar.gz -C /tmp && \ | ||
/tmp/git-lfs-3.3.0/install.sh && \ | ||
rm -rf /tmp/git-lfs* && \ | ||
curl -L -o /usr/bin/mpm -s https://www.mathworks.com/mpm/glnxa64/mpm && \ | ||
chmod a+x /usr/bin/mpm | ||
|
||
# inject the renku-jupyter stack | ||
COPY --from=renku_base /opt/conda /opt/conda | ||
COPY --from=renku_base --chown=matlab:matlab /usr/local/bin/ /usr/local/bin/ | ||
COPY --from=renku_base --chown=matlab:matlab /home/jovyan/ /home/matlab/ | ||
COPY --from=renku_base /entrypoint.sh /entrypoint.sh | ||
COPY --from=renku_base /renku/bashrc /renku/bashrc | ||
|
||
# set permissions of the R library directory to be editable by NB_USER | ||
RUN chown 1000:100 /opt/conda && \ | ||
chown -R 1000:1000 /opt/matlab/R2024a && \ | ||
# this hack lets some of the setup from the base renku image work here | ||
ln -s /home/${NB_USER} /home/jovyan | ||
|
||
USER ${NB_USER} | ||
|
||
# set up conda in the NB_USER environment | ||
RUN echo ". ${CONDA_PATH}/etc/profile.d/conda.sh" >> ~/.bashrc && \ | ||
echo "conda activate base" >> ~/.bashrc && \ | ||
cat /renku/bashrc >> $HOME/.bashrc && \ | ||
echo "source ~/.bashrc" >> ~/.bash_profile && \ | ||
pip install --no-cache-dir "jupyter-matlab-proxy" | ||
|
||
ENTRYPOINT [ "/tini", "--", "/entrypoint.sh" ] | ||
CMD [ "jupyter", "server", "--ip", "0.0.0.0" ] | ||
|
||
WORKDIR ${HOME} |