|
| 1 | +# Copyright 2025 The MathWorks, Inc. |
| 2 | + |
| 3 | +# Light weight image only to test Jupyter Notebook UI |
| 4 | + |
| 5 | +# Using the default python version in Databricks Runtime 17.3-LTS |
| 6 | +ARG PYTHON_VERSION=3.12 |
| 7 | +ARG MATLAB_RELEASE="R2025b" |
| 8 | +ARG UBUNTU_VERSION="24.04" |
| 9 | +# Default installation directory for MATLAB |
| 10 | +ARG MATLAB_INSTALL_LOCATION="/opt/matlab" |
| 11 | +ARG MATLAB_PRODUCT_LIST="MATLAB" |
| 12 | + |
| 13 | +FROM ubuntu:24.04 |
| 14 | + |
| 15 | +ARG PYTHON_VERSION |
| 16 | +ARG MATLAB_RELEASE |
| 17 | +ARG UBUNTU_VERSION |
| 18 | +ARG MATLAB_INSTALL_LOCATION |
| 19 | +ARG MATLAB_PRODUCT_LIST |
| 20 | + |
| 21 | +ENV DEBIAN_FRONTEND=noninteractive |
| 22 | +# Install build dependencies, install UV (for python) and NVM (for nodejs) |
| 23 | +RUN apt-get update && \ |
| 24 | + apt-get install -y --no-install-recommends \ |
| 25 | + git \ |
| 26 | + wget \ |
| 27 | + curl \ |
| 28 | + unzip \ |
| 29 | + ca-certificates && \ |
| 30 | + rm -rf /var/lib/apt/lists/* |
| 31 | + |
| 32 | +# Install MATLAB dependencies and MATLAB using MPM |
| 33 | +ARG MATLAB_DEPS_URL="https://raw.githubusercontent.com/mathworks-ref-arch/container-images/main/matlab-deps/${MATLAB_RELEASE}/ubuntu${UBUNTU_VERSION}/base-dependencies.txt" |
| 34 | +ARG MATLAB_DEPENDENCIES="matlab-deps-${MATLAB_RELEASE}-base-dependencies.txt" |
| 35 | +ARG ADDITIONAL_PACKAGES="wget curl unzip ca-certificates xvfb git vim fluxbox" |
| 36 | +RUN export DEBIAN_FRONTEND=noninteractive && apt-get update \ |
| 37 | + && apt-get install --no-install-recommends -y ${ADDITIONAL_PACKAGES}\ |
| 38 | + && wget $(echo ${MATLAB_DEPS_URL} | tr "[:upper:]" "[:lower:]") -O ${MATLAB_DEPENDENCIES} \ |
| 39 | + && xargs -a ${MATLAB_DEPENDENCIES} -r apt-get install --no-install-recommends -y \ |
| 40 | + && apt-get clean \ |
| 41 | + && apt-get -y autoremove \ |
| 42 | + && rm -rf /var/lib/apt/lists/* ${MATLAB_DEPENDENCIES} |
| 43 | + |
| 44 | +RUN echo "Installing MATLAB using MPM..." |
| 45 | +RUN wget -q https://www.mathworks.com/mpm/glnxa64/mpm && \ |
| 46 | + chmod +x mpm \ |
| 47 | + && ./mpm install --release=${MATLAB_RELEASE} --destination=${MATLAB_INSTALL_LOCATION} \ |
| 48 | + --products ${MATLAB_PRODUCT_LIST} \ |
| 49 | + || (echo "MPM Installation Failure. See below for more information:" && cat /tmp/mathworks_root.log && false)\ |
| 50 | + && rm -f /tmp/mathworks_root.log \ |
| 51 | + && ln -s ${MATLAB_INSTALL_LOCATION}/bin/matlab /usr/local/bin/matlab \ |
| 52 | + && mv mpm /usr/local/bin |
| 53 | + |
| 54 | + |
| 55 | +# Installs UV for all users |
| 56 | +RUN curl -LsSf https://astral.sh/uv/install.sh | \ |
| 57 | + UV_INSTALL_DIR=/usr/local/bin INSTALLER_NO_MODIFY_PATH=1 sh |
| 58 | + |
| 59 | +# Create a python environment for the ROOT user |
| 60 | +COPY requirements.txt /tmp/requirements.txt |
| 61 | +RUN uv venv /local-dev-env --python ${PYTHON_VERSION} && uv pip install -r /tmp/requirements.txt --python /local-dev-env/bin/python |
| 62 | +RUN UV_PYTHON_INSTALL_DIR=/opt/uv-python UV_TOOL_BIN_DIR=/usr/local/bin UV_TOOL_DIR=/opt/uv-tools \ |
| 63 | +uv tool install matlab-proxy --force --python ${PYTHON_VERSION} && \ |
| 64 | +chmod -R 755 /opt/uv-tools && chmod -R 755 /opt/uv-python |
0 commit comments