Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,8 @@ jobs:
- matlab
baseImage:
- debian:latest
# Update to ubuntu:latest when R2024b support for it has been released in matlab-deps
- ubuntu:22.04
- mcr.microsoft.com/devcontainers/base:ubuntu
- registry.access.redhat.com/ubi9/ubi:latest
steps:
- uses: actions/checkout@v3

Expand Down
7 changes: 4 additions & 3 deletions src/matlab/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,22 @@ Installs MATLAB with supporting packages and tools.

```json
"features": {
"ghcr.io/mathworks/devcontainer-features/matlab:0": {}
"ghcr.io/prabhakk-mw/devcontainer-features/matlab:0": {}
}
```

## Options

| Options Id | Description | Type | Default Value |
|-----|-----|-----|-----|
| release | MATLAB Release to install. | string | R2024b |
| release | MATLAB Release to install. | string | R2025b |
| products | Products to install, specified as a list of space-separated product names.</br> For details of products, see [MATLAB Package Manager](https://github.com/mathworks-ref-arch/matlab-dockerfile/blob/main/MPM.md#product-installation-options). | string | MATLAB |
| doc | Flag to install documentation and examples (R2022b and earlier releases). | boolean | false |
| installGpu | Skips installation of GPU libraries when you install Parallel Computing Toolbox (R2023a and later releases). | boolean | false |
| destination | Full path to the installation destination folder. Default: /opt/matlab/${RELEASE^} | string | - |
| installMatlabProxy | Installs matlab-proxy and its dependencies (R2020b and later releases). | boolean | false |
| installJupyterMatlabProxy | Installs jupyter-matlab-proxy and its dependencies (R2020b and later releases). | boolean | false |
| installJupyterLab | Installs jupyterlab | boolean | false |
| installMatlabEngineForPython | Installs the MATLAB Engine for Python if the destination option is set correctly. | boolean | false |
| startInDesktop | Starts matlab-proxy when container starts. | string | false |
| networkLicenseManager | MATLAB will use the specified Network License Manager. | string | - |
Expand All @@ -37,4 +38,4 @@ Installs MATLAB with supporting packages and tools.

---

_Note: This file was auto-generated from the [devcontainer-feature.json](https://github.com/mathworks/devcontainer-features/blob/main/src/matlab/devcontainer-feature.json). Add additional notes to a `NOTES.md`._
_Note: This file was auto-generated from the [devcontainer-feature.json](https://github.com/prabhakk-mw/devcontainer-features/blob/main/src/matlab/devcontainer-feature.json). Add additional notes to a `NOTES.md`._
15 changes: 11 additions & 4 deletions src/matlab/devcontainer-feature.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
{
"name": "MATLAB",
"id": "matlab",
"version": "0.2.0",
"version": "0.3.0",
"description": "Installs MATLAB with supporting packages and tools.",
"documentationURL": "https://github.com/mathworks/devcontainer-features",
"options": {
"release": {
"type": "string",
"proposals": [
"R2025b",
"R2025a",
"R2024b",
"R2024a",
"R2023b",
Expand All @@ -21,7 +23,7 @@
"R2019b",
"R2019a"
],
"default": "R2024b",
"default": "R2025b",
"description": "MATLAB Release to install."
},
"products": {
Expand Down Expand Up @@ -58,6 +60,11 @@
"description": "Installs jupyter-matlab-proxy and its dependencies (R2020b and later releases).",
"type": "boolean"
},
"installJupyterLab": {
"default": false,
"description": "Installs jupyterlab",
"type": "boolean"
},
"installMatlabEngineForPython": {
"default": false,
"description": "Installs the MATLAB Engine for Python if the destination option is set correctly.",
Expand Down Expand Up @@ -95,8 +102,8 @@
],
"settings": {
"MATLAB.indexWorkspace": true,
"MATLAB.installPath": "/usr/local/bin/matlab",
"MATLAB.matlabConnectionTiming": "never",
"MATLAB.signIn": true,
"MATLAB.matlabConnectionTiming": "onDemand",
"MATLAB.telemetry": true
}
}
Expand Down
21 changes: 16 additions & 5 deletions src/matlab/install-helper-functions.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env bash
#-------------------------------------------------------------------------------------------------------------
# Copyright 2024 The MathWorks, Inc.
# Copyright 2024-2025 The MathWorks, Inc.
#-------------------------------------------------------------------------------------------------------------
# Helpers functions to encapsulate OS specific installation

Expand Down Expand Up @@ -34,12 +34,11 @@ function ihf_get_matlab_deps_os() {
case ${LINUX_DISTRO} in
debian)
if [[ "${ID}" == "ubuntu" ]]; then
local SUPPORTED_VERSION_CODENAME="focal jammy"
MATLAB_DEPS_OS_VERSION=${ID}${VERSION_ID}
elif [[ "${ID}" == "debian" ]]; then
local SUPPORTED_VERSION_CODENAME="bullseye bookworm"
elif [[ "${ID}" == "debian" ]]; then
local UBUNTU_VERSION_ID=${VERSION_ID/11/20.04}
UBUNTU_VERSION_ID=${UBUNTU_VERSION_ID/12/22.04}
UBUNTU_VERSION_ID=${UBUNTU_VERSION_ID/13/24.04}
MATLAB_DEPS_OS_VERSION=ubuntu${UBUNTU_VERSION_ID}
fi
;;
Expand Down Expand Up @@ -136,7 +135,7 @@ function ihf_get_remove_cmd() {
# returns "true/false" string if MATLAB_RELEASE is valid
function ihf_is_valid_matlab_release() {
# List of supported MATLAB_RELEASE values
local _SUPPORTED_MATLAB_RELEASES=("R2024b" "R2024a" "R2023b" "R2023a" "R2022b" "R2022a" "R2021b" "R2021a" "R2020b" "R2020a" "R2019b" "R2019a")
local _SUPPORTED_MATLAB_RELEASES=("R2025b" "R2025a" "R2024b" "R2024a" "R2023b" "R2023a" "R2022b" "R2022a" "R2021b" "R2021a" "R2020b" "R2020a" "R2019b" "R2019a")

## Validate MATLAB_RELEASE
if [ -z "$MATLAB_RELEASE" ]; then
Expand Down Expand Up @@ -164,6 +163,18 @@ function ihf_is_debian_or_rhel() {
fi
}


function ihf_is_debian_13 {
. /etc/os-release
if [ "${ID}" = "debian" ] && [ "${VERSION_ID}" = "13" ]; then
# True
return 0
else
# False
return 1
fi
}

function ihf_clean_up() {
local LINUX_DISTRO=$(ihf_is_debian_or_rhel)
case ${LINUX_DISTRO} in
Expand Down
7 changes: 5 additions & 2 deletions src/matlab/install-matlab-deps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# This script install the OS dependencies required by MATLAB for the release specified in the
# environment variable MATLAB_RELEASE on any linux OS that is dervied from Ubuntu or RHEL
#-------------------------------------------------------------------------------------------------------------
# Copyright 2024 The MathWorks, Inc.
# Copyright 2024-2025 The MathWorks, Inc.
#-------------------------------------------------------------------------------------------------------------

set -eu -o pipefail
Expand Down Expand Up @@ -43,6 +43,10 @@ function get_base_dependencies_list() {
local BASE_DEPS_URL=https://raw.githubusercontent.com/mathworks-ref-arch/container-images/main/matlab-deps/${MATLAB_RELEASE,}/${MATLAB_DEPS_OS_VERSION}/base-dependencies.txt
# Get matlab_deps - if this fails, then we aren't on a supported os
local PKGS=$(wget -qO- ${BASE_DEPS_URL})
# if Debian 13, then remove packages which have dpdk in their name
if ihf_is_debian_13; then
PKGS=$(echo $PKGS | tr ' ' '\n' | grep -v 'dpdk' | tr '\n' ' ')
fi
if [ -z "$PKGS" ]; then
ihf_print_and_exit "${MATLAB_DEPS_OS_VERSION} is not a supported OS for MATLAB ${MATLAB_RELEASE} ."
fi
Expand All @@ -51,7 +55,6 @@ function get_base_dependencies_list() {

function install_matlab_deps() {
local MATLAB_DEPS_OS_VERSION=$(ihf_get_matlab_deps_os)
# local linux_distro=$(ihf_is_debian_or_rhel)

print_os_info

Expand Down
106 changes: 74 additions & 32 deletions src/matlab/install.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env bash
#-------------------------------------------------------------------------------------------------------------
# Copyright 2024 The MathWorks, Inc.
# Copyright 2024-2025 The MathWorks, Inc.
#-------------------------------------------------------------------------------------------------------------
# NOTE: The 'install.sh' entrypoint script is always executed as the root user.

Expand All @@ -17,14 +17,15 @@ set -eu -o pipefail

## Set defaults to all the options in the feature.

# R2024b is the latest available release.
RELEASE="${RELEASE:-"R2024b"}"
# R2025b is the latest available release.
RELEASE="${RELEASE:-"R2025b"}"
PRODUCTS="${PRODUCTS:-"MATLAB"}"
DOC="${DOC:-"false"}"
INSTALLGPU="${INSTALLGPU:-"false"}"
DESTINATION="${DESTINATION:-"/opt/matlab/${RELEASE^}"}"
INSTALLMATLABPROXY="${INSTALLMATLABPROXY:-"false"}"
INSTALLJUPYTERMATLABPROXY="${INSTALLJUPYTERMATLABPROXY:-"false"}"
INSTALLJUPYTERLAB="${INSTALLJUPYTERLAB:-"false"}"
INSTALLMATLABENGINEFORPYTHON="${INSTALLMATLABENGINEFORPYTHON:-"false"}"
STARTINDESKTOP="${STARTINDESKTOP:-"false"}"
NETWORKLICENSEMANAGER="${NETWORKLICENSEMANAGER:-" "}"
Expand All @@ -45,28 +46,33 @@ _CONTAINER_USER="${_CONTAINER_USER:-"undefined"}"

_SCRIPT_LOCATION=$(dirname $(readlink -f "$0"))

_PIP_INSTALL="python3 -m pip install"
export PIP_BREAK_SYSTEM_PACKAGES=1

### Variable Declaration End ###
### Helper Functions Begin ###
export DEBIAN_FRONTEND=noninteractive

function updaterc() {
echo "Updating /etc/bash.bashrc and /etc/zsh/zshrc..."
if [[ "$(cat /etc/bash.bashrc)" != *"$1"* ]]; then
echo -e "$1" >>/etc/bash.bashrc
fi
if [ -f "/etc/zsh/zshrc" ] && [[ "$(cat /etc/zsh/zshrc)" != *"$1"* ]]; then
echo -e "$1" >>/etc/zsh/zshrc
updaterc() {
local _bashrc
local _zshrc
IS_DEBIAN_OR_RHEL=$(ihf_is_debian_or_rhel)
case $IS_DEBIAN_OR_RHEL in
debian) echo "Updating /etc/bash.bashrc and /etc/zsh/zshrc..."
_bashrc=/etc/bash.bashrc
_zshrc=/etc/zsh/zshrc
;;
rhel) echo "Updating /etc/bashrc and /etc/zshrc..."
_bashrc=/etc/bashrc
_zshrc=/etc/zshrc
;;
esac
if [[ "$(cat ${_bashrc})" != *"$1"* ]]; then
echo -e "$1" >> ${_bashrc}
fi
}

function install_python_and_pip() {
if [ "$(ihf_is_debian_or_rhel)" == "rhel" ]; then
# uninstalling python3-requests package as it cannot be updated by subsequent install command.
ihf_remove_packages "python3-requests"
if [ -f "${_zshrc}" ] && [[ "$(cat ${_zshrc})" != *"$1"* ]]; then
echo -e "$1" >> ${_zshrc}
fi
ihf_install_packages "python3 python3-pip" && \
python3 -m pip install --upgrade pip

}

function install_xvfb() {
Expand All @@ -76,22 +82,52 @@ function install_xvfb() {
fi
}

_INSTALL_PYTHON_AND_PIP_HAS_BEEN_INSTALLED=0
function install_python_and_pip() {
if [ "$_INSTALL_PYTHON_AND_PIP_HAS_BEEN_INSTALLED" -eq 0 ]; then
if [ "$(ihf_is_debian_or_rhel)" == "rhel" ]; then
# uninstalling python3-requests package as it cannot be updated by subsequent install command.
ihf_remove_packages "python3-requests"
fi
ihf_install_packages "python3 python3-pip"
_INSTALL_PYTHON_AND_PIP_HAS_BEEN_INSTALLED=1
else
echo "Python and PIP already installed."
fi
}

_MATLAB_PROXY_HAS_BEEN_INSTALLED=0
function install_matlab_proxy() {
install_python_and_pip &&
install_xvfb &&
python3 -m pip install --upgrade matlab-proxy
if [ "$_MATLAB_PROXY_HAS_BEEN_INSTALLED" -eq 0 ]; then
install_python_and_pip
install_xvfb

$_PIP_INSTALL matlab-proxy

_MATLAB_PROXY_HAS_BEEN_INSTALLED=1
else
echo "MATLAB Proxy already installed."
fi
}

function install_jupyter_matlab_proxy() {
install_python_and_pip &&
install_xvfb &&
python3 -m pip install --upgrade jupyter-matlab-proxy matlab-proxy jupyterlab jupyterlab-git
install_python_and_pip
$_PIP_INSTALL jupyter-matlab-proxy
}

function install_jupyterlab() {
install_python_and_pip
$_PIP_INSTALL jupyterlab jupyter
}

function install_matlab_engine_for_python() {
# Installing the engine is tricky
# The installation can fail if the python version does not match the supported release
install_python_and_pip

# TODO: Skip installation if MATLAB Engine for Python does not support of Python version
# See: https://mathworks.com/support/requirements/python-compatibility.html
declare -A matlabengine_map
matlabengine_map['R2025b']="25.2"
matlabengine_map['R2025a']="25.1"
matlabengine_map['R2024b']="24.2"
matlabengine_map['R2024a']="24.1"
matlabengine_map['R2023b']="23.2"
Expand All @@ -102,12 +138,10 @@ function install_matlab_engine_for_python() {
matlabengine_map['R2021a']="9.10"
matlabengine_map['R2020b']="9.9"

install_python_and_pip &&

echo "Setting LD_LIBRARY_PATH=${_LD_LIBRARY_PATH}"

env LD_LIBRARY_PATH=${_LD_LIBRARY_PATH} \
python3 -m pip install matlabengine==${matlabengine_map[$MATLAB_RELEASE]}.*
$_PIP_INSTALL matlabengine==${matlabengine_map[$MATLAB_RELEASE]}.*
echo "Setting LD_LIBRARY_PATH=${_LD_LIBRARY_PATH}"
}

# Create a home folder for non-root, undefined CONTAINER_USER, if not already available
Expand Down Expand Up @@ -169,6 +203,12 @@ if [ "${INSTALLJUPYTERMATLABPROXY}" == "true" ]; then
install_jupyter_matlab_proxy
fi

# Install jupyterlab if requested
if [ "${INSTALLJUPYTERLAB}" == "true" ]; then
echo "Installing jupyterlab"
install_jupyterlab
fi

if [ "${STARTINDESKTOP}" == "true" ] || [ "${STARTINDESKTOP}" == "test" ]; then
echo "User wants to start in MATLAB Desktop."
# Leave a marker file that can be checked by the postStartCommand
Expand Down Expand Up @@ -202,6 +242,7 @@ fi

# Update RC files with the provided license manager info
if [ ! -z "${NETWORKLICENSEMANAGER}" -a "${NETWORKLICENSEMANAGER}" != " " ]; then
echo "Saving NLM info to bashrc and zshrc"
updaterc "export MLM_LICENSE_FILE=${NETWORKLICENSEMANAGER}"
fi

Expand All @@ -225,7 +266,7 @@ if [ "$SKIPMATLABINSTALL" != 'true' ]; then

# Handle GPU installation
if [ "${INSTALLGPU}" == "false" ]; then
RELEASES_THAT_SUPPORT_NOGPU=("R2024b" "R2024a" "R2023b" "R2023a")
RELEASES_THAT_SUPPORT_NOGPU=("R2025a" "R2024b" "R2024a" "R2023b" "R2023a")
# The value variable is assigned a regex that matches the exact value
value="\<${MATLAB_RELEASE}\>"
if [[ ${RELEASES_THAT_SUPPORT_NOGPU[@]} =~ $value ]]; then
Expand Down Expand Up @@ -297,4 +338,5 @@ fi
popd
### Script Section End ###
echo "MATLAB feature installation is complete."
unset PIP_BREAK_SYSTEM_PACKAGES
exit 0
Loading