Skip to content

Commit dbfc3d7

Browse files
author
Prabhakar Kumar
committed
Various bugfixes to Dockerfiles and new matrix style workflows to build and publish containers for all dockerfiles for 4 releases of MATLAB
1 parent ad39fba commit dbfc3d7

File tree

8 files changed

+282
-267
lines changed

8 files changed

+282
-267
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
runs:
2+
using: "composite"
3+
steps:
4+
- uses: actions/checkout@v2
5+
6+
- uses: docker/setup-buildx-action@v1
7+
8+
- uses: docker/login-action@v1
9+
with:
10+
registry: ${{ inputs.registry }}
11+
username: ${{ github.repository_owner }}
12+
password: ${{ inputs.github_token }}
13+
14+
- uses: docker/build-push-action@v2
15+
with:
16+
context: ${{ inputs.context }}
17+
platforms: linux/amd64
18+
file: ${{ inputs.dockerfile }}
19+
tags: ${{ inputs.registry }}/${{ inputs.github_repo }}/${{ inputs.image }}:${{ inputs.matlab_release }}
20+
build-args: MATLAB_RELEASE=${{ inputs.matlab_release }}
21+
push: true
22+
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# Build & Publish all Dockerfiles in the repository, for pre-defined set of MATLAB version.
2+
name: Build MIFJ Dockerfiles
3+
4+
# Define when builds will occur:
5+
on:
6+
# Run workflow when there is a push to the 'main' branch & push includes changes to any Dockerfile or YML files
7+
push:
8+
branches:
9+
- 'main'
10+
paths:
11+
- '**Dockerfile*'
12+
- '**.yml'
13+
14+
# Run workflow when there is a release
15+
release:
16+
types:
17+
- 'created'
18+
19+
# Run at 00:00 on every Monday (1st Day of the Week) (See: crontab.guru)
20+
schedule:
21+
- cron: '0 0 * * 1'
22+
23+
jobs:
24+
docker:
25+
# Each job needs a runner environment
26+
runs-on: ubuntu-latest
27+
continue-on-error: True
28+
strategy:
29+
matrix:
30+
matlab_release: [r2022a, r2021b, r2021a, r2020b]
31+
dockerfile: ["./matlab/Dockerfile", "./matlab/Dockerfile.byoi", "./matlab/Dockerfile.mounted", "./matlab-vnc/Dockerfile", "./matlab-vnc/Dockerfile.mounted"]
32+
include:
33+
- image: "jupyter-matlab-notebook"
34+
dockerfile: "./matlab/Dockerfile"
35+
context: "./matlab"
36+
37+
- image: "jupyter-byoi-matlab-notebook"
38+
dockerfile: "./matlab/Dockerfile.byoi"
39+
context: "./matlab"
40+
41+
- image: "jupyter-mounted-matlab-notebook"
42+
dockerfile: "./matlab/Dockerfile.mounted"
43+
context: "./matlab"
44+
45+
- image: "jupyter-matlab-vnc-notebook"
46+
dockerfile: "./matlab-vnc/Dockerfile"
47+
context: "./matlab-vnc"
48+
49+
- image: "jupyter-mounted-matlab-vnc-notebook"
50+
dockerfile: "./matlab-vnc/Dockerfile.mounted"
51+
context: "./matlab-vnc"
52+
53+
steps:
54+
- uses: actions/checkout@v2
55+
- uses: ./.github/actions/build-and-push-notebook
56+
with:
57+
dockerfile: ${{ matrix.dockerfile }}
58+
context: ${{ matrix.context }}
59+
matlab_release: ${{ matrix.matlab_release }}
60+
image: ${{ matrix.image }}
61+
registry: ghcr.io
62+
github_token: ${{ secrets.GITHUB_TOKEN }}
63+
github_repo: ${{ github.repository }}

.github/workflows/build-and-publish-notebook.yml

Lines changed: 0 additions & 39 deletions
This file was deleted.

matlab-vnc/Dockerfile

