|
| 1 | +# Building from Dockerfile provided by Mathworks |
| 2 | +# https://github.com/mathworks-ref-arch/matlab-dockerfile/blob/main/Dockerfile |
| 3 | + |
| 4 | +# Specify MATLAB release |
| 5 | +ARG MATLAB_RELEASE=R2024b |
| 6 | + |
| 7 | +# Specify the list of products to install into MATLAB. |
| 8 | +ARG MATLAB_PRODUCT_LIST="MATLAB Computer_Vision_Toolbox Control_System_Toolbox Deep_Learning_Toolbox Image_Processing_Toolbox Optimization_Toolbox Parallel_Computing_Toolbox Statistics_and_Machine_Learning_Toolbox Symbolic_Math_Toolbox System_Identification_Toolbox Deep_Learning_Toolbox_Converter_for_ONNX_Model_Format" |
| 9 | + |
| 10 | +# Specify MATLAB Install Location. |
| 11 | +ARG MATLAB_INSTALL_LOCATION="/opt/matlab/${MATLAB_RELEASE}" |
| 12 | + |
| 13 | +# Specify license server information using the format: port@hostname |
| 14 | +ARG LICENSE_SERVER="27009@licenseserver.it.vanderbilt.edu" |
| 15 | + |
| 16 | +# To check the available matlab-deps images, see: https://hub.docker.com/r/mathworks/matlab-deps |
| 17 | +FROM mathworks/matlab-deps:${MATLAB_RELEASE} |
| 18 | + |
| 19 | +# Declare build arguments to use at the current build stage. |
| 20 | +ARG MATLAB_RELEASE |
| 21 | +ARG MATLAB_PRODUCT_LIST |
| 22 | +ARG MATLAB_INSTALL_LOCATION |
| 23 | +ARG LICENSE_SERVER |
| 24 | + |
| 25 | +# Install mpm dependencies. |
| 26 | +RUN export DEBIAN_FRONTEND=noninteractive \ |
| 27 | + && apt-get update \ |
| 28 | + && apt-get install --no-install-recommends --yes \ |
| 29 | + wget \ |
| 30 | + ca-certificates \ |
| 31 | + && apt-get clean \ |
| 32 | + && apt-get autoremove \ |
| 33 | + && apt-get install -y git \ |
| 34 | + && rm -rf /var/lib/apt/lists/* |
| 35 | + |
| 36 | +# Add "matlab" user and grant sudo permission. |
| 37 | +RUN adduser --shell /bin/bash --disabled-password --gecos "" matlab \ |
| 38 | + && echo "matlab ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/matlab \ |
| 39 | + && chmod 0440 /etc/sudoers.d/matlab |
| 40 | + |
| 41 | +# Set user and work directory. |
| 42 | +USER matlab |
| 43 | +WORKDIR /home/matlab |
| 44 | + |
| 45 | +# Run mpm to install MATLAB in the target location and delete the mpm installation afterwards. |
| 46 | +# If mpm fails to install successfully, then print the logfile in the terminal, otherwise clean up. |
| 47 | +# Pass in $HOME variable to install support packages into the user's HOME folder. |
| 48 | +RUN wget -q https://www.mathworks.com/mpm/glnxa64/mpm \ |
| 49 | + && chmod +x mpm \ |
| 50 | + && sudo HOME=${HOME} ./mpm install \ |
| 51 | + --release=${MATLAB_RELEASE} \ |
| 52 | + --destination=${MATLAB_INSTALL_LOCATION} \ |
| 53 | + --products ${MATLAB_PRODUCT_LIST} \ |
| 54 | + || (echo "MPM Installation Failure. See below for more information:" && cat /tmp/mathworks_root.log && false) \ |
| 55 | + && sudo rm -rf mpm /tmp/mathworks_root.log \ |
| 56 | + && sudo ln -s ${MATLAB_INSTALL_LOCATION}/bin/matlab /usr/local/bin/matlab |
| 57 | + |
| 58 | + |
| 59 | +ENV MLM_LICENSE_FILE=$LICENSE_SERVER |
| 60 | + |
| 61 | +# Install nnv |
| 62 | +RUN git clone https://github.com/verivital/nnv.git |
| 63 | + |
| 64 | +WORKDIR nnv |
| 65 | + |
| 66 | +RUN matlab -nodisplay -r "cd code/nnv/; install; exit()" |
0 commit comments