|
| 1 | +# Copyright 2020 The MathWorks, Inc. |
| 2 | + |
| 3 | +# Replace "matlab:r2020b" with the Docker image that contains MATLAB |
| 4 | +# MATLAB should be installed at /usr/local/MATLAB or other changes will need |
| 5 | +# to be made to this Dockerfile |
| 6 | +FROM matlab:r2020b AS matlab-install-stage |
| 7 | + |
| 8 | +FROM jupyter/base-notebook |
| 9 | + |
| 10 | +USER root |
| 11 | + |
| 12 | +# Copy MATLAB install from Docker image |
| 13 | +COPY --from=matlab-install-stage /usr/local/MATLAB /usr/local/MATLAB |
| 14 | + |
| 15 | +# Add MATLAB to the path |
| 16 | +RUN ln -s /usr/local/MATLAB/bin/matlab /usr/local/bin/matlab |
| 17 | + |
| 18 | +# Install MATLAB dependencies |
| 19 | +# Reference: https://github.com/mathworks-ref-arch/container-images/tree/master/matlab-deps |
| 20 | +RUN export DEBIAN_FRONTEND=noninteractive && apt-get update && apt-get install --no-install-recommends -y \ |
| 21 | + libasound2 \ |
| 22 | + libatk1.0-0 \ |
| 23 | + libc6 \ |
| 24 | + libcairo-gobject2 \ |
| 25 | + libcairo2 \ |
| 26 | + libcrypt1 \ |
| 27 | + libcups2 \ |
| 28 | + libdbus-1-3 \ |
| 29 | + libfontconfig1 \ |
| 30 | + libgdk-pixbuf2.0-0 \ |
| 31 | + libgstreamer-plugins-base1.0-0 \ |
| 32 | + libgstreamer1.0-0 \ |
| 33 | + libgtk-3-0 \ |
| 34 | + libnspr4 \ |
| 35 | + libnss3 \ |
| 36 | + libpam0g \ |
| 37 | + libpango-1.0-0 \ |
| 38 | + libpangocairo-1.0-0 \ |
| 39 | + libpangoft2-1.0-0 \ |
| 40 | + libpython2.7 \ |
| 41 | + libpython3.8 \ |
| 42 | + libselinux1 \ |
| 43 | + libsm6 \ |
| 44 | + libsndfile1 \ |
| 45 | + libtcl8.6 \ |
| 46 | + libuuid1 \ |
| 47 | + libx11-6 \ |
| 48 | + libx11-xcb1 \ |
| 49 | + libxcb1 \ |
| 50 | + libxcomposite1 \ |
| 51 | + libxcursor1 \ |
| 52 | + libxdamage1 \ |
| 53 | + libxext6 \ |
| 54 | + libxfixes3 \ |
| 55 | + libxft2 \ |
| 56 | + libxi6 \ |
| 57 | + libxinerama1 \ |
| 58 | + libxrandr2 \ |
| 59 | + libxrender1 \ |
| 60 | + libxt6 \ |
| 61 | + libxtst6 \ |
| 62 | + libxxf86vm1 \ |
| 63 | + zlib1g \ |
| 64 | + xkb-data \ |
| 65 | + procps \ |
| 66 | + ca-certificates \ |
| 67 | + sudo \ |
| 68 | + locales locales-all \ |
| 69 | + && apt-get clean \ |
| 70 | + && apt-get -y autoremove \ |
| 71 | + && rm -rf /var/lib/apt/lists/* |
| 72 | + |
| 73 | +# Install jupyter-matlab-vnc dependencies |
| 74 | +RUN export DEBIAN_FRONTEND=noninteractive \ |
| 75 | + && apt-get -y update \ |
| 76 | + && apt-get install -y \ |
| 77 | + dbus-x11 \ |
| 78 | + firefox \ |
| 79 | + xfce4 \ |
| 80 | + xfce4-panel \ |
| 81 | + xfce4-session \ |
| 82 | + xfce4-settings \ |
| 83 | + xorg \ |
| 84 | + xubuntu-icon-theme \ |
| 85 | + curl \ |
| 86 | + && apt-get clean \ |
| 87 | + && apt-get -y autoremove \ |
| 88 | + && rm -rf /var/lib/apt/lists/* |
| 89 | + |
| 90 | +# Install tigervnc to /usr/local |
| 91 | +RUN curl -sSfL 'https://bintray.com/tigervnc/stable/download_file?file_path=tigervnc-1.10.1.x86_64.tar.gz' \ |
| 92 | + | tar -zxf - -C /usr/local --strip=2 |
| 93 | + |
| 94 | +# noVNC provides VNC over browser capability |
| 95 | +# Set default install location for noVNC |
| 96 | +ARG NOVNC_PATH=/opt/noVNC |
| 97 | + |
| 98 | +# Get noVNC |
| 99 | +RUN mkdir -p ${NOVNC_PATH} \ |
| 100 | + && curl -sSfL 'https://github.com/novnc/noVNC/archive/v1.2.0.tar.gz' \ |
| 101 | + | tar -zxf - -C ${NOVNC_PATH} --strip=1 \ |
| 102 | + && chown -R ${NB_USER}:users ${NOVNC_PATH} |
| 103 | + |
| 104 | +# Change user to jovyan from root as we do not want any changes to be made as root in the container |
| 105 | +USER $NB_USER |
| 106 | + |
| 107 | +# Get websockify |
| 108 | +RUN conda install -y -q websockify=0.9.0 |
| 109 | + |
| 110 | +# Set environment variable for python package jupyter-matlab-vnc-proxy |
| 111 | +ENV NOVNC_PATH=${NOVNC_PATH} |
| 112 | +# Pip install the integration |
| 113 | +RUN python -m pip install https://github.com/mathworks/jupyter-matlab-vnc-proxy/archive/0.1.0.tar.gz |
| 114 | + |
| 115 | +# Ensure jupyter-server-proxy JupyterLab extension is installed |
| 116 | +RUN jupyter labextension install @jupyterlab/server-proxy |
| 117 | + |
| 118 | +# Move MATLAB resource files to the expected locations |
| 119 | +RUN export RESOURCES_LOC=$(python -c "import jupyter_matlab_vnc_proxy as pkg; print(pkg.__path__[0])")/resources \ |
| 120 | + && mkdir -p ${HOME}/.local/share/applications ${HOME}/Desktop ${HOME}/.local/share/ ${HOME}/.icons \ |
| 121 | + && cp ${RESOURCES_LOC}/MATLAB.desktop ${HOME}/Desktop/ \ |
| 122 | + && cp ${RESOURCES_LOC}/MATLAB.desktop ${HOME}/.local/share/applications\ |
| 123 | + && ln -s ${RESOURCES_LOC}/matlab_icon.png ${HOME}/.icons/matlab_icon.png \ |
| 124 | + && cp ${RESOURCES_LOC}/matlab_launcher.py ${HOME}/.local/share/ \ |
| 125 | + && cp ${RESOURCES_LOC}/mw_lite.html ${NOVNC_PATH} |
| 126 | + |
| 127 | +# Fixes occasional failure to start VNC desktop, which requires a reloading of the webpage to fix. |
| 128 | +RUN touch ${HOME}/.Xauthority |
| 129 | + |
| 130 | +# Uncomment and set the port and hostname to configure a network license manager for all users |
| 131 | +# ENV MLM_LICENSE_FILE port@hostname |
0 commit comments