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 any 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
5
+ # on a base image of jupyter/base-notebook.
6
+
7
+ # # Sample Build Command:
8
+ # docker build --build-arg MATLAB_RELEASE=r2021b \
9
+ # --build-arg MATLAB_PRODUCT_LIST="MATLAB Deep_Learning_Toolbox Symbolic_Math_Toolbox"\
10
+ # --build-arg LICENSE_SERVER=12345@hostname.com \
11
+ # -t my_matlab_image_name .
12
+
13
+ # Specify release of MATLAB to build. (use lowercase, default is r2021b)
14
+ ARG MATLAB_RELEASE=r2021b
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
29
+ FROM jupyter/base-notebook AS base_jupyter_image
30
+
31
+ # Base Jupyter image with LICENSE_SERVER
32
+ FROM jupyter/base-notebook 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
26
42
27
43
# Switch to root user
28
44
USER root
45
+ ENV DEBIAN_FRONTEND="noninteractive" TZ="Etc/UTC"
29
46
30
- # Copy MATLAB install from supplied Docker image
31
- COPY --from=matlab-install-stage ${BASE_ML_INSTALL_LOC} /usr/local/MATLAB
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 : xvfb
32
51
33
- # Put MATLAB on the PATH
34
- RUN ln -s /usr/local/MATLAB/bin/ matlab /usr/local/bin/matlab
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"
35
54
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 \
55
+ # Install dependencies
56
+ RUN export DEBIAN_FRONTEND=noninteractive && apt-get update \
57
+ && apt-get install --no-install-recommends -y `wget -qO- ${MATLAB_DEPS_REQUIREMENTS_FILE}`\
58
+ wget \
97
59
unzip \
98
- zlib1g \
60
+ ca-certificates \
61
+ xvfb \
99
62
&& apt-get clean \
100
63
&& apt-get -y autoremove \
101
64
&& rm -rf /var/lib/apt/lists/*
102
65
103
- # Install jupyter-matlab-proxy dependencies
104
- RUN export DEBIAN_FRONTEND=noninteractive && apt-get update && apt-get install --yes \
105
- xvfb \
106
- && apt-get clean \
107
- && rm -rf /var/lib/apt/lists/*
66
+ # Run mpm to install MATLAB in the target location and delete the mpm installation afterwards
67
+ RUN wget -q https://www.mathworks.com/mpm/glnxa64/mpm && \
68
+ chmod +x mpm && \
69
+ ./mpm install \
70
+ --release=${MATLAB_RELEASE} \
71
+ --destination=/opt/matlab \
72
+ --products ${MATLAB_PRODUCT_LIST} && \
73
+ rm -f mpm /tmp/mathworks_root.log && \
74
+ ln -s /opt/matlab/bin/matlab /usr/local/bin/matlab
75
+
76
+ # Install patched glibc - See https://github.com/mathworks/build-glibc-bz-19329-patch
77
+ WORKDIR /packages
78
+ RUN export DEBIAN_FRONTEND=noninteractive &&\
79
+ wget -q https://github.com/mathworks/build-glibc-bz-19329-patch/releases/download/ubuntu-focal/all-packages.tar.gz &&\
80
+ tar -x -f all-packages.tar.gz \
81
+ --exclude glibc-*.deb \
82
+ --exclude libc6-dbg*.deb &&\
83
+ apt-get install --yes --no-install-recommends ./*.deb &&\
84
+ rm -fr /packages
85
+ WORKDIR /
108
86
109
87
# Switch back to notebook user
110
88
USER $NB_USER
@@ -115,5 +93,7 @@ RUN python -m pip install jupyter-matlab-proxy
115
93
# Ensure jupyter-server-proxy JupyterLab extension is installed
116
94
RUN jupyter labextension install @jupyterlab/server-proxy
117
95
118
- # Uncomment and set the port and hostname to configure a network license manager for all users
119
- # ENV MLM_LICENSE_FILE port@hostname
96
+ # Make JupyterLab the default environment
97
+ ENV JUPYTER_ENABLE_LAB="yes"
98
+
99
+ ENV MW_CONTEXT_TAGS=${MW_CONTEXT_TAGS}
0 commit comments