|
| 1 | +# Copyright 2025 The MathWorks, Inc. |
| 2 | + |
| 3 | +# Full image, with MATLAB and MATLAB Proxy |
| 4 | + |
| 5 | +ARG PYTHON_VERSION=3.11 |
| 6 | +ARG NODE_VERSION=20 |
| 7 | +ARG NVM_VERSION="0.40.3" |
| 8 | +ARG MATLAB_RELEASE="R2025b" |
| 9 | +ARG UBUNTU_VERSION="24.04" |
| 10 | +# Default installation directory for MATLAB |
| 11 | +ARG MATLAB_INSTALL_LOCATION="/opt/matlab" |
| 12 | +ARG MATLAB_PRODUCT_LIST="MATLAB" |
| 13 | + |
| 14 | +FROM ubuntu:${UBUNTU_VERSION} |
| 15 | + |
| 16 | +ARG NVM_VERSION |
| 17 | +ARG PYTHON_VERSION |
| 18 | +ARG NODE_VERSION |
| 19 | +ARG MATLAB_RELEASE |
| 20 | +ARG UBUNTU_VERSION |
| 21 | +ARG MATLAB_INSTALL_LOCATION |
| 22 | +ARG MATLAB_PRODUCT_LIST |
| 23 | + |
| 24 | +ENV DEBIAN_FRONTEND=noninteractive |
| 25 | +# Install build dependencies, install UV (for python) and NVM (for nodejs) |
| 26 | +RUN apt-get update && \ |
| 27 | + apt-get install -y --no-install-recommends \ |
| 28 | + git \ |
| 29 | + wget \ |
| 30 | + curl \ |
| 31 | + unzip \ |
| 32 | + xvfb \ |
| 33 | + fluxbox \ |
| 34 | + ca-certificates && \ |
| 35 | + rm -rf /var/lib/apt/lists/* |
| 36 | + |
| 37 | +USER ubuntu |
| 38 | + |
| 39 | +# Updates the default shell to bash instead of sh |
| 40 | +SHELL ["/bin/bash", "-c"] |
| 41 | + |
| 42 | +WORKDIR /home/ubuntu |
| 43 | +# Set up development environment for ubuntu user with UV and NVM |
| 44 | +RUN curl -LsSf https://astral.sh/uv/install.sh | sh && \ |
| 45 | + source ${HOME}/.local/bin/env && \ |
| 46 | + uv python install ${PYTHON_VERSION} && \ |
| 47 | + curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v${NVM_VERSION}/install.sh | bash && \ |
| 48 | + export NVM_DIR="/home/ubuntu/.nvm" && [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" && \ |
| 49 | + nvm install ${NODE_VERSION} |
| 50 | + |
| 51 | +# Now the matlab-proxy directory can be mounted and tested for build |
| 52 | + |
| 53 | +USER root |
| 54 | + |
| 55 | +# Install MATLAB dependencies and MATLAB using MPM |
| 56 | +ARG MATLAB_DEPS_URL="https://raw.githubusercontent.com/mathworks-ref-arch/container-images/main/matlab-deps/${MATLAB_RELEASE}/ubuntu${UBUNTU_VERSION}/base-dependencies.txt" |
| 57 | +ARG MATLAB_DEPENDENCIES="matlab-deps-${MATLAB_RELEASE}-base-dependencies.txt" |
| 58 | +ARG ADDITIONAL_PACKAGES="wget curl unzip ca-certificates xvfb git vim fluxbox gettext" |
| 59 | +RUN export DEBIAN_FRONTEND=noninteractive && apt-get update \ |
| 60 | + && apt-get install --no-install-recommends -y ${ADDITIONAL_PACKAGES}\ |
| 61 | + && wget $(echo ${MATLAB_DEPS_URL} | tr "[:upper:]" "[:lower:]") -O ${MATLAB_DEPENDENCIES} \ |
| 62 | + && xargs -a ${MATLAB_DEPENDENCIES} -r apt-get install --no-install-recommends -y \ |
| 63 | + && apt-get clean \ |
| 64 | + && apt-get -y autoremove \ |
| 65 | + && rm -rf /var/lib/apt/lists/* ${MATLAB_DEPENDENCIES} |
| 66 | + |
| 67 | +WORKDIR /matlab-install |
| 68 | +ARG MSH_MANAGED_INSTALL_ROOT=/usr/local/MathWorks/ServiceHost/ |
| 69 | +ARG MSH_DOWNLOAD_LOCATION=/tmp/Downloads/MathWorks/ServiceHost |
| 70 | +# Dont need to set HOME to install Support packages as jupyter images set HOME to NB_USER in all images, even for ROOT. |
| 71 | +RUN echo "Installing MATLAB using MPM..." |
| 72 | +RUN wget -q https://www.mathworks.com/mpm/glnxa64/mpm && \ |
| 73 | + chmod +x mpm \ |
| 74 | + && ./mpm install --release=${MATLAB_RELEASE} --destination=${MATLAB_INSTALL_LOCATION} \ |
| 75 | + --products ${MATLAB_PRODUCT_LIST} \ |
| 76 | + || (echo "MPM Installation Failure. See below for more information:" && cat /tmp/mathworks_root.log && false)\ |
| 77 | + && rm -f mpm /tmp/mathworks_root.log \ |
| 78 | + && ln -s ${MATLAB_INSTALL_LOCATION}/bin/matlab /usr/local/bin/matlab \ |
| 79 | + && git clone https://github.com/mathworks-ref-arch/administer-mathworks-service-host.git \ |
| 80 | + && cd /matlab-install/administer-mathworks-service-host/admin-scripts/linux/admin-controlled-installation \ |
| 81 | + && ./download_msh.sh --destination ${MSH_DOWNLOAD_LOCATION} \ |
| 82 | + && ./install_msh.sh --source ${MSH_DOWNLOAD_LOCATION} --destination ${MSH_MANAGED_INSTALL_ROOT} --no-update-environment \ |
| 83 | + && ./cleanup_default_msh_installation_location.sh --for-all-users \ |
| 84 | + && cd / && rm -rf /matlab-install ${MSH_DOWNLOAD_LOCATION} |
| 85 | + |
| 86 | +ENV MATHWORKS_SERVICE_HOST_MANAGED_INSTALL_ROOT=${MSH_MANAGED_INSTALL_ROOT} |
| 87 | + |
| 88 | +USER ubuntu |
| 89 | +WORKDIR /home/ubuntu |
0 commit comments