Lines changed: 89 additions & 116 deletions
Original file line numberDiff line numberDiff line change
@@ -1,109 +1,62 @@
1-
# Copyright 2021 The MathWorks, Inc.
2-
3-
# Argument shared across multi-stage build to hold location of installed MATLAB
4-
ARG BASE_ML_INSTALL_LOC=/tmp/matlab-install-location
5-
6-
# Replace "mathworks/matlab:r2021b" with the Docker image that contains MATLAB
7-
# MATLAB should be available on the path in the Docker image
8-
FROM mathworks/matlab:r2021b AS matlab-install-stage
9-
ARG BASE_ML_INSTALL_LOC
10-
11-
# Run code to locate a MATLAB install in the base image and softlink
12-
# to BASE_ML_INSTALL_LOC for a latter stage to copy
13-
RUN export ML_INSTALL_LOC=$(which matlab) \
14-
&& if [ ! -z "$ML_INSTALL_LOC" ]; then \
15-
ML_INSTALL_LOC=$(dirname $(dirname $(readlink -f ${ML_INSTALL_LOC}))); \
16-
echo "soft linking: " $ML_INSTALL_LOC " to" ${BASE_ML_INSTALL_LOC}; \
17-
ln -s ${ML_INSTALL_LOC} ${BASE_ML_INSTALL_LOC}; \
18-
elif [ $BASE_ML_INSTALL_LOC = '/tmp/matlab-install-location' ]; then \
19-
echo "MATLAB was not found in your image."; exit 1; \
20-
else \
21-
echo "Proceeding with user provided path to MATLAB installation: ${BASE_ML_INSTALL_LOC}"; \
22-
fi
23-
24-
FROM jupyter/base-notebook
25-
ARG BASE_ML_INSTALL_LOC
1+
# Copyright 2021-2022 The MathWorks, Inc.
2+
# Builds Docker image with
3+
# 1. MATLAB - Using MPM
4+
# 2. MATLAB Integration for Jupyter (VNC)
5+
# on a base image of jupyter/base-notebook.
6+
7+
## Sample Build Command:
8+
# docker build --build-arg MATLAB_RELEASE=r2022a \
9+
# --build-arg MATLAB_PRODUCT_LIST="MATLAB Deep_Learning_Toolbox Symbolic_Math_Toolbox"\
10+
# --build-arg [email protected] \
11+
# -t my_matlab_image_name .
12+
13+
# Specify release of MATLAB to build. (use lowercase, default is r2022a)
14+
ARG MATLAB_RELEASE=r2022a
15+
16+
# Specify the list of products to install into MATLAB,
17+
ARG MATLAB_PRODUCT_LIST="MATLAB"
18+
19+
# Optional Network License Server information
20+
ARG LICENSE_SERVER
21+
22+
# If LICENSE_SERVER is provided then SHOULD_USE_LICENSE_SERVER will be set to "_use_lm"
23+
ARG SHOULD_USE_LICENSE_SERVER=${LICENSE_SERVER:+"_with_lm"}
24+
25+
# Default DDUX information
26+
ARG MW_CONTEXT_TAGS=MATLAB_PROXY:JUPYTER:MPM:V1
27+
28+
# Base Jupyter image without LICENSE_SERVER, using python-3.9.12 as websockify only supports upto 3.9
29+
FROM jupyter/base-notebook:python-3.9.12 AS base_jupyter_image
30+
31+
# Base Jupyter image with LICENSE_SERVER
32+
FROM jupyter/base-notebook:python-3.9.12 AS base_jupyter_image_with_lm
33+
ARG LICENSE_SERVER
34+
# If license server information is available, then use it to set environment variable
35+
ENV MLM_LICENSE_FILE=${LICENSE_SERVER}
36+
37+
# Select base Jupyter image based on whether LICENSE_SERVER is provided
38+
FROM base_jupyter_image${SHOULD_USE_LICENSE_SERVER}
39+
ARG MW_CONTEXT_TAGS
40+
ARG MATLAB_RELEASE
41+
ARG MATLAB_PRODUCT_LIST
2642

2743
# Switch to root user
2844
USER root
45+
ENV DEBIAN_FRONTEND="noninteractive" TZ="Etc/UTC"
2946

30-
# Copy MATLAB install from Docker image
31-
COPY --from=matlab-install-stage ${BASE_ML_INSTALL_LOC} /usr/local/MATLAB
32-
33-
# Add MATLAB to the path
34-
RUN ln -s /usr/local/MATLAB/bin/matlab /usr/local/bin/matlab
35-
36-
## Install MATLAB dependencies
37-
# Please update this list for the version of MATLAB you are using.
38-
# Listed below are the dependencies of R2021b for Ubuntu 20.04
39-
# Reference: https://github.com/mathworks-ref-arch/container-images/tree/master/matlab-deps/r2021b
40-
RUN export DEBIAN_FRONTEND=noninteractive && apt-get update && apt-get install --no-install-recommends -y \
41-
ca-certificates \
42-
libasound2 \
43-
libatk-bridge2.0-0 \
44-
libatk1.0-0 \
45-
libatspi2.0-0 \
46-
libc6 \
47-
libcairo-gobject2 \
48-
libcairo2 \
49-
libcap2 \
50-
libcrypt1 \
51-
libcups2 \
52-
libdbus-1-3 \
53-
libdrm2 \
54-
libfontconfig1 \
55-
libgbm1 \
56-
libgdk-pixbuf2.0-0 \
57-
libglib2.0-0 \
58-
libgomp1 \
59-
libgstreamer-plugins-base1.0-0 \
60-
libgstreamer1.0-0 \
61-
libgtk-3-0 \
62-
libnspr4 \
63-
libnss3 \
64-
libodbc1 \
65-
libpam0g \
66-
libpango-1.0-0 \
67-
libpangocairo-1.0-0 \
68-
libpangoft2-1.0-0 \
69-
libpython3.9 \
70-
libsm6 \
71-
libsndfile1 \
72-
libssl1.1 \
73-
libuuid1 \
74-
libx11-6 \
75-
libx11-xcb1 \
76-
libxcb-dri3-0 \
77-
libxcb1 \
78-
libxcomposite1 \
79-
libxcursor1 \
80-
libxdamage1 \
81-
libxext6 \
82-
libxfixes3 \
83-
libxft2 \
84-
libxi6 \
85-
libxinerama1 \
86-
libxrandr2 \
87-
libxrender1 \
88-
libxt6 \
89-
libxtst6 \
90-
libxxf86vm1 \
91-
locales \
92-
locales-all \
93-
make \
94-
net-tools \
95-
procps \
96-
sudo \
97-
unzip \
98-
zlib1g \
99-
&& apt-get clean \
100-
&& apt-get -y autoremove \
101-
&& rm -rf /var/lib/apt/lists/*
47+
## Installing Dependencies for Ubuntu 20.04
48+
# For MATLAB : Get base-dependencies.txt from matlab-deps repository on GitHub
49+
# For mpm : wget, unzip, ca-certificates
50+
# For MATLAB Integration for Jupyter (VNC): xvfb dbus-x11 firefox xfce4 xfce4-panel xfce4-session xfce4-settings xorg xubuntu-icon-theme curl xscreensaver
10251

103-
# Install jupyter-matlab-vnc dependencies
104-
RUN export DEBIAN_FRONTEND=noninteractive \
105-
&& apt-get -y update \
106-
&& apt-get install -y \
52+
# List of MATLAB Dependencies for Ubuntu 20.04 and specified MATLAB_RELEASE
53+
ARG MATLAB_DEPS_REQUIREMENTS_FILE="https://raw.githubusercontent.com/mathworks-ref-arch/container-images/main/matlab-deps/${MATLAB_RELEASE}/ubuntu20.04/base-dependencies.txt"
54+
ARG MATLAB_DEPS_REQUIREMENTS_FILE_NAME="matlab-deps-${MATLAB_RELEASE}-base-dependencies.txt"
55+
56+
# Install dependencies
57+
RUN wget ${MATLAB_DEPS_REQUIREMENTS_FILE} -O ${MATLAB_DEPS_REQUIREMENTS_FILE_NAME} && \
58+
export DEBIAN_FRONTEND=noninteractive && apt-get update && \
59+
xargs -a ${MATLAB_DEPS_REQUIREMENTS_FILE_NAME} -r apt-get install --no-install-recommends -y \
10760
dbus-x11 \
10861
firefox \
10962
xfce4 \
@@ -119,6 +72,28 @@ RUN export DEBIAN_FRONTEND=noninteractive \
11972
&& apt-get -y autoremove \
12073
&& rm -rf /var/lib/apt/lists/*
12174

75+
# Run mpm to install MATLAB in the target location and delete the mpm installation afterwards
76+
RUN wget -q https://www.mathworks.com/mpm/glnxa64/mpm && \
77+
chmod +x mpm && \
78+
./mpm install \
79+
--release=${MATLAB_RELEASE} \
80+
--destination=/opt/matlab \
81+
--products ${MATLAB_PRODUCT_LIST} && \
82+
rm -f mpm /tmp/mathworks_root.log && \
83+
ln -s /opt/matlab/bin/matlab /usr/local/bin/matlab
84+
85+
# Install patched glibc - See https://github.com/mathworks/build-glibc-bz-19329-patch
86+
WORKDIR /packages
87+
RUN export DEBIAN_FRONTEND=noninteractive && \
88+
apt-get update && apt-get clean && apt-get autoremove && \
89+
wget -q https://github.com/mathworks/build-glibc-bz-19329-patch/releases/download/ubuntu-focal/all-packages.tar.gz && \
90+
tar -x -f all-packages.tar.gz \
91+
--exclude glibc-*.deb \
92+
--exclude libc6-dbg*.deb && \
93+
apt-get install --yes --no-install-recommends --allow-downgrades ./*.deb && \
94+
rm -fr /packages
95+
WORKDIR /
96+
12297
# Install tigervnc to /usr/local
12398
RUN curl -sSfL 'https://sourceforge.net/projects/tigervnc/files/stable/1.10.1/tigervnc-1.10.1.x86_64.tar.gz/download' \
12499
| tar -zxf - -C /usr/local --strip=2
@@ -129,9 +104,9 @@ ARG NOVNC_PATH=/opt/noVNC
129104

130105
# Get noVNC
131106
RUN mkdir -p ${NOVNC_PATH} \
132-
&& curl -sSfL 'https://github.com/novnc/noVNC/archive/v1.2.0.tar.gz' \
133-
| tar -zxf - -C ${NOVNC_PATH} --strip=1 \
134-
&& chown -R ${NB_USER}:users ${NOVNC_PATH}
107+
&& curl -sSfL 'https://github.com/novnc/noVNC/archive/v1.2.0.tar.gz' \
108+
| tar -zxf - -C ${NOVNC_PATH} --strip=1 \
109+
&& chown -R ${NB_USER}:users ${NOVNC_PATH}
135110

136111
# JOVYAN is the default user in jupyter/base-notebook.
137112
# JOVYAN is being set to be passwordless.
@@ -146,23 +121,21 @@ RUN conda install -y -q websockify=0.9.0
146121

147122
# Set environment variable for python package jupyter-matlab-vnc-proxy
148123
ENV NOVNC_PATH=${NOVNC_PATH}
149-
# Pip install the integration
150-
RUN python -m pip install https://github.com/mathworks/jupyter-matlab-vnc-proxy/archive/0.1.0.tar.gz
124+
125+
# Pip install the latest version of the integration
126+
RUN curl -s https://api.github.com/repos/mathworks/jupyter-matlab-vnc-proxy/releases/latest | grep tarball_url | cut -d '"' -f 4 | xargs python -m pip install
151127

152128
# Ensure jupyter-server-proxy JupyterLab extension is installed
153129
RUN jupyter labextension install @jupyterlab/server-proxy
154130

155131
# Move MATLAB resource files to the expected locations
156132
RUN export RESOURCES_LOC=$(python -c "import jupyter_matlab_vnc_proxy as pkg; print(pkg.__path__[0])")/resources \
157-
&& mkdir -p ${HOME}/.local/share/applications ${HOME}/Desktop ${HOME}/.local/share/ ${HOME}/.icons \
158-
&& cp ${RESOURCES_LOC}/MATLAB.desktop ${HOME}/Desktop/ \
159-
&& cp ${RESOURCES_LOC}/MATLAB.desktop ${HOME}/.local/share/applications\
160-
&& ln -s ${RESOURCES_LOC}/matlab_icon.png ${HOME}/.icons/matlab_icon.png \
161-
&& cp ${RESOURCES_LOC}/matlab_launcher.py ${HOME}/.local/share/ \
162-
&& cp ${RESOURCES_LOC}/mw_lite.html ${NOVNC_PATH}
133+
&& mkdir -p ${HOME}/.local/share/applications ${HOME}/Desktop ${HOME}/.local/share/ ${HOME}/.icons \
134+
&& cp ${RESOURCES_LOC}/MATLAB.desktop ${HOME}/Desktop/ \
135+
&& cp ${RESOURCES_LOC}/MATLAB.desktop ${HOME}/.local/share/applications\
136+
&& ln -s ${RESOURCES_LOC}/matlab_icon.png ${HOME}/.icons/matlab_icon.png \
137+
&& cp ${RESOURCES_LOC}/matlab_launcher.py ${HOME}/.local/share/ \
138+
&& cp ${RESOURCES_LOC}/mw_lite.html ${NOVNC_PATH}
163139

164140
# Fixes occasional failure to start VNC desktop, which requires a reloading of the webpage to fix.
165-
RUN touch ${HOME}/.Xauthority
166-
167-
# Uncomment and set the port and hostname to configure a network license manager for all users
168-
# ENV MLM_LICENSE_FILE port@hostname
141+
RUN touch ${HOME}/.Xauthority

0 commit comments

Comments
 (0